/**
  * Displays the GUI showing the data
  */
 function display($pid = 0)
 {
     global $root_path, $dbf_nodate, $newdata, $kb_other_his_array, $lang;
     // $_SESSION;
     $validdata = TRUE;
     if (!empty($pid)) {
         $this->pid = $pid;
     }
     # Load the language tables
     $lang_tables = $this->langfiles;
     include $root_path . 'include/inc_load_lang_tables.php';
     # Load the other hospitals array
     include_once $root_path . 'global_conf/other_hospitals.php';
     include_once $root_path . 'include/inc_date_format_functions.php';
     include_once $root_path . 'include/care_api_classes/class_insurance.php';
     $pinsure_obj = new PersonInsurance($this->pid);
     # Get the global config for person�s registration form
     include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
     $GLOBAL_CONFIG = array();
     $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
     $glob_obj->getConfig('person_%');
     //extract($GLOBAL_CONFIG);
     if (empty($this->pid)) {
         $validdata = FALSE;
     } else {
         //if($data_obj=&$this->person_obj->getAllInfoObject()){
         //	$this->data=$data_obj->FetchRow();
         if ($this->is_loaded) {
             extract($this->data);
             # Get related insurance data
             $p_insurance = $pinsure_obj->getPersonInsuranceObject($this->pid);
             if ($p_insurance == FALSE) {
                 $insurance_show = true;
             } else {
                 if (!$p_insurance->RecordCount()) {
                     $insurance_show = true;
                 } elseif ($p_insurance->RecordCount() == 1) {
                     $buffer = $p_insurance->FetchRow();
                     extract($buffer);
                     $insurance_show = true;
                     # Get insurace firm name
                     $insurance_firm_name = $pinsure_obj->getFirmName($insurance_firm_id);
                 } else {
                     $insurance_show = FALSE;
                 }
             }
             $insurance_class_info = $pinsure_obj->getInsuranceClassInfo(isset($insurance_class_nr));
             # Check if person is currently admitted
             $this->current_encounter = $this->person_obj->CurrentEncounter($this->pid);
             # update the record�s history
             if (empty($newdata)) {
                 @$this->person_obj->setHistorySeen($_SESSION['sess_user_name']);
             }
             # Check whether config foto path exists, else use default path
             $photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $this->default_photo_path;
         } else {
             $validdata = FALSE;
         }
     }
     if ($validdata) {
         include_once $root_path . 'include/inc_photo_filename_resolve.php';
         ############ Here starts the GUI output ##################
         # Start Smarty templating here
         # Create smarty object without initiliazing the GUI (2nd param = FALSE)
         include_once $root_path . 'gui/smarty_template/smarty_care.class.php';
         $this->smarty = new smarty_care('common', FALSE);
         # Set from width
         $this->smarty->assign('sFormWidth', 'width="100%"');
         $img_male = createComIcon($root_path, 'spm.gif', '0');
         $img_female = createComIcon($root_path, 'spf.gif', '0');
         if (!empty($this->pretext)) {
             $this->smarty->assign('pretext', $this->pretext);
         }
         $this->smarty->assign('LDRegistryNr', $LDRegistryNr);
         $this->smarty->assign('pid', $pid);
         if (file_exists($root_path . 'cache/barcodes/pn_' . $pid . '.png')) {
             $this->smarty->assign('sBarcodeImg', '<img src="' . $root_path . 'cache/barcodes/pn_' . $pid . '.png" border=0 width=180 height=35>');
         } else {
             $this->smarty->assign('sBarcodeImg', "<img src='" . $root_path . "classes/barcode/image.php?code=" . $pid . "&style=68&type=I25&width=180&height=50&xres=2&font=5&label=2&form_file=pn' border=0 width=0 height=0>");
             $this->smarty->assign('sBarcodeImg', "<img src='" . $root_path . "classes/barcode/image.php?code=" . $pid . "&style=68&type=I25&width=180&height=50&xres=2&font=5' border=0 width=180  height=35>");
         }
         $this->smarty->assign('img_source', $img_source);
         # iRowSpanCount counts the rows on the left of the photo image. Begin with 5 because there are 5 static rows.
         $iRowSpanCount = 5;
         $this->smarty->assign('LDRegDate', $LDRegDate);
         $this->smarty->assign('sRegDate', @formatDate2Local($date_reg, $date_format) . '<input name="date_reg" type="hidden" value="' . $date_reg . '"');
         //$iRowSpanCount++;
         $this->smarty->assign('LDRegTime', $LDRegTime);
         $this->smarty->assign('sRegTime', convertTimeToLocal(@formatDate2Local($date_reg, $date_format, 0, 1)));
         $this->smarty->assign('sFileNr', $this->createTR($LDFileNr, $selian_pid, 1, TRUE));
         if (!$GLOBAL_CONFIG['person_title_hide']) {
             $this->smarty->assign('sPersonTitle', $this->createTR($LDTitle, $title));
             $iRowSpanCount++;
         }
         $this->smarty->assign('sNameLast', $this->createTR($LDLastName, $name_last, 1, TRUE));
         //$iRowSpanCount++;
         # If person is dead show a black cross
         if ($death_date && $death_date != $dbf_nodate) {
             $sCross = '&nbsp;<img ' . createComIcon($root_path, 'blackcross_sm.gif', '0', '', TRUE) . '>';
         } else {
             $sCross = '';
         }
         $this->smarty->assign('sNameFirst', $this->createTR($LDFirstName, $name_first . $sCross, 1, TRUE));
         if (!$GLOBAL_CONFIG['person_name_2_hide'] && $name_2) {
             $this->smarty->assign('sName2', $this->createTR($LDName2, $name_2));
             $iRowSpanCount++;
         }
         if (!$GLOBAL_CONFIG['person_name_3_hide'] && $name_3) {
             $this->smarty->assign('sName3', $this->createTR($LDName3, $name_3));
             $iRowSpanCount++;
         }
         if (!$GLOBAL_CONFIG['person_name_middle_hide'] && $name_middle) {
             $this->smarty->assign('sNameMiddle', $this->createTR($LDNameMid, $name_middle));
             $iRowSpanCount++;
         }
         if (!$GLOBAL_CONFIG['person_name_maiden_hide'] && $name_maiden) {
             $this->smarty->assign('sNameMaiden', $this->createTR($LDNameMaiden, $name_maiden));
             $iRowSpanCount++;
         }
         if (!$GLOBAL_CONFIG['person_name_others_hide'] && $name_others) {
             $this->smarty->assign('sNameOthers', $this->createTR($LDNameOthers, $name_others));
             $iRowSpanCount++;
         }
         # Set the rowspan value for the photo image <td>
         $this->smarty->assign('sPicTdRowSpan', "rowspan={$iRowSpanCount}");
         $this->smarty->assign('LDBday', "{$LDBday}:");
         if ($death_date && $death_date != $dbf_nodate) {
             $this->smarty->assign('sCrossImg', $sCross);
             $this->smarty->assign('sDeathDate', '<font color="#000000">' . @formatDate2Local($death_date, $date_format) . '</font>');
         }
         $this->smarty->assign('sBdayInput', '<div class="vi_data">' . @formatDate2Local($date_birth, $date_format) . '</div>');
         $this->smarty->assign('LDSex', "{$LDSex}:");
         if ($sex == "m") {
             $this->smarty->assign('LDMale', '<div class="vi_data">' . $LDMale . '</div>');
         } elseif ($sex == "f") {
             $this->smarty->assign('LDFemale', '<div class="vi_data">' . $LDFemale . '</div>');
         }
         if (!$GLOBAL_CONFIG['person_bloodgroup_hide'] && trim($blood_group)) {
             // KB: make blood group hideable
             $this->smarty->assign('LDBloodGroup', $LDBloodGroup);
             $buf = 'LD' . trim($blood_group);
             $this->smarty->assign('sBGAInput', ${$buf});
         }
         if (!$GLOBAL_CONFIG['person_civilstatus_hide'] && trim($civil_status)) {
             $this->smarty->assign('LDCivilStatus', $LDCivilStatus);
             if ($civil_status == "single") {
                 $sCSBuffer = $LDSingle;
             } elseif ($civil_status == "married") {
                 $sCSBuffer = $LDMarried;
             } elseif ($civil_status == "divorced") {
                 $sCSBuffer = $LDDivorced;
             } elseif ($civil_status == "widowed") {
                 $sCSBuffer = $LDWidowed;
             } elseif ($civil_status == "separated") {
                 $sCSBuffer = $LDSeparated;
             }
             $this->smarty->assign('sCSSingleInput', $sCSBuffer);
         }
         $this->smarty->assign('LDAddress', "{$LDAddress}:");
         $this->smarty->assign('LDStreet', "{$LDStreet}:");
         $this->smarty->assign('sStreetInput', $addr_str);
         $this->smarty->assign('LDStreetNr', "{$LDStreetNr}:");
         $this->smarty->assign('sStreetNrInput', $addr_str_nr);
         $this->smarty->assign('LDTownCity', "{$LDTownCity}:");
         $this->smarty->assign('sTownCityInput', $addr_citytown_name);
         $this->smarty->assign('LDZipCode', "{$LDZipCode} :");
         $this->smarty->assign('sZipCodeInput', $addr_zip);
         $this->smarty->assign('LDTribe', "{$LDTribe} :");
         $this->smarty->assign('sTribe', $tribe_name);
         $this->smarty->assign('LDOccupation', "{$LDOccupation} :");
         $this->smarty->assign('sTitle', $title);
         $this->smarty->assign('LDEducation', "{$LDEducation} :");
         $this->smarty->assign('sEducation', $education);
         if (!$GLOBAL_CONFIG['person_insurance_hide']) {
             if (!isset($GLOBAL_CONFIG['person_insurance_1_nr_hide']) && $insurance_show && isset($insurance_nr)) {
                 $this->smarty->assign('bShowInsurance', TRUE);
                 $this->smarty->assign('sInsuranceNr', $this->createTR($LDInsuranceNr, $insurance_nr, 2));
                 $buffer = $insurance_class_info['LD_var'];
                 if (isset(${$buffer}) && !empty(${$buffer})) {
                     $this->smarty->append('sInsClasses', ${$buffer});
                 } else {
                     $this->smarty->append('sInsClasses', $insurance_class_info['name']);
                 }
                 $this->smarty->assign('LDInsuranceCo', $LDInsuranceCo);
                 $this->smarty->assign('sInsCoNameInput', $insurance_firm_name);
                 $this->createTR($LDInsuranceCo . ' 1', $insurance_firm_name, 2);
             }
         }
         if (!$GLOBAL_CONFIG['person_phone_1_nr_hide'] && $phone_1_nr) {
             //$this->smarty->assign('sPhone1',$this->createTR($LDPhone.' 1',$phone_1_nr,2));
             // by RM:
             $this->smarty->assign('sPhone1', $this->createTR($LDPhone, $phone_1_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_phone_2_nr_hide'] && $phone_2_nr) {
             $this->smarty->assign('sPhone2', $this->createTR($LDPhone . ' 2', $phone_2_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_cellphone_1_nr_hide'] && $cellphone_1_nr) {
             //$this->smarty->assign('sCellPhone1',$this->createTR($LDCellPhone.' 1',$cellphone_1_nr,2));
             // by RM:
             $this->smarty->assign('sCellPhone1', $this->createTR($LDCellPhone, $cellphone_1_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_cellphone_2_nr_hide'] && $cellphone_2_nr) {
             $this->smarty->assign('sCellPhone2', $this->createTR($LDCellPhone . ' 2', $cellphone_2_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_fax_hide'] && $fax) {
             $this->smarty->assign('sFax', $this->createTR($LDFax, $fax, 2));
         }
         if (!$GLOBAL_CONFIG['person_email_hide'] && $email) {
             $this->smarty->assign('sEmail', $this->createTR($LDEmail, "<a href=\"mailto:{$email}\">{$email}</a>", 2));
         }
         if (!$GLOBAL_CONFIG['person_citizenship_hide'] && $citizenship) {
             $this->smarty->assign('sCitzenship', $this->createTR($LDCitizenship, $citizenship, 2));
         }
         if (!$GLOBAL_CONFIG['person_sss_nr_hide'] && $sss_nr) {
             $this->smarty->assign('sSSSNr', $this->createTR($LDSSSNr, $sss_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_nat_id_nr_hide'] && $nat_id_nr) {
             $this->smarty->assign('sNatIdNr', $this->createTR($LDNatIdNr, $nat_id_nr, 2));
         }
         if (!$GLOBAL_CONFIG['person_religion_hide'] && $religion) {
             $this->smarty->assign('sReligion', $this->createTR($LDReligion, $religion, 2));
         }
         if (!$GLOBAL_CONFIG['person_ethnic_orig_hide'] && $ethnic_orig) {
             $this->smarty->assign('LDEthnicOrig', $LDEthnicOrigin);
             $this->smarty->assign('sEthnicOrigInput', $ethnic_orig_txt);
         }
         if (!$GLOBAL_CONFIG['person_other_his_nr_hide']) {
             $other_hosp_list = $this->person_obj->OtherHospNrList();
             $iHospCount = sizeof($other_hosp_list);
             if ($iHospCount) {
                 $this->smarty->assign('bShowOtherHospNr', TRUE);
                 $this->smarty->assign('LDOtherHospitalNr', $LDOtherHospitalNr);
                 $sOtherNrBuffer = '';
                 if (is_array($other_hosp_list) && $iHospCount) {
                     foreach ($other_hosp_list as $k => $v) {
                         $sOtherNrBuffer .= "<b>" . $kb_other_his_array[$k] . ":</b> " . $v . "<br />\n";
                     }
                 }
                 $this->smarty->assign('sOtherNr', $sOtherNrBuffer);
             }
         }
         $this->smarty->assign('LDRegBy', $LDRegBy);
         if (empty($modify_id)) {
             $buffer = $create_id;
         } else {
             $buffer = $modify_id;
         }
         $this->smarty->assign('sRegByInput', $buffer);
     } else {
         $this->smarty->assign('pretext', 'Invalid PID number or the data is not available from the databank! Please report this to <a  href="mailto:info@care2x.org">info@care2x.org</a>. Thank you.');
     }
     # If data is to be returned only, buffer output, get the buffer contents, end and clean buffer and return contents.
     if ($this->bReturnOnly) {
         ob_start();
         $this->smarty->display('registration_admission/reg_form.tpl');
         $sTemp = ob_get_contents();
         ob_end_clean();
         return $sTemp;
     } else {
         $this->smarty->display('registration_admission/reg_form.tpl');
         return TRUE;
     }
 }
    /**
     * Displays the GUI input form
     */
    function display()
    {
        global $db, $sid, $lang, $root_path, $pid, $insurance_show, $user_id, $mode, $dbtype, $no_tribe, $no_region, $update, $photo_filename;
        #, $_FILES $_POST, $_SESSION;
        extract($_POST);
        require_once $root_path . 'include/care_api_classes/class_advanced_search.php';
        # Load the language tables
        $lang_tables = $this->langfiles;
        include $root_path . 'include/inc_load_lang_tables.php';
        include_once $root_path . 'include/inc_date_format_functions.php';
        include_once $root_path . 'include/care_api_classes/class_insurance.php';
        include_once $root_path . 'include/care_api_classes/class_person.php';
        $db->debug = FALSE;
        # Create the new person object
        $person_obj =& new Person($pid);
        # Create a new person insurance object
        $pinsure_obj =& new PersonInsurance($pid);
        if (!isset($insurance_show)) {
            $insurance_show = TRUE;
        }
        $newdata = 1;
        $error = 0;
        $dbtable = 'care_person';
        if (!isset($photo_filename) || empty($photo_filename)) {
            $photo_filename = 'nopic';
        }
        # Assume first that image is not uploaded
        $valid_image = FALSE;
        //* Get the global config for person's registration form*/
        include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
        $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
        $glob_obj->getConfig('person_%');
        extract($GLOBAL_CONFIG);
        # Check whether config foto path exists, else use default path
        $photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $this->default_photo_path;
        if ($mode == 'save' || $mode == 'forcesave') {
            $search_obj =& new advanced_search();
            if (is_array($result_array = $search_obj->get_equal_words("tribe_name", "care_tz_tribes", false, 65, 'tribe_id')) && $name_maiden && !$no_tribe) {
                $tribe_array = $result_array;
            } else {
                $tribe_array = $result_array;
            }
            if (is_array($result_array = $search_obj->get_equal_words("name", "care_tz_religion", false, 65, 'nr')) && $religion && !$person_religion_hide) {
                $religion_array = $result_array;
            } else {
                $religion_array = $result_array;
            }
            /*
            		if (is_array($result_array=$search_obj->get_equal_words("region_name", "care_tz_region", false, 65, 'region_id')) && $email && !$person_email_hide )
            		{
            			$region_array=$result_array;
            		}
            		else
            		{
            			 $region_array=$result_array;
            		}
            		if (is_array($result_array=$search_obj->get_equal_words1("district_name", "care_tz_district", false, 65, 'district_id',$email)) && $sss_nr )
            		{
            			$district_array=$result_array;
            		}
            		else
            		{
            			 $district_array=$result_array;
            		}
            		if (is_array($result_array=$search_obj->get_equal_words1("ward_name", "care_tz_ward", false, 65, 'ward_id',$sss_nr)) && $nat_id_nr )
            		{
            			$ward_array=$result_array;
            		}
            		else
            		{
            			 $ward_array=$result_array;
            		}
            */
            # If saving is not forced, validate important elements
            if ($mode != 'forcesave') {
                # clean and check input data variables
                if (trim($encoder) == '') {
                    $encoder = $aufnahme_user;
                }
                if (trim($name_last) == '') {
                    $errornamelast = 1;
                    $error++;
                }
                //if (trim($selian_pid)=='' || !is_numeric($selian_pid) || (!$update && $person_obj->SelianFileExists($selian_pid))) { $errorfilenr=1; $error++;}
                if ($person_obj->IsHospitalFileNrMandatory()) {
                    if (trim($selian_pid) == '' || !$update && $person_obj->SelianFileExists($selian_pid)) {
                        $errorfilenr = 1;
                        $error++;
                    }
                }
                if (trim($name_first) == '') {
                    $errornamefirst = 1;
                    $error++;
                }
                if (trim($date_birth) == '') {
                    $errordatebirth = 1;
                    $error++;
                }
                if (mktime(0, 0, 0, substr($date_birth, 3, 2), substr($date_birth, 0, 2), substr($date_birth, 6, 4)) > time()) {
                    $errordatebirth = 1;
                    $error++;
                }
                //if (is_array($tribe_array) && !$no_tribe) {$errormaiden=1; $error++;}
                //if (is_array($town_array)) {$errortown=1; $error++;}
                //if (!$citizenship) { $errortown=1; $error++;}
                if ($sex == '') {
                    $errorsex = 1;
                    $error++;
                }
            }
            # If the validation produced no error, save the data
            if (!$error) {
                # Save the old filename for testing
                $old_fn = $photo_filename;
                # Create image object
                include_once $root_path . 'include/care_api_classes/class_image.php';
                $img_obj =& new Image();
                # Check the uploaded image file if exists and valid
                if ($img_obj->isValidUploadedImage($_FILES['photo_filename'])) {
                    $valid_image = TRUE;
                    # Get the file extension
                    $picext = $img_obj->UploadedImageMimeType();
                }
                //addr_citytown_nr='$addr_citytown_nr',
                if ($update) {
                    //echo formatDate2STD($geburtsdatum,$date_format);
                    $sql = "UPDATE {$dbtable} SET\n\t\t\t\t\t\t\t title='{$title}',\n\t\t\t\t\t\t\t selian_pid='{$selian_pid}',\n\t\t\t\t\t\t\t name_last='{$name_last}',\n\t\t\t\t\t\t\t name_first='{$name_first}',\n\t\t\t\t\t\t\t name_2='{$name_2}',\n\t\t\t\t\t\t\t name_3='{$name_3}',\n\t\t\t\t\t\t\t name_middle='{$name_middle}',\n\t\t\t\t\t\t\t name_maiden='{$name_maiden}',\n\t\t\t\t\t\t\t name_others='{$name_others}',\n\t\t\t\t\t\t\t date_birth='" . formatDate2STD($date_birth, $date_format) . "',\n\t\t\t\t\t\t\t blood_group='" . trim($blood_group) . "',\n\t\t\t\t\t\t\t rh='" . trim($rh) . "',\n\t\t\t\t\t\t\t sex='{$sex}',\n\t\t\t\t\t\t\t addr_str='{$addr_str}',\n\t\t\t\t\t\t\t addr_str_nr='{$addr_str_nr}',\n\t\t\t\t\t\t\t addr_zip='{$addr_zip}',\n\t\t\t\t\t\t\t addr_citytown_nr='{$addr_citytown_nr}',\n\t\t\t\t\t\t\t addr_citytown_name='{$addr_citytown_name}',\n\t\t\t\t\t\t\t phone_1_nr='{$phone_1_nr}',\n\t\t\t\t\t\t\t phone_2_nr='{$phone_2_nr}',\n\t\t\t\t\t\t\t cellphone_1_nr='{$cellphone_1_nr}',\n\t\t\t\t\t\t\t cellphone_2_nr='{$cellphone_2_nr}',\n\t\t\t\t\t\t\t fax='{$fax}',\n\t\t\t\t\t\t\t email='',\n\t\t\t\t\t\t\t citizenship ='{$citizenship}',\n\t\t\t\t\t\t\t civil_status='{$civil_status}',\n\t\t\t\t\t\t\t sss_nr='',\n\t\t\t\t\t\t\t nat_id_nr='',\n\t\t\t\t\t\t\t religion='{$religion}', insurance_ID='{$insurance_ID}',\n\t\t\t\t\t\t\t ethnic_orig='{$ethnic_orig}',\n\t\t\t\t\t\t\t date_update='" . date('Y-m-d H:i:s') . "',";
                    if ($region != "-1" && $district != "-1" && $ward != "-1") {
                        $sql .= "region='{$region}',\n\t\t\t\t\t\t\t   district='{$district}',\n\t\t\t\t\t\t\t   ward='{$ward}',";
                    }
                    //if ($old_fn!=$photo_filename){
                    if ($valid_image) {
                        # Compose the new filename
                        $photo_filename = $pid . '.' . $picext;
                        # Save the file
                        $img_obj->saveUploadedImage($_FILES['photo_filename'], $root_path . $photo_path . '/', $photo_filename);
                        # add to the sql query
                        $sql .= " photo_filename='{$photo_filename}',";
                    }
                    # complete the sql query
                    $sql .= " history=" . $person_obj->ConcatHistory("Update " . date('Y-m-d H:i:s') . " " . $_SESSION['sess_user_name'] . " \n") . ", modify_id='" . $_SESSION['sess_user_name'] . "' WHERE pid={$pid}";
                    //$db->debug=true;
                    $db->BeginTrans();
                    $ok = $db->Execute($sql);
                    if ($ok) {
                        $db->CommitTrans();
                        # Update the insurance data
                        # Lets detect if the data is already existing
                        if ($insurance_show) {
                            if ($insurance_item_nr) {
                                if (!empty($insurance_nr) && !empty($insurance_firm_name) && $insurance_firm_id) {
                                    $insure_data = array('insurance_nr' => $insurance_nr, 'firm_id' => $insurance_firm_id, 'class_nr' => $insurance_class_nr, 'history' => "Update " . date('Y-m-d H:i:s') . " " . $_SESSION['sess_user_name'] . " \n", 'modify_id' => $_SESSION['sess_user_name'], 'modify_time' => date('YmdHis'));
                                    $pinsure_obj->updateDataFromArray($insure_data, $insurance_item_nr);
                                }
                            } elseif ($insurance_nr && $insurance_firm_name && $insurance_class_nr) {
                                $insure_data = array('insurance_nr' => $insurance_nr, 'firm_id' => $insurance_firm_id, 'pid' => $pid, 'class_nr' => $insurance_class_nr, 'history' => "Update " . date('Y-m-d H:i:s') . " " . $_SESSION['sess_user_name'] . " \n", 'create_id' => $_SESSION['sess_user_name'], 'create_time' => date('YmdHis'));
                                $pinsure_obj->insertDataFromArray($insure_data);
                            }
                        }
                        $newdata = 1;
                        if (file_exists($this->displayfile)) {
                            header("location: {$this->displayfile}" . URL_REDIRECT_APPEND . "&pid={$pid}&from={$from}&newdata=1&target=entry");
                            exit;
                        } else {
                            echo "Error! Target display file not defined!!";
                        }
                    } else {
                        $db->RollbackTrans();
                    }
                } else {
                    $from = 'entry';
                    $_POST['date_birth'] = @formatDate2Std($date_birth, $date_format);
                    $_POST['date_reg'] = date('Y-m-d H:i:s');
                    $_POST['blood_group'] = trim($_POST['blood_group']);
                    $_POST['status'] = 'normal';
                    $_POST['history'] = "Init.reg. " . date('Y-m-d H:i:s') . " " . $_SESSION['sess_user_name'] . "\n";
                    //$_POST['modify_id']=$_SESSION['sess_user_name'];
                    $_POST['create_id'] = $_SESSION['sess_user_name'];
                    $_POST['create_time'] = date('YmdHis');
                    # Prepare internal data to be stored together with the user input data
                    if (!$person_obj->InitPIDExists($GLOBAL_CONFIG['person_id_nr_init'])) {
                        # If db is mysql, insert the initial pid value  from global config
                        # else let the dbms make an initial value via the sequence generator e.g. postgres
                        # However, the sequence generator must be configured during db creation to start at
                        # the initial value set in the global config
                        if ($dbtype == 'mysql') {
                            $_POST['pid'] = $GLOBAL_CONFIG['person_id_nr_init'];
                        }
                    } else {
                        # Persons are existing. Check if duplicate might exist
                        if (is_object($duperson = $person_obj->PIDbyData($_POST))) {
                            $error_person_exists = TRUE;
                        }
                    }
                    //echo $person_obj->getLastQuery();
                    if (!$error_person_exists || $mode == 'forcesave') {
                        if ($person_obj->insertDataFromInternalArray()) {
                            # If data was newly inserted, get the insert id if mysq, else get the pid number)
                            if (!$update) {
                                $oid = $db->Insert_ID();
                                $pid = $person_obj->LastInsertPK('pid', $oid);
                                /*
                                								if($dbtype=='mysql'){
                                									$pid=$db->Insert_ID();
                                								}else{
                                									$pid=$person_obj->postgre_Insert_ID($dbtable,'pid',$db->Insert_ID());
                                								}*/
                            }
                            //if(!$update) $pid=$db->Insert_ID();
                            # Save the valid uploaded photo
                            if ($valid_image) {
                                # Compose the new filename by joining the pid number and the file extension with "."
                                $photo_filename = $pid . '.' . $picext;
                                # Save the file
                                if ($img_obj->saveUploadedImage($_FILES['photo_filename'], $root_path . $photo_path . '/', $photo_filename)) {
                                    # Update the filename to the databank
                                    $person_obj->setPhotoFilename($pid, $photo_filename);
                                }
                            }
                            //echo $pid;
                            //echo $citizenship;
                            # Update the insurance data
                            # Lets detect if the data is already existing
                            if ($insurance_show) {
                                if ($insurance_item_nr) {
                                    if (!empty($insurance_nr) && !empty($insurance_firm_name) && $insurance_firm_id) {
                                        $insure_data = array('insurance_nr' => $insurance_nr, 'firm_id' => $insurance_firm_id, 'class_nr' => $insurance_class_nr);
                                        $pinsure_obj->updateDataFromArray($insure_data, $insurance_item_nr);
                                    }
                                } elseif ($insurance_nr && $insurance_firm_name && $insurance_class_nr) {
                                    $insure_data = array('insurance_nr' => $insurance_nr, 'firm_id' => $insurance_firm_id, 'pid' => $pid, 'class_nr' => $insurance_class_nr);
                                    $pinsure_obj->insertDataFromArray($insure_data);
                                }
                            }
                            $newdata = 1;
                            if (file_exists($this->displayfile)) {
                                header("location: {$this->displayfile}" . URL_REDIRECT_APPEND . "&pid={$pid}&from={$from}&newdata=1&target=entry");
                                exit;
                            } else {
                                echo "Error! Target display file not defined!!";
                            }
                        } else {
                            echo "<p>{$db->ErrorMsg}()<p>{$LDDbNoSave}";
                        }
                    }
                }
            }
            // end of if(!$error)
        } elseif (!empty($this->pid)) {
            # Get the person�s data
            if ($data_obj =& $person_obj->getAllInfoObject()) {
                $zeile = $data_obj->FetchRow();
                extract($zeile);
                //print_r($zeile);
                # Get the related insurance data
                $p_insurance =& $pinsure_obj->getPersonInsuranceObject($pid);
                if ($p_insurance == FALSE) {
                    $insurance_show = TRUE;
                } else {
                    if (!$p_insurance->RecordCount()) {
                        $insurance_show = TRUE;
                    } elseif ($p_insurance->RecordCount() == 1) {
                        $buffer = $p_insurance->FetchRow();
                        extract($buffer);
                        $insurance_show = TRUE;
                        $insurance_firm_name = $pinsure_obj->getFirmName($insurance_firm_id);
                    } else {
                        $insurance_show = FALSE;
                    }
                }
            }
        } else {
            $date_reg = date('Y-m-d H:i:s');
        }
        # Get the insurance classes
        $insurance_classes =& $pinsure_obj->getInsuranceClassInfoObject('class_nr,name,LD_var AS "LD_var"');
        include_once $root_path . 'include/inc_photo_filename_resolve.php';
        $search_obj =& new advanced_search();
        if (!$update) {
            $tribe = $name_maiden;
            $town = $citizenship;
        }
        if (is_array($result_array = $search_obj->get_equal_words("tribe_name", "care_tz_tribes", false, 65, 'tribe_id')) && $name_maiden && !$no_tribe) {
            $tribe_array = $result_array;
        } else {
            $tribe_array = $result_array;
        }
        /*
        		if (is_array($result_array=$search_obj->get_equal_words("village_name", "care_tz_village", false, 65, 'village_id',$ward)) && $addr_citytown_nr)
        		{
        			$town_array=$result_array;
        		}
        		else
        		{
        			 $town_array=$result_array;
        		}*/
        if (is_array($result_array = $search_obj->get_equal_words("name", "care_tz_religion", false, 65, 'nr')) && $religion) {
            $religion_array = $result_array;
        } else {
            $religion_array = $result_array;
        }
        /*
        		if (is_array($result_array=$search_obj->get_equal_words("region_name", "care_tz_region", false, 65, 'region_id')) && $email && !$person_email_hide )
        		{
        			$region_array=$result_array;
        		}
        		else
        		{
        			 $region_array=$result_array;
        		}
        		if (is_array($result_array=$search_obj->get_equal_words1("district_name", "care_tz_district", false, 65, 'district_id',$email)) && $sss_nr )
        		{
        			$district_array=$result_array;
        		}
        		else
        		{
        			 $district_array=$result_array;
        		}
        		if (is_array($result_array=$search_obj->get_equal_words1("ward_name", "care_tz_ward", false, 65, 'ward_id',$sss_nr)) && $nat_id_nr )
        		{
        			$ward_array=$result_array;
        		}
        
        		else
        		{
        			 $ward_array=$result_array;
        		}
        */
        ########  Here starts the GUI output #######################################################
        $img_male = createComIcon($root_path, 'spm.gif', '0');
        $img_female = createComIcon($root_path, 'spf.gif', '0');
        $tbg = 'background="' . $root_path . 'gui/img/common/' . $theme_com_icon . '/tableHeader_gr.gif"';
        if (!empty($this->pretext)) {
            echo $this->pretext;
        }
        ?>
		<script  language="javascript">
		<!--
			function test(){
			document.aufnahmeform.action="<?php 
        $_SERVER['PHP_SELF'];
        ?>
";
			document.aufnahmeform.submit();
		}

			function forceSave(){
			document.aufnahmeform.mode.value="forcesave";
			document.aufnahmeform.submit();
		}

		function showpic(d){
			if(d.value) document.images.headpic.src=d.value;
		}

		function popSearchWin(target,obj_val,obj_name){
			urlholder="./data_search.php<?php 
        echo URL_REDIRECT_APPEND;
        ?>
&target="+target+"&obj_val="+obj_val+"&obj_name="+obj_name;
			DSWIN<?php 
        echo $sid;
        ?>
=window.open(urlholder,"wblabel<?php 
        echo $sid;
        ?>
","menubar=no,width=400,height=550,resizable=yes,scrollbars=yes");
		}
		function list_popup(d,chosentype)
		{
			if(d.value=="notinlist")
			{
				urlholder="<?php 
        echo $root_path;
        ?>
modules/registration_admission/notinlist.php<?php 
        echo URL_APPEND . '&chosentype=" + chosentype + "';
        ?>
";
				notinlist=window.open(urlholder,"notinlist","width=500,height=450,menubar=no,resizable=yes,scrollbars=yes");
			}
		}
		function chkform(d) {
			<?php 
        if ($person_obj->IsHospitalFileNrMandatory()) {
            echo 'if(d.selian_pid.value==""){
			      			alert("Please enter Hospital File Number");
			      		 d.selian_pid.focus();
			      			return false;
			      			}else';
        }
        ?>

			if(d.name_last.value==""){
				alert("<?php 
        echo $LDPlsEnterLastName;
        ?>
");
				d.name_last.focus();
				return false;
			}else if(d.name_first.value==""){
				alert("<?php 
        echo $LDPlsEnterFirstName;
        ?>
");
				d.name_first.focus();
				return false;
			}else if(d.name_2.value==""){
				alert("<?php 
        echo 'Please Enter Father Name';
        ?>
");
				d.name_2.focus();
				return false;
			}else if(d.date_birth.value==""){
				alert("<?php 
        echo $LDPlsEnterDateBirth;
        ?>
");
				d.date_birth.focus();
				return false;
			}else if(d.sex[0]&&d.sex[1]&&!d.sex[0].checked&&!d.sex[1].checked){
				alert("<?php 
        echo $LDPlsSelectSex;
        ?>
");
				return false;

			<?php 
        if ($update) {
            $sql = "SELECT * FROM care_person where pid=" . $pid;
            $ergebnis = $db->Execute($sql);
            while ($person = $ergebnis->FetchRow()) {
                $region = $person['region'];
            }
        }
        if (!$update or $region == '') {
            echo '}else if(d.region.value=="-1"){';
            echo 'alert("Please select region");';
            echo 'd.region.focus();';
            echo 'return false;';
            echo '}else if(d.district.value=="-1"){';
            echo 'alert("Please select district");';
            echo 'd.district.focus();';
            echo 'return false;';
            echo '}else if(d.ward.value=="-1"){';
            echo ' alert("Please select Ward");';
            echo ' d.ward.focus();';
            echo ' return false;';
        } else {
            echo '}else if(d.region.value!="-1"){';
            echo 'if(d.district.value=="-1")';
            echo '{';
            echo 'alert("Please select district");';
            echo 'd.district.focus();';
            echo 'return false;';
            echo '}';
            echo 'if(d.ward.value=="-1")';
            echo '{';
            echo ' alert("Please select ward");';
            echo ' d.ward.focus();';
            echo ' return false;';
            echo '}';
        }
        ?>
			}else if(d.user_id.value==""){
				alert("<?php 
        echo $LDPlsEnterFullName;
        ?>
");
				d.user_id.focus();
				return false;
			}else if(d.name_maiden.value=="-1"){
				alert ("Select tribe!");
				return false;
			}else if(d.religion.value=="-1"){
				alert ("Select religion!");
				return false;
			}else{
				return true;
			}
		}


<?php 
        require $root_path . 'include/inc_checkdate_lang.php';
        ?>
		-->
		</script>

		<script language="javascript" src="<?php 
        echo $root_path;
        ?>
js/setdatetime.js"></script>
		<script language="javascript" src="<?php 
        echo $root_path;
        ?>
js/checkdate.js"></script>
		<script language="javascript" src="<?php 
        echo $root_path;
        ?>
js/dtpick_care2x.js"></script>

		<FONT    SIZE=-1  FACE="Arial">

		<form method="post" action="<?php 
        echo $thisfile;
        ?>
" name="aufnahmeform" ENCTYPE="multipart/form-data" onSubmit="return chkform(this)">

		<table border=0 cellspacing=0 cellpadding=0>
<?php 
        if ($error) {
            echo "<script language=\"Javascript\" type=\"text/javascript\"> </script>";
            //alert('Information is missing in the input field marked red!') ;
            ?>
			<tr bgcolor=#ffffee>
			<td colspan=3>
			<center>
				<font face=arial color=#7700ff size=4>
				<img <?php 
            echo createMascot($root_path, 'mascot1_r.gif', '0', 'bottom');
            ?>
 align="absmiddle">
<?php 
            if ($error > 1) {
                echo "<script language=\"Javascript\" type=\"text/javascript\"> </script>";
                //alert('$LDErrorS')
                echo $LDErrorS;
            } else {
                /* echo "<script language=\"Javascript\" type=\"text/javascript\"> alert('Information is missing in the input field marked red!') </script>"; */
                echo $LDError;
            }
            ?>
			</center>
			</td>
			</tr>
<?php 
        } elseif ($error_person_exists) {
            ?>
			<tr bgcolor=#ffffee>
			<td colspan=3>
			<center>
				<table border=0>
				<tr>
				<td><img <?php 
            echo createMascot($root_path, 'mascot1_r.gif', '0', 'bottom');
            ?>
 align="absmiddle"></td>
				<td><font face=arial color=#7700ff size=4>
<?php 
            echo $LDPersonDuplicate;
            if ($duperson->RecordCount() > 1) {
                echo " {$LDSimilarData2} {$LDPlsCheckFirst2}";
            } else {
                echo "{$LDSimilarData} {$LDPlsCheckFirst}";
            }
            echo "<script language=\"Javascript\" type=\"text/javascript\"> </script>";
            // alert('$LDSimilarData $LDPlsCheckFirst')
            echo '
				</td>
				</tr>
				</table>
			</center>
			</td>
			</tr>

			<tr>
			<td colspan=3>

				<table border=0 cellspacing=0 cellpadding=1 bgcolor="#000000" width=100%>
				<tr>
				<td>
					<table border=0 cellspacing=0 width=100% bgcolor="#ffffff">';
            echo '
		 			<tr bgcolor="#66ee66" background="' . $root_path . 'gui/img/common/default/tableHeaderbg.gif">';
            echo "\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDRegistryNr}</b></td>\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDLastName}</b></td>\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDFirstName}</b></td>\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDBday}</b></td>\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDSex}</b></td>\n\t\t\t\t\t<td {$tbg}><FONT  SIZE=-1  FACE=\"Arial\" color=\"#000066\"><b>\n\t\t\t\t\t\t{$LDOptions}</b></td>\n\t\t\t\t\t</tr>";
            # Show the probable same person
            while ($dup = $duperson->FetchRow()) {
                echo '
					<tr>
					<td><font face=arial color=#000000 size=2>' . $dup['pid'] . '</td>
					<td><font face=arial color=#000000 size=2>' . $dup['name_last'] . '</td>
					<td><font face=arial color=#000000 size=2>' . $dup['name_first'] . '</td>
					<td><font face=arial color=#000000 size=2>' . formatDate2Local($dup['date_birth'], $date_format) . '</td>
					<td>';
                switch ($dup['sex']) {
                    case 'f':
                        echo '<img ' . $img_female . '>';
                        break;
                    case 'm':
                        echo '<img ' . $img_male . '>';
                        break;
                    default:
                        echo '&nbsp;';
                        break;
                }
                echo '
					</td>
					<td><font face=arial color=#000000 size=2>:: <a href="person_reg_showdetail.php' . URL_APPEND . '&pid=' . $dup['pid'] . '&from=$from&newdata=1&target=entry" target="_blank">' . $LDShowDetails . '</a> ::
					<a href="patient_register.php' . URL_APPEND . '&pid=' . $dup['pid'] . '&update=1">' . $LDUpdate . '</a>
					</td>
   					</tr>';
            }
            echo '
					</table>
				</td>
				</tr>
				</table>';
        }
        ?>
			</td>
			</tr>

			<tr>
			<td>
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($pid) {
            echo $LDRegistryNr;
        }
        ?>
			</td>
			<td >
				<FONT SIZE=-1  FACE="Arial" color="#800000">
				<?php 
        if ($pid) {
            if (IS_TANZANIAN) {
                echo $this->showPID($pid);
            } else {
                echo $pid;
            }
        }
        ?>
&nbsp;
			</td>
			<td  rowspan=6 class="photo_id" >
				<FONT SIZE=-1  FACE="Arial">
				<a href="#"  onClick="showpic(document.aufnahmeform.photo_filename)"><img <?php 
        echo $img_source;
        ?>
 id="headpic" name="headpic"></a>
				<br>
				<?php 
        echo $LDPhoto;
        ?>
				<br><input name="photo_filename" type="file" size="15"   onChange="showpic(this)" value="<?php 
        if (isset($photo_filename)) {
            echo $photo_filename;
        }
        ?>
">

			</td>
			</tr>

			<tr>
			<td class="reg_item">
				<?php 
        echo $LDRegDate;
        ?>
:
			</td>
			<td class="reg_input">
				<FONT SIZE=-1  FACE="Arial" color="#800000">
				<?php 
        echo formatDate2Local($date_reg, $date_format);
        ?>
				<input name="date_reg" type="hidden" value="<?php 
        echo $date_reg;
        ?>
">
			</td>
			</tr>

			<tr>
			<td class="reg_item">
				<?php 
        echo $LDRegTime;
        ?>
:
			</td>
			<td class="reg_input">
				<FONT SIZE=-1  FACE="Arial" color="#800000"><?php 
        echo convertTimeToLocal(formatDate2Local($date_reg, $date_format, 0, 1));
        ?>
			</td>
			</tr>
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($person_obj->IsHospitalFileNrMandatory()) {
            $asterik = '*';
        } else {
            $asterik = ' ';
        }
        if ($errorfilenr) {
            echo '<font color="#ff0000">*' . $LDFileNr . '</font><br>
					Try this one: ' . $person_obj->GetNewSelianFileNumber();
        } else {
            echo $asterik . $LDFileNr;
        }
        ?>
			</td>
			<td class="reg_input">
				<input type="text" name="selian_pid" size=14 maxlength=6 value="<?php 
        echo $selian_pid;
        ?>
" onFocus="this.select();">
			</td>
			</tr>

<?php 
        $this->createTR($errornamefirst, 'name_first', ' *' . $LDFirstName, $name_first, '', '', FALSE);
        $this->createTR($errorname2, 'name_2', ' *' . $LDName2, $name_2, '', '', FALSE);
        $this->createTR($errornamelast, 'name_last', ' *' . $LDLastName, $name_last, '', '', FALSE);
        $this->createTR($errornamemid, 'name_middle', $LDNameMid, $name_middle, '', '', FALSE);
        // This is for balozi
        if (!$no_tribe) {
            ?>

			<tr>
				<td class="reg_item"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
				<?php 
            if ($errormaiden) {
                echo '<font color="FF0000">';
            }
            echo '* ' . $LDNameMaiden;
            ?>
</td>
				<td  class="reg_input" colspan=1>

				<?php 
            echo '<SELECT name="name_maiden" onChange="list_popup(this, \'tribe\');">';
            echo '<OPTION value="-1" >' . $LDPleaseSelectTribe . '</OPTION>';
            foreach ($tribe_array as $unit) {
                //if($update && (strtoupper($name_maiden) == strtoupper($unit[1])))
                if (strtoupper($name_maiden) == strtoupper($unit[1])) {
                    $check = 'selected';
                } else {
                    $check = '';
                }
                echo '<OPTION value="' . $unit[1] . '" ' . $check . '>' . $unit[0] . '</OPTION>';
            }
            // echo '<OPTION value="notinlist">NOT IN LIST</OPTION>';
            echo '</SELECT>';
            ?>

				</td>
			</tr>

<?php 
        }
        ?>

			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($errordatebirth) {
            echo "<font color=red>";
        }
        ?>
* <?php 
        echo $LDBday;
        ?>
</font>:
			</td>
			<td class="reg_input">
				<FONT SIZE=-1  FACE="Arial">
				<input name="date_birth" type="text" size="15" maxlength=10 value="<?php 
        if ($date_birth) {
            if ($mode == 'save' || $error || $error_person_exists) {
                echo $date_birth;
            } else {
                echo formatDate2Local($date_birth, $date_format);
            }
        }
        # Uncomment the following when the current date must be inserted
        # automatically at the start of each document
        /*else{
        			echo formatDate2Local(date('Y-m-d'),$date_format);
        		}*/
        ?>
"
 				onFocus="this.select();"
				onBlur="IsValidDate(this,'<?php 
        echo $date_format;
        ?>
')"
				onKeyUp="setDate(this,'<?php 
        echo $date_format;
        ?>
','<?php 
        echo $lang;
        ?>
');">
				<a href="javascript:show_calendar('aufnahmeform.date_birth','<?php 
        echo $date_format;
        ?>
')">
				<img <?php 
        echo createComIcon($root_path, 'show-calendar.gif', '0', 'absmiddle');
        ?>
></a>


				<font size=1>[
<?php 
        $dfbuffer = "LD_" . strtr($date_format, ".-/", "phs");
        echo ${$dfbuffer};
        ?>
				 ] </font><br>
<input name="date_age" type="text" size="15" maxlength=10 value="" onKeyUp="setDatebyAge(this,this.form.date_birth,'<?php 
        echo $date_format;
        ?>
','<?php 
        echo $lang;
        ?>
')">
				<font size=1>
<?php 
        echo $LDAge;
        ?>
</font>
			</td>
			<td>&nbsp;</td>
			<tr>
			<td class="reg_item">
			<FONT SIZE=-1  FACE="Arial">
<?php 
        if ($errorsex) {
            echo "<font color=#ff0000>";
        }
        echo '* ' . $LDSex . '</font>';
        ?>
:<td>
			<input name="sex" type="radio" value="m"  <?php 
        if ($sex == "m") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDMale;
        ?>
&nbsp;&nbsp;
			<input name="sex" type="radio" value="f"  <?php 
        if ($sex == "f") {
            echo "checked";
        }
        ?>
>

<?php 
        echo $LDFemale;
        if ($errorsex) {
            echo "</font>";
        }
        # But patch 2004-03-10
        # Clean blood group
        $blood_group = trim($blood_group);
        ?>
			</td>
			</tr>
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($errorreligion) {
            echo "<font color=red>";
        }
        ?>
* <?php 
        echo $LDReligion;
        ?>
:
			</td>
			<td class="reg_input">
<?php 
        echo '<SELECT name="religion" onChange="list_popup(this,\'religion\');">';
        echo '<OPTION value="-1" >' . $LDSelectReligion . '</OPTION>';
        foreach ($religion_array as $unit) {
            if (strtoupper($religion) == strtoupper($unit[1])) {
                $check = 'selected';
            } else {
                $check = '';
            }
            echo '<OPTION value="' . $unit[1] . '" ' . $check . '>' . $unit[0] . '</OPTION>';
        }
        // echo '<OPTION value="notinlist">NOT IN LIST</OPTION>';
        echo '</SELECT>';
        ?>

			</td>
			</tr>
		<?php 
        if (!$person_name_others_hide) {
            $this->createTR($errornameothers, 'name_others', $LDNameOthers, $name_others);
        }
        ?>

<!--
TODO: Kompletly not shown, or dependig on who is editing: Doctor, Lab?
-->
 			<tr>
			<td class="reg_item">
				<?php 
        echo $LDBloodGroup;
        ?>
:
			</td>
			<td class="reg_input">
				<FONT SIZE=-1  FACE="Arial">
				<input name="blood_group" type="radio" value="A"  <?php 
        if ($blood_group == 'A') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDA;
        ?>
&nbsp;&nbsp;
				<input name="blood_group" type="radio" value="B"  <?php 
        if ($blood_group == 'B') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDB;
        ?>
&nbsp;&nbsp;
				<input name="blood_group" type="radio" value="AB"  <?php 
        if ($blood_group == 'AB') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDAB;
        ?>
&nbsp;&nbsp;
				<input name="blood_group" type="radio" value="O"  <?php 
        if ($blood_group == 'O') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDO;
        ?>
			</td>
			<td>
							<?php 
        echo $LDRHfactor;
        ?>
<input name="rh" type="radio" value="pos"
			<?php 
        if ($rh == 'pos') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDRHpos;
        ?>
				<input name="rh" type="radio" value="neg"
			<?php 
        if ($rh == 'neg') {
            echo 'checked';
        }
        ?>
><?php 
        echo $LDRHneg;
        ?>
			</td>
			</tr>
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($errorcivil) {
            echo "<font color=red>";
        }
        ?>
 <?php 
        echo $LDCivilStatus;
        ?>
</font>:
			</td>
			<td colspan=2 class="reg_input">
				<FONT SIZE=-1  FACE="Arial"> <input name="civil_status" type="radio" value="single"  <?php 
        if ($civil_status == "single") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDSingle;
        ?>
&nbsp;&nbsp;
				<input name="civil_status" type="radio" value="married"  <?php 
        if ($civil_status == "married") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDMarried;
        ?>
				<FONT SIZE=-1  FACE="Arial"> <input name="civil_status" type="radio" value="divorced"  <?php 
        if ($civil_status == "divorced") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDDivorced;
        ?>
&nbsp;&nbsp;
				<input name="civil_status" type="radio" value="widowed"  <?php 
        if ($civil_status == "widowed") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDWidowed;
        ?>
				<FONT SIZE=-1  FACE="Arial"> <input name="civil_status" type="radio" value="separated"  <?php 
        if ($civil_status == "separated") {
            echo "checked";
        }
        ?>
><?php 
        echo $LDSeparated;
        ?>
&nbsp;&nbsp;
			</td>
			</tr>
			<tr>
				<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"> <?php 
        echo $LDInsurance;
        ?>
:
			</td>
				<td class="reg_input"> <?php 
        // Create array of all insurances for GUI
        $coreObj->sql = "SELECT DISTINCT parent FROM care_tz_insurance WHERE cancel_flag='0' order by name asc";
        $result = $db->Execute($coreObj->sql);
        $name_insurer_array = array();
        while ($row = $result->FetchRow()) {
            $nr = $row['insurance_ID'];
            if ($nr != -1) {
                $coreObj->sql = "SELECT name FROM care_tz_company WHERE insurance_ID={$nr}";
                $ergebnis = $db->Execute($coreObj->sql);
                $row = $ergebnis->FetchRow();
                $arrayTemp = array("name" => $row['name'], "id" => $nr);
                array_push($name_insurer_array, $arrayTemp);
            }
        }
        echo '<SELECT name="insurance_ID">';
        echo '<OPTION value="-1" >--select insurance--</OPTION>';
        foreach ($name_insurer_array as $row) {
            if ($insurance_ID == $row[id]) {
                $check = 'selected';
            } else {
                $check = '';
            }
            echo '<OPTION value="' . $row[id] . '" ' . $check . '>' . $row[name] . '</OPTION>';
        }
        echo '</SELECT>';
        ?>
</td>

			</tr>
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        echo $LDOccupation;
        ?>
:
			</td>
			<td class="reg_input">
				<input type="text" name="title" size=14 maxlength=25 value="<?php 
        echo $title;
        ?>
" onFocus="this.select();">
			</td>
			</tr>
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        echo $LDEducation;
        ?>
:
			</td>
			<td class="reg_input">
				<input type="text" name="name_others" size=14 maxlength=25 value="<?php 
        echo $name_others;
        ?>
" onFocus="this.select();">
			</td>
			</tr>

<!-- 		<tr>
			<td colspan=2>
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($erroraddress) {
            echo "<font color=red>";
        }
        echo $LDAddress;
        ?>
</font>:
			</td>
			</tr>
-->

<?php 
        if (!$person_email_hide) {
            //{
            ?>
			<tr>
				<td class="reg_item"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
				<?php 
            if ($errormaiden) {
                echo '<font color="FF0000">';
            }
            echo '* ' . 'Region';
            $sql = "SELECT DISTINCT region_id, region_name FROM care_tz_region region INNER JOIN care_tz_district distrcit ON distrcit.is_additional=region.region_id INNER JOIN care_tz_ward ward ON distrcit.district_id=ward.is_additional ORDER BY region_name, district_name, ward_name";
            //$sql="SELECT region_id,region_name FROM view_care_region_district_ward GROUP BY region_id order by region_name ";
            $catchment_area_obj = $db->Execute($sql);
            ?>
</td>
				<td  class="reg_input" colspan=1>
					<select name="region" size="1" onChange="redirect(this.options.selectedIndex)">

						<option value="-1" id="-1">---select region--------</option>
						<?php 
            while ($catchment_area_row = $catchment_area_obj->FetchRow()) {
                echo '<option value="' . $catchment_area_row['region_name'] . '" id=' . $catchment_area_row['region_id'] . '>' . $catchment_area_row['region_name'] . '</option>';
            }
            ?>
					</select>

				<?php 
        }
        ?>

				</td>
				<?php 
        if ($update) {
            ?>
					<td class="reg_input"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
					<?php 
            if ($errormaiden) {
                echo '<font color="FF0000">';
            }
            $sql = "Select * from care_person where pid=" . $pid;
            $result = $db->Execute($sql);
            $region = $result->FetchRow();
            echo '' . 'Region:<FONT SIZE=-1 FACE="Arial" color="#800000"> ' . $region['region'] . '</FONT>';
            ?>
</td><?php 
        }
        ?>
			</tr>
			<tr></tr>
			<tr>
				<td class="reg_item"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
				<?php 
        if ($errormaiden) {
            echo '<font color="FF0000">';
        }
        echo '* ' . 'District';
        ?>
</td>
				<td  class="reg_input" colspan=1>

							<select name="district" size="1" onChange="redirect1(this.options.selectedIndex)">
							<option value="-1" >---select district--------</option>
							</select>


				</td>
				<?php 
        if ($update) {
            ?>
					<td class="reg_input"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
					<?php 
            if ($errormaiden) {
                echo '<font color="FF0000">';
            }
            $sql = "Select * from care_person where pid=" . $pid;
            $result = $db->Execute($sql);
            $region = $result->FetchRow();
            echo '' . 'District: <FONT SIZE=-1 FACE="Arial" color="#800000">' . $region['district'] . '</FONT>';
            ?>
</td><?php 
        }
        ?>
			</tr>
			<tr></tr>
			<tr>
				<td class="reg_item"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
				<?php 
        if ($errormaiden) {
            echo '<font color="FF0000">';
        }
        echo '* ' . 'Ward';
        ?>
</td>
				<td  class="reg_input" colspan=1>
					<select name="ward" size="1">
						<option value="-1" >-select Ward-</option>
					</select>

			<?php 
        ?>

			<script language="javascript">

				<?php 
        // fill up all regions, districts and wards:
        $sql = "SELECT region_id, region_name, district_id, district_name, ward_id, ward_name FROM care_tz_region region INNER JOIN care_tz_district distrcit ON distrcit.is_additional=region.region_id INNER JOIN care_tz_ward ward ON distrcit.district_id=ward.is_additional ORDER BY region_name, district_name, ward_name";
        $catchment_area_obj = $db->Execute($sql);
        $number_of_rows = $catchment_area_obj->RecordCount();
        echo "var group=new Array(" . $number_of_rows . ")\n";
        echo "for (i=0; i<" . $number_of_rows . "; i++)\n";
        echo "group[i]=new Array()\n";
        echo "group[0]= new Option(\"---select Region -----\");\n";
        echo "group[0][0]=new Option(\"---select district--------\");\n";
        echo "group[1][0]=new Option(\"now select this one\");\n";
        echo "group[1][0][0]=new Option(\"-select Ward-\");\n";
        // define some variables that eclipse will get no trouble by syntax error check...
        $previous_region_id = -1;
        $previous_district_id = -1;
        $region_id = 1;
        $district_id = 0;
        $ward_id = 0;
        // remember if it's the first row...
        $FIRST_ROW = TRUE;
        while ($catchment_area_row = $catchment_area_obj->FetchRow()) {
            // reading out all information of this row and store each to a variable
            $this_region_name = $catchment_area_row['region_name'];
            $this_district_name = $catchment_area_row['district_name'];
            $this_district_id = $catchment_area_row['district_id'];
            $this_ward_name = $catchment_area_row['ward_name'];
            $this_ward_id = $catchment_area_row['ward_id'];
            if ($FIRST_ROW == TRUE) {
                // it's the first row, the "this" is the same as the "previous" status
                $previous_region_id = $region_id;
                $previous_ward_id = $ward_id;
                $previous_district_id = $district_id;
                // if its the first row, so we can attach this line directly to the jscript-array:
                echo "group[" . $region_id . "][" . $district_id . "]=new Option(\"" . $this_district_name . "\");\n";
                // "this" is no longer the first row, set it to FALSE
                $FIRST_ROW = FALSE;
            } else {
                // reading out all information of this row and store each to a variable
                $this_region_id = $catchment_area_row['region_id'];
                $this_region_name = $catchment_area_row['region_name'];
                $this_district_name = $catchment_area_row['district_name'];
                $this_district_id = $catchment_area_row['district_id'];
                // it is not the first row, so we have to be a bit more carefully
                if ($this_region_id == $previous_region_id) {
                    // if its the same region ID like the previous one, so check if it's a new district as well:
                    if ($this_district_id == $previous_district_id) {
                        // if its the same district ID like the previous one, then we have a new ward
                        echo "group[" . $region_id . "][" . $district_id . "][" . $ward_id . "]=new Option(\"" . $this_ward_name . "\"); // Ward_id=" . $this_ward_id . "\n";
                        $ward_id = $ward_id + 1;
                    } else {
                        $district_id = $district_id + 1;
                        $previous_district_id = $this_district_id;
                        $ward_id = 0;
                        echo "group[" . $region_id . "][" . $district_id . "]=new Option(\"" . $this_district_name . "\"); //Region_id=" . $this_region_id . "\n";
                    }
                } else {
                    // it's a new region, so reset the value of "this region"
                    $district_id = 0;
                    $region_id = $region_id + 1;
                    echo "group[" . $region_id . "][" . $district_id . "]=new Option(\"" . $this_district_name . "\"); //Region_id=" . $this_region_id . "\n";
                    $previous_region_id = $this_region_id;
                }
                // end of if ($this_region_id==$previous_region_id)
            }
            // end of if ($FIRST_ROW==TRUE)
        }
        ?>


				var temp_district=document.aufnahmeform.district
				var temp_ward=document.aufnahmeform.ward

				function redirect(x){

					// delete all previous entries
					for (m=temp_district.options.length-1;m>0;m--)
						temp_district.options[m]=null;
					// set the new ones to this option list

					for (i=1;i<group[x].length;i++){
						temp_district.options[i]=new Option(group[x][i].text)
					}
					temp_district.options[0].selected=true;
					temp_district.options[0].value=-1;
					redirect1(0)
					}



				function redirect1(y){
					for (m=temp_ward.options.length-1;m>=0;m--)
						temp_ward.options[m]=null;

					var region_index = document.aufnahmeform.region.options.selectedIndex;
					var district_index = document.aufnahmeform.district.options.selectedIndex;
					var i = 0;

					for (i=0;i<100;i++){
						temp_ward.options[i]=new Option(group[region_index][district_index][i].text)
					}

					temp_ward.options[0].selected=true
					temp_ward.options[0].value=-1;

				}

			</script>


				</td>
				<?php 
        if ($update) {
            ?>
					<td class="reg_input"><FONT SIZE=-1  FACE="Arial,verdana,sans serif">
					<?php 
            if ($errormaiden) {
                echo '<font color="FF0000">';
            }
            $sql = "Select * from care_person where pid=" . $pid;
            $result = $db->Execute($sql);
            $region = $result->FetchRow();
            echo '' . 'Ward: <FONT SIZE=-1 FACE="Arial" color="#800000">' . $region['ward'] . '</FONT>';
            ?>
</td><?php 
        }
        ?>

			<tr>
			<td colspan=2>
				<FONT SIZE=-1  FACE="Arial"><?php 
        if ($erroraddress) {
            echo "<font color=red>";
        }
        echo $LDAddress;
        ?>
</font>:
			</td>
			</tr>

			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
        echo $LDTownCity;
        ?>
:
			</td>
			<td class="reg_input"><input name="citizenship" type="text" value="<?php 
        echo $citizenship;
        ?>
" ></td>
			<!--<td class="reg_input">
<?php 
        echo '<SELECT name="addr_citytown_nr" onChange="list_popup(this,\'city\');">';
        echo '<OPTION value="-1" >-- select location --</OPTION>';
        foreach ($town_array as $unit) {
            if (strtoupper($addr_citytown_nr) == strtoupper($unit[1])) {
                $check = 'selected';
            } else {
                $check = '';
            }
            echo '<OPTION value="' . $unit[1] . '" ' . $check . '>' . $unit[0] . '</OPTION>';
        }
        // echo '<OPTION value="notinlist">NOT IN LIST</OPTION>';
        echo '</SELECT>';
        ?>

			</td>-->
			<td class="reg_input">
				&nbsp;&nbsp;<FONT SIZE=-1  FACE="Arial"><?php 
        if ($errorzip) {
            echo "<font color=red>";
        }
        echo $LDPOBOX . " ";
        ?>
<input name="addr_zip" type="text" size="10" value="<?php 
        echo $addr_zip;
        ?>
" >
			</td>
			</tr>

<?php 
        if ($insurance_show) {
            if (!$person_insurance_1_nr_hide) {
                ?>
			<!--<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial"><?php 
                if ($errorinsurancecoid) {
                    echo '<font color="' . $error_fontcolor . '">';
                }
                echo $LDInsuranceCo;
                ?>
:
			</td>
			<td colspan=2 class="reg_input"><FONT SIZE=-1  FACE="Arial"><?php 
                if ($errorinsuranceclass) {
                    echo '<font color="' . $error_fontcolor . '">';
                }
                ?>

					<input name="insurance_category" type="radio"  value="silver"  <?php 
                if ($insurance_category == "silver") {
                    echo 'checked';
                }
                ?>
> <?php 
                echo $LDInsuranceSilver;
                ?>
					<input name="insurance_category" type="radio"  value="gold"  <?php 
                if ($insurance_category == "gold") {
                    echo 'checked';
                }
                ?>
> <?php 
                echo $LDInsuranceGold;
                ?>
					<input name="insurance_category" type="radio"  value="friedkin"  <?php 
                if ($insurance_category == "friedkin") {
                    echo 'checked';
                }
                ?>
> <?php 
                echo $LDInsuranceFriedkin;
                ?>
					<input name="insurance_category" type="radio"  value="selian"  <?php 
                if ($insurance_category == "selian") {
                    echo 'checked';
                }
                ?>
> <?php 
                echo $LDInsuranceSelianstuff;
                ?>

			</td>
			</tr>-->
<?php 
            }
        } else {
            ?>
			<tr>
			<td colspan=2 class="reg_item">
				<a><?php 
            echo $LDSeveralInsurances;
            ?>
<img <?php 
            echo createComIcon($root_path, 'frage.gif', '0');
            ?>
></a>
			</td>
			</tr>
<?php 
        }
        if (!$person_phone_1_nr_hide) {
            $this->createTR($errorphone1, 'phone_1_nr', $LDPhone, $phone_1_nr, 2);
        }
        if (!$person_cellphone_1_nr_hide) {
            $this->createTR($errorcell1, 'cellphone_1_nr', $LDCellPhone, $cellphone_1_nr, 2);
        }
        if (!$person_cellphone_2_nr_hide) {
            $this->createTR($errorcell2, 'cellphone_2_nr', $LDCellPhone . ' 2', $cellphone_2_nr, 2);
        }
        if (!$person_religion_hide) {
            ?>


			<?php 
        }
        ?>
				<!--<tr>
				<td class="reg_item" valign=top class="reg_input">
					<?php 
        echo $LDOtherHospitalNr;
        ?>
				</td>
				<td colspan=2 class="reg_input">
				<?php 
        /*
        $other_hosp_list = $person_obj->OtherHospNrList();
        $sOtherNrBuffer='';
        foreach( $other_hosp_list as $k=>$v ){
        	echo "<b>".$kb_other_his_array[$k].":</b> ".$v."<br />\n";
        }
        
        
        echo '<SELECT name="other_his_org">
        	<OPTION value="">--</OPTION>';
        foreach( $kb_other_his_array as $k=>$v ){
        	echo '<OPTION value="$k" $check>$v</OPTION>';
        }
         echo '</SELECT>&nbsp;&nbsp;'.$LDNr.':<INPUT name="other_his_no" size=20><br>';
        
        echo '('.$LDSelectOtherHospital.' - '.$LDNoNrNoDelete.')<br></TD></TR>';
        */
        ?>
				</td>
				</tr>-->
			<tr>
			<td class="reg_item">
				<FONT SIZE=-1  FACE="Arial" ><FONT  SIZE=2  FACE="Arial"><font color=#ff0000><?php 
        echo $LDRegBy;
        ?>
</font>
			</td>
			<td colspan=2 class="reg_input">
				<FONT SIZE=-1  FACE="Arial"><nobr>
				<input  name="user_id" type="text" value="<?php 
        if (isset($user_id) && $user_id) {
            echo $user_id;
        } else {
            echo $_SESSION['sess_user_name'];
        }
        ?>
"  size="35" readonly>
				</nobr>
			</td>
			</tr>

			</table>
			<p>
			<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
			<input type="hidden" name="itemname" value="<?php 
        echo $itemname;
        ?>
">
			<input type="hidden" name="sid" value="<?php 
        echo $sid;
        ?>
">
			<input type="hidden" name="lang" value="<?php 
        echo $lang;
        ?>
">
			<input type="hidden" name="linecount" value="<?php 
        echo $linecount;
        ?>
">
			<input type="hidden" name="mode" value="save">

			<input type="hidden" name="insurance_item_nr" value="<?php 
        echo $insurance_item_nr;
        ?>
">
			<input type="hidden" name="insurance_firm_id" value="<?php 
        echo $insurance_firm_id;
        ?>
">
			<input type="hidden" name="insurance_show" value="<?php 
        echo $insurance_show;
        ?>
">
			<input type="hidden" name="ethnic_orig" value="<?php 
        echo $ethnic_orig;
        ?>
">
<?php 
        if ($update) {
            echo '<input type="hidden" name="update" value=1>';
            echo '<input type="hidden" name="pid" value="' . $pid . '">';
        }
        ?>
			<input  type="image" <?php 
        echo createLDImgSrc($root_path, 'savedisc.gif', '0');
        ?>
  alt="<?php 
        echo $LDSaveData;
        ?>
" align="absmiddle">
				<a href="javascript:document.aufnahmeform.reset()"><img <?php 
        echo createLDImgSrc($root_path, 'reset.gif', '0');
        ?>
 alt="<?php 
        echo $LDResetData;
        ?>
"   align="absmiddle"></a>
<?php 
        //if($error||$error_person_exists) echo '<input  type="button" value="'.$LDForceSave.'" onClick="forceSave()">';
        ?>
		</form>


<?php 
        if (!$newdata) {
            ?>
			<form action=<?php 
            echo $thisfile;
            ?>
 method=post>
				<input type=hidden name=sid value=<?php 
            echo $sid;
            ?>
>
				<input type=hidden name=patnum value="">
				<input type=hidden name="lang" value="<?php 
            echo $lang;
            ?>
">
				<input type=hidden name="date_format" value="<?php 
            echo $date_format;
            ?>
">
				<input type=submit value="<?php 
            echo $LDNewForm;
            ?>
" >
			</form>
<?php 
        }
    }
             $sql2 .= " OR p.date_birth = '{$srcword}' ";
         }
         if (is_numeric($srcword)) {
             $sql2 .= " OR o.op_nr = {$srcword} OR e.encounter_nr = {$srcword}";
         }
         $sql2 .= ")";
     }
 }
 #Load and create paginator object
 include_once $root_path . 'include/care_api_classes/class_paginator.php';
 $pagen =& new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
 $GLOBAL_CONFIG = array();
 include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
 $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
 # Get the max nr of rows from global config
 $glob_obj->getConfig('pagin_patient_search_max_block_rows');
 if (empty($GLOBAL_CONFIG['pagin_patient_search_max_block_rows'])) {
     $pagen->setMaxCount(MAX_BLOCK_ROWS);
 } else {
     $pagen->setMaxCount($GLOBAL_CONFIG['pagin_patient_search_max_block_rows']);
 }
 # Detect what type of sort item
 if ($oitem == 'encounter_nr') {
     $tab = 'e';
 } elseif (stristr($oitem, 'op_')) {
     $tab = 'o';
 } else {
     $tab = 'p';
 }
 # If the search is directed to a single patient
 if ($mode == 'get' || $mode == 'getbypid' || $mode == 'getbyenc') {
    /**
     * Displays the GUI showing the data
     */
    function display($pid)
    {
        global $root_path, $dbf_nodate, $newdata;
        $validdata = TRUE;
        if (!empty($pid)) {
            $this->pid = $pid;
        }
        # Load the language tables
        $lang_tables = $this->langfile;
        include $root_path . 'include/inc_load_lang_tables.php';
        include_once $root_path . 'include/inc_date_format_functions.php';
        include_once $root_path . 'include/care_api_classes/class_insurance.php';
        $pinsure_obj = new PersonInsurance($this->pid);
        # Get the global config for person�s registration form
        include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
        $GLOBAL_CONFIG = array();
        $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
        $glob_obj->getConfig('person_%');
        //extract($GLOBAL_CONFIG);
        if (empty($this->pid)) {
            $validdata = FALSE;
        } else {
            //if($data_obj=&$this->person_obj->getAllInfoObject()){
            //	$this->data=$data_obj->FetchRow();
            if ($this->is_loaded) {
                extract($this->data);
                # Get related insurance data
                $p_insurance =& $pinsure_obj->getPersonInsuranceObject($this->pid);
                if ($p_insurance == FALSE) {
                    $insurance_show = true;
                } else {
                    if (!$p_insurance->RecordCount()) {
                        $insurance_show = true;
                    } elseif ($p_insurance->RecordCount() == 1) {
                        $buffer = $p_insurance->FetchRow();
                        extract($buffer);
                        $insurance_show = true;
                        # Get insurace firm name
                        $insurance_firm_name = $pinsure_obj->getFirmName($insurance_firm_id);
                    } else {
                        $insurance_show = FALSE;
                    }
                }
                $insurance_class_info = $pinsure_obj->getInsuranceClassInfo($insurance_class_nr);
                # Check if person is currently admitted
                $this->current_encounter = $this->person_obj->CurrentEncounter($this->pid);
                # update the record�s history
                if (empty($newdata)) {
                    @$this->person_obj->setHistorySeen($_SESSION['sess_user_name']);
                }
                # Check whether config foto path exists, else use default path
                $photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $this->default_photo_path;
            } else {
                $validdata = FALSE;
            }
        }
        if ($validdata) {
            include_once $root_path . 'include/inc_photo_filename_resolve.php';
            ############ Here starts the GUI output ##################
            # load config options
            include_once $root_path . 'include/care_api_classes/class_multi.php';
            $multi = new multi();
            ?>
		<table border=0 cellspacing=1 cellpadding=3>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial"><?php 
            echo $LDRegistryNr;
            ?>
:
		</td>
		<td width="30%"  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#800000">
			<?php 
            if ($pid) {
                if (IS_TANZANIAN) {
                    echo $this->showPID($pid);
                } else {
                    echo $pid;
                }
            }
            ?>
<br>
<?php 
            if (file_exists($root_path . 'cache/barcodes/pn_' . $pid . '.png')) {
                echo '<img src="' . $root_path . 'cache/barcodes/pn_' . $pid . '.png" border=0 width=180 height=35>';
            } else {
                echo "<img src='" . $root_path . "classes/barcode/image.php?code=" . $pid . "&style=68&type=I25&width=180&height=50&xres=2&font=5&label=2&form_file=pn' border=0 width=0 height=0>";
                echo "<img src='" . $root_path . "classes/barcode/image.php?code=" . $pid . "&style=68&type=I25&width=180&height=50&xres=2&font=5' border=0 width=180  height=35>";
            }
            ?>
		</td>
		<td valign="top" rowspan=6 align="center" bgcolor="#ffffee" >
			<FONT SIZE=-1  FACE="Arial"><img <?php 
            echo $img_source;
            ?>
>
		</td>
		</tr>
		<tr>
		<td  bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial"><?php 
            echo $LDFileNr;
            ?>
:
		</td>
		<td  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#800000"><b><?php 
            echo $selian_pid;
            ?>
		</td>
		</tr>
		<tr>
		<td  bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial"><?php 
            echo $LDRegTime;
            ?>
:
		</td>
		<td  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#800000"><b><?php 
            echo convertTimeToLocal(formatDate2Local($date_reg, $date_format, 0, 1));
            ?>
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDRegDate;
            ?>
:
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#800000">
			<b><?php 
            echo formatDate2Local($date_reg, $date_format);
            ?>
			<input name="date_reg" type="hidden" value="<?php 
            echo $date_reg;
            ?>
">
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial"><?php 
            echo $LDTitle;
            ?>
:
		</td>
		<td  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $title;
            ?>
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDLastName;
            ?>
:
		</td>
		<td  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $name_last;
            ?>
</b>
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDFirstName;
            ?>
:
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $name_first;
            ?>
</b>
<?php 
            # If person is dead show a black cross
            if ($death_date && $death_date != $dbf_nodate) {
                echo '&nbsp;<img ' . createComIcon($root_path, 'blackcross_sm.gif', '0') . '>';
            }
            ?>
		</td>
		</tr>
<?php 
            if (!$GLOBAL_CONFIG['person_name_2_hide'] && $name_2) {
                $this->createTR($LDName2, $name_2);
            }
            if (!$GLOBAL_CONFIG['person_name_3_hide'] && $name_3) {
                $this->createTR($LDName3, $name_3);
            }
            if (!$GLOBAL_CONFIG['person_name_middle_hide'] && $name_middle) {
                $this->createTR($LDNameMid, $name_middle);
            }
            if (!$GLOBAL_CONFIG['person_name_maiden_hide'] && $name_maiden) {
                $this->createTR($LDNameMaiden, $tribe_name);
            }
            if (!$GLOBAL_CONFIG['person_name_others_hide'] && $name_others) {
                $this->createTR($LDNameOthers, $name_others);
            }
            ?>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDBday;
            ?>
:
		</td>
		<td  bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial"  color="#990000">
			<b><?php 
            echo formatDate2Local($date_birth, $date_format);
            ?>
</b>
<?php 
            # If person is dead show a black cross
            if ($death_date && $death_date != $dbf_nodate) {
                echo '&nbsp;<img ' . createComIcon($root_path, 'blackcross_sm.gif', '0') . '>&nbsp;<font color="#000000">' . formatDate2Local($death_date, $date_format) . '</font>';
            }
            ?>
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>
			<?php 
            echo $LDSex;
            ?>
: <?php 
            if ($sex == "m") {
                echo $LDMale;
            } elseif ($sex == "f") {
                echo $LDFemale;
            }
            ?>
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial"><?php 
            echo $LDBloodGroup;
            ?>
:
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>
<?php 
            $buf = 'LD' . trim($blood_group);
            echo ${$buf};
            ?>
		</td>
<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>
<?php 
            echo $LDRHfactor . $rh;
            ?>
		</td>
		</tr>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo 'Allergy';
            ?>
:
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $allergy;
            ?>
</b>
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDCivilStatus;
            ?>
:
		</td>
		<td colspan=2 bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>
<?php 
            if ($civil_status == "single") {
                echo $LDSingle;
            } elseif ($civil_status == "married") {
                echo $LDMarried;
            } elseif ($civil_status == "divorced") {
                echo $LDDivorced;
            } elseif ($civil_status == "widowed") {
                echo $LDWidowed;
            } elseif ($civil_status == "separated") {
                echo $LDSeparated;
            }
            ?>
		</td>
		</tr>

		<?php 
            global $db;
            $coreObj->sql = "SELECT name FROM care_tz_company WHERE id={$insurance_ID}";
            if ($ergebnis = $db->Execute($coreObj->sql)) {
                $row = $ergebnis->FetchRow();
                $insurance_name = $row['name'];
            } else {
                $insurance_name = '';
            }
            ?>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDInsurance;
            ?>
:
		</td>
		<td><FONT SIZE=-1  FACE="Arial" color="#990000"><b>
		<?php 
            echo $insurance_name;
            ?>
</td>
		</tr>
                <tr>
		<td bgColor="#eeeeee">
		<FONT SIZE=-1  FACE="Arial">
		<?php 
            echo $LDMembership_nr;
            ?>
:
		</td>
		<td><FONT SIZE=-1  FACE="Arial" color="#990000"><b>
		<?php 
            echo $membership_nr;
            ?>
</td>
		</tr>
                <tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDForm_nr;
            ?>
:
		</td>
		<td><FONT SIZE=-1  FACE="Arial" color="#990000"><b>
		<?php 
            echo $form_nr;
            ?>
</td>
		</tr>

		<tr>
		<td colspan=3>
			<FONT SIZE=-1  FACE="Arial">
			<?php 
            echo $LDAddress;
            ?>
:
		</td>
		</tr>

		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			&nbsp;&nbsp;&nbsp;<?php 
            echo $LDTownCity;
            ?>
:
		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>


			<?php 
            echo $citizenship;
            ?>
 <?php 
            //echo $addr_citytown_name;
            //echo $addr_citytown_nr;
            ?>

		</td>
		<td bgcolor="#ffffee">
			<FONT SIZE=-1  FACE="Arial" color="#990000"><b>
			&nbsp;&nbsp;&nbsp;<?php 
            echo $LDZipCode;
            ?>
: <?php 
            echo $addr_zip;
            ?>
		</td>
		</tr>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			&nbsp;&nbsp;&nbsp;<?php 
            echo 'Region';
            ?>
:
		</td>
		<td bgcolor="#ffffee" colspan=2>
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $region > 0 ? $multi->GetRegionName($region) : $region;
            ?>
		</td>
		</tr>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			&nbsp;&nbsp;&nbsp;<?php 
            echo 'District';
            ?>
:
		</td>
		<td bgcolor="#ffffee" colspan=2>
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $district > 0 ? $multi->GetDistrictName($district) : $district;
            ?>
		</td>
		</tr>
		<tr>
		<td bgColor="#eeeeee">
			<FONT SIZE=-1  FACE="Arial">
			&nbsp;&nbsp;&nbsp;<?php 
            echo 'Ward';
            ?>
:
		</td>
		<td bgcolor="#ffffee" colspan=2>
			<FONT SIZE=-1  FACE="Arial" color="#990000">
			<b><?php 
            echo $ward > 0 ? $multi->GetWardName($ward) : $ward;
            ?>
		</td>
		</tr>


 <?php 
            if (!$GLOBAL_CONFIG['person_insurance_1_nr_hide'] && $insurance_show && $insurance_nr) {
                $this->createTR($LDInsuranceNr, $insurance_nr, 2);
                $buffer = $insurance_class_info['LD_var'];
                if (isset(${$buffer}) && !empty(${$buffer})) {
                    $this->createTR($LDInsuranceClass, ${$buffer}, 2);
                } else {
                    $this->createTR($LDInsuranceClass, $insurance_class_info['name'], 2);
                }
                $this->createTR($LDInsuranceCo . ' 1', $insurance_firm_name, 2);
            }
            if (!$GLOBAL_CONFIG['person_phone_1_nr_hide'] && $phone_1_nr) {
                $this->createTR($LDPhone . ' 1', $phone_1_nr, 2);
            }
            if (!$GLOBAL_CONFIG['person_phone_2_nr_hide'] && $phone_2_nr) {
                $this->createTR($LDPhone . ' 2', $phone_2_nr, 2);
            }
            if (!$GLOBAL_CONFIG['person_cellphone_1_nr_hide'] && $cellphone_1_nr) {
                $this->createTR($LDCellPhone . ' 1', $cellphone_1_nr, 2);
            }
            if (!$GLOBAL_CONFIG['person_cellphone_2_nr_hide'] && $cellphone_2_nr) {
                $this->createTR($LDCellPhone . ' 2', $cellphone_2_nr, 2);
            }
            if (!$GLOBAL_CONFIG['person_fax_hide'] && $fax) {
                $this->createTR($LDFax, $fax, 2);
            }
            if (!$GLOBAL_CONFIG['person_email_hide'] && $email) {
            }
            //if (!$GLOBAL_CONFIG['person_citizenship_hide']&&$citizenship){
            //$this->createTR($LDCitizenship,$citizenship,2);
            //}
            if (!$GLOBAL_CONFIG['person_sss_nr_hide'] && $sss_nr) {
                $this->createTR('District', $district_name, 2);
            }
            if (!$GLOBAL_CONFIG['person_nat_id_nr_hide'] && $nat_id_nr) {
                //			$this->createTR('Ward',$ward_name,2);
            }
            if (!$GLOBAL_CONFIG['person_religion_hide'] && $religion) {
                $this->createTR($LDReligion, $name, 2);
            }
            if (!$GLOBAL_CONFIG['person_insurance_hide'] && $insurance_ID) {
                //			$this->createTR($LDInsurance,$insurance_ID,2);
            }
            if (!$GLOBAL_CONFIG['person_ethnic_orig_hide'] && $ethnic_orig) {
                $this->createTR($LDEthnicOrigin, $ethnic_orig_txt, 2);
            }
            $sql = 'SELECT modify_id, create_id FROM care_person where pid="' . $pid . '"';
            $result = $db->Execute($sql);
            $row = $result->FetchRow();
            if ($row['modify_id'] == '') {
                $modifyid = $row['create_id'];
            } else {
                $modifyid = $row['modify_id'];
            }
            ?>
		<tr>
		<td bgcolor="#eeeeee">
			<nobr><FONT  SIZE=2  FACE="Arial"><?php 
            echo $LDRegBy;
            ?>
:</nobr>
		</td>
		<td colspan=2 bgcolor="#ffffee">
			<FONT  SIZE=2  FACE="Arial" color="#990000"><b><?php 
            echo $modifyid;
            ?>
 </b></FONT>
		</td>
		</tr>
		</table>
<?php 
        } else {
            echo 'Invalid PID number or the data is not available from the databank! Please report this to <a  href="mailto:info@care2x.org">info@care2x.org</a>. Thank you.';
        }
    }
示例#5
0
if ($mode != 'paginate') {
    # Reset paginator variables
    $pgx = 0;
    $totalcount = 0;
    # Set the sort parameters
    if (empty($oitem)) {
        $oitem = 'name';
    }
    if (empty($odir)) {
        $odir = 'ASC';
    }
}
$GLOBAL_CONFIG = array();
include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('pagin_address_list_max_block_rows');
if (empty($GLOBAL_CONFIG['pagin_address_list_max_block_rows'])) {
    $GLOBAL_CONFIG['pagin_address_list_max_block_rows'] = MAX_BLOCK_ROWS;
}
# Last resort, use the default defined at the start of this page
#Load and create paginator object
require_once $root_path . 'include/care_api_classes/class_paginator.php';
$pagen = new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
# Adjust the max nr of rows in a block
$pagen->setMaxCount($GLOBAL_CONFIG['pagin_address_list_max_block_rows']);
# Get all the active firms info
//$address=$address_obj->getAllActiveCityTown();
$address =& $address_obj->getLimitActiveCityTown($GLOBAL_CONFIG['pagin_address_list_max_block_rows'], $pgx, $oitem, $odir);
# Get the resulting record count
//echo $address_obj->getLastQuery();
$linecount = $address_obj->LastRecordCount();
示例#6
0
require_once 'include/care_api_classes/class_userconfig.php';
$cfg_obj = new UserConfig();
if ($cfg_obj->exists($user_id)) {
    $cfg_obj->getConfig($user_id);
    $USERCONFIG = $cfg_obj->buffer;
    $config_exists = true;
    // Flag that user config is existing
} else {
    $cfg_obj->_getDefault();
    $USERCONFIG = $cfg_obj->buffer;
}
# Load global configurations API
require_once 'include/care_api_classes/class_globalconfig.php';
$glob_cfg = new GlobalConfig($GLOBALCONFIG);
# Get the global config for language usage
$glob_cfg->getConfig('language_%');
# Get the global config for frames
$glob_cfg->getConfig('gui_frame_left_nav_width');
# Get the global config for lev nav border
$glob_cfg->getConfig('gui_frame_left_nav_border');
$savelang = 0;
/*echo $GLOBALCONFIG['language_non_single'];
while (list($x,$v)=each($GLOBALCONFIG)) echo $x.'==>'.$v.'<br>';
*/
# Start checking language properties
if (!$GLOBALCONFIG['language_single']) {
    # We get the language code
    if ($_chg_lang_ && !empty($lang)) {
        $savelang = 1;
    } else {
        //echo $lang=$USERCONFIG['lang'];
示例#7
0
    } else {
        if (!is_numeric($_POST['news_normal_display_width'])) {
            $_POST['news_normal_display_width'] = NEWS_DISPLAY_WIDTH;
        }
    }
    if (!is_numeric($_POST['news_normal_preview_maxlen'])) {
        $_POST['news_normal_preview_maxlen'] = NEWS_PREVIEW_MAXLEN;
    }
    # Save the configuration
    $glob_obj->saveConfigArray($_POST, $filter, $numeric, '', $addslash);
    # Loop back to self to get the newly stored values
    header("location:{$thisfile}" . URL_REDIRECT_APPEND . "&save_ok=1");
    exit;
    # Else get current global data
} else {
    $glob_obj->getConfig('news_%');
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('system_admin');
# Title in toolbar
$smarty->assign('sToolbarTitle', $LDNewsDisplay);
# href for help button
$smarty->assign('pbHelp', "javascript:gethelp('newsdisplay.php')");
# href for close button
$smarty->assign('breakfile', $breakfile);
    $GCONFIG = array();
}
include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$gc = new GlobalConfig($GCONFIG);
if (isset($mode) && $mode == 'save' && !empty($max_items)) {
    for ($i = 1; $i <= $max_items; $i++) {
        if (empty($_POST["value{$i}"])) {
            $_POST["value{$i}"] = '0';
        }
        //echo $_POST["index$i"].'==>'.$_POST["value$i"].'<br>';
        $gc->saveConfigItem($_POST["index{$i}"], $_POST["value{$i}"]);
    }
    header('location:' . $thisfile . URL_REDIRECT_APPEND . '&mode=0');
    exit;
} else {
    $gc->getConfig('person_%_hide');
    $gc->getConfig('patient_%_hide');
    $gc->getConfig('patient_%_show');
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('system_admin');
# Title in toolbar
$smarty->assign('sToolbarTitle', $LDDataEntryForms);
# href for return button
$smarty->assign('pbBack', $returnfile);
示例#9
0
<?php

error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
require './roots.php';
require $root_path . 'include/inc_environment_global.php';
require $root_path . 'include/inc_front_chain_lang.php';
//----------------------------------------------------------------------------------------------------
$breakfile = 'edv-system-admi-welcome.php' . URL_APPEND;
//----------------------------------------------------------------------------------------------------
$GLOBAL_CONFIG = array();
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$thisfile = basename($_SERVER['PHP_SELF']);
if (isset($_POST['mode']) && $_POST['mode'] == 'save') {
    $filter = 'main_info_facility';
    # The index filter
    $numeric = FALSE;
    # Values are not strictly numeric
    $addslash = TRUE;
    # Slashes should be added to the stored values
    # Save the configuration
    $glob_obj->saveConfigArray($_POST, $filter, $numeric, '', $addslash);
    # Loop back to self to get the newly stored values
    header("location:{$thisfile}" . URL_REDIRECT_APPEND . "&save_ok=1");
    exit;
    # Else get current global data
} else {
    $glob_obj->getConfig('main_info_facility%');
}
//----------------------------------------------------------------------------------------------------
require "gui_edv_arv_information.php";
示例#10
0
* We check again the language variable lang. If table file not available use default (lang = "en")
*/
if (!isset($lang) || empty($lang)) {
    include $root_path . 'chklang.php';
}
/* Load the language table */
if (file_exists($root_path . 'language/' . $lang . '/lang_' . $lang . '_indexframe.php')) {
    include $root_path . 'language/' . $lang . '/lang_' . $lang . '_indexframe.php';
} else {
    include $root_path . 'language/en/lang_en_indexframe.php';
    $lang = 'en';
    // last desperate effort to settle the language
}
// echo $_COOKIE['ck_config']; // for debugging only
if ($mask == 2 && !$nonewmask) {
    header("location: indexframe2.php?sid=" . $sid . "&lang=" . $lang . "&boot=" . $boot . "&cookie=" . $cookie);
    exit;
}
# Get the global config for language usage
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$GLOBALCONFIG = array();
$gc = new GlobalConfig($GLOBALCONFIG);
$gc->getConfig('language_%');
# Prepare additional data for the gui template
$charset = setCharSet();
# Load dept & ward classes
require_once $root_path . 'include/care_api_classes/class_department.php';
require_once $root_path . 'include/care_api_classes/class_ward.php';
$dept = new Department();
$ward = new Ward();
require './gui_bridge/gui_indexframe.php';
示例#11
0
}
# Clean the title
require $root_path . 'include/inc_newstitle_clean.php';
# Check if the uploaded image file is valid
$is_pic = @$img_obj->isValidUploadedImage($_FILES['pic']);
# Retrieve the filename extension
$picext = @$img_obj->UploadedImageMimeType();
$publishdate = @formatDate2Std($publishdate, $date_format);
/* Prepare data set for saving */
$news = array('category' => $category, 'title' => $newstitle, 'preface' => $preface, 'body' => $newsbody, 'pic_mime' => $picext, 'art_num' => $artnum, 'author' => $author, 'publish_date' => $publishdate);
require_once $root_path . 'include/care_api_classes/class_news.php';
$newsobj = new News();
if ($news_nr = $newsobj->saveNews($dept_nr, $news)) {
    if ($is_pic) {
        # Get the news foto path from global config
        require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
        $globobj = new GlobalConfig($GLOBALCONFIG);
        $globobj->getConfig('news_fotos_path');
        if ($GLOBALCONFIG['news_fotos_path'] == '') {
            $news_fotos_path = $root_path . 'fotos/news/';
        } else {
            $news_fotos_path = $root_path . $GLOBALCONFIG['news_fotos_path'];
        }
        $picfilename = "{$news_nr}.{$picext}";
        $img_obj->saveUploadedImage($_FILES['pic'], $news_fotos_path, $picfilename);
    }
    header('Location: ' . $fileforward . URL_REDIRECT_APPEND . '&nr=' . $news_nr . '&mode=preview4saved');
    exit;
} else {
    echo $img_obj->getLastQuery() . "<p>{$LDDbNoSave}";
}
示例#12
0
 include $root_path . 'include/inc_init_crypt.php';
 # initialize crypt
 $clear_ck_sid = $dec_hcemd5->DecodeMimeSelfRand($_COOKIE[$ck_sid_buffer]);
 $tnow = date('His');
 // echo $tnow."<p>";
 $time_out = FALSE;
 if (!defined('NO_2LEVEL_CHK') || NO_2LEVEL_CHK != 1) {
     # Let us check if the calling script is the time-out configuration script, if yes, then we skip the time out
     if (!preg_match('/edv_system_timeout.php/i', $_SERVER['PHP_SELF'])) {
         # Load the global time out configs
         include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
         if (!isset($GLOBAL_CONFIG)) {
             $GLOBAL_CONFIG = array();
         }
         $gc_obj = new GlobalConfig($GLOBAL_CONFIG);
         $gc_obj->getConfig('timeout_%');
         # If config data available, use it
         if ($GLOBAL_CONFIG['timeout_inactive']) {
             $TIME_OUT_INACTIVE = $GLOBAL_CONFIG['timeout_inactive'];
         }
         if ((int) $GLOBAL_CONFIG['timeout_time']) {
             $TIME_OUT_TIME = (int) $GLOBAL_CONFIG['timeout_time'];
         }
         if (!$TIME_OUT_INACTIVE) {
             #echo $tnow."<br>";
             #echo $_SESSION['sess_tos']."<br>";
             #echo ($tnow-$_SESSION['sess_tos'])."<br>";
             # Check if session is still valid
             if (isset($_SESSION['sess_tos']) || $_SESSION['sess_tos']) {
                 # Check if time out value is positive or not zero
                 # current time minus start time
示例#13
0
<?php

if (preg_match('/pageheader1.php/i', $_SERVER['PHP_SELF'])) {
    die('<meta http-equiv="refresh" content="0; url=../../../">');
}
#Get care logo
$imgsize = GetImageSize($logo);
$pdf->addPngFromFile($logo, 20, 780, $imgsize[0]);
# Attach logo
$pdf->selectFont($fontpath . 'Helvetica.afm');
$pdf->ezStartPageNumbers(550, 25, 8);
# Get the main informations
if (!isset($GLOBAL_CONFIG)) {
    $GLOBAL_CONFIG = array();
}
include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob = new GlobalConfig($GLOBAL_CONFIG);
# Get all config items starting with "main_"
$glob->getConfig('main_%');
$addr[] = array($GLOBAL_CONFIG['main_info_address'], "{$LDPhone}:\n{$LDFax}:\n{$LDEmail}:", $GLOBAL_CONFIG['main_info_phone'] . "\n" . $GLOBAL_CONFIG['main_info_fax'] . "\n" . $GLOBAL_CONFIG['main_info_email'] . "\n");
$pdf->ezTable($addr, '', '', array('xPos' => 165, 'xOrientation' => 'right', 'showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'fontsize' => 6, 'cols' => array(1 => array('justification' => 'right'))));
示例#14
0
# Initialize page�s control variables
if ($mode != 'paginate') {
    # Reset paginator variables
    $pgx = 0;
    $totalcount = 0;
    $odir = '';
    $oitem = '';
}
#Load and create paginator object
require_once $root_path . 'include/care_api_classes/class_paginator.php';
$pagen = new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
$GLOBAL_CONFIG = array();
# Get the max nr of rows from global config
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('pagin_personell_list_max_block_rows');
if (empty($GLOBAL_CONFIG['pagin_personell_list_max_block_rows'])) {
    $pagen->setMaxCount(MAX_BLOCK_ROWS);
} else {
    $pagen->setMaxCount($GLOBAL_CONFIG['pagin_personell_list_max_block_rows']);
}
if (empty($oitem)) {
    $oitem = 'name_last';
}
if (empty($odir)) {
    $odir = 'ASC';
}
# default, ascending alphabetic
# Set the sort parameters
$pagen->setSortItem($oitem);
$pagen->setSortDirection($odir);
}
$thisfile = basename($_SERVER['PHP_SELF']);
# Load the department list with oncall doctors
require_once $root_path . 'include/care_api_classes/class_department.php';
$dept_obj = new Department();
$dept_obj->preloadDept($dept_nr);
$dept_list =& $dept_obj->getAllMedical();
# Load the dept doctors
require_once $root_path . 'include/care_api_classes/class_personell.php';
$pers_obj = new Personell();
$doctors =& $pers_obj->getDoctorsOfDept($dept_nr);
# Load global values
$GLOBAL_CONFIG = array();
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('personell_%');
# Set color values for the search mask
$searchmask_bgcolor = '#f3f3f3';
$searchprompt = $LDEntryPrompt;
$entry_block_bgcolor = '#fff3f3';
$entry_border_bgcolor = '#6666ee';
$entry_body_bgcolor = '#ffffff';
if (!isset($searchkey)) {
    $searchkey = '';
}
if (!isset($mode)) {
    $mode = '';
}
if (!empty($ipath)) {
    switch ($ipath) {
        case 'menu':
    $user = new UserConfig();
    if ($user->getConfig($_COOKIE['ck_config'])) {
        $config =& $user->getConfigData();
        $config = array_merge($config, $config_new);
        if ($user->saveConfig($_COOKIE['ck_config'], $config)) {
            header('location:' . basename(__FILE__) . URL_REDIRECT_APPEND . '&saved=1');
            exit;
        }
    }
} elseif (!isset($cfg['control_buttons']) || empty($cfg['control_buttons'])) {
    if (!isset($GLOBAL_CONFIG)) {
        $GLOBAL_CONFIG = array();
    }
    include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
    $gc = new GlobalConfig($GLOBAL_CONFIG);
    $gc->getConfig('theme_common_icons');
    if (!empty($GLOBAL_CONFIG['theme_common_icons'])) {
        $cfg['icons'] = $GLOBAL_CONFIG['theme_common_icons'];
    } else {
        $cfg['control_buttons'] = 'default';
    }
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('common');
# Toolbar title
示例#17
0
if ($mode != 'paginate') {
    # Reset paginator variables
    $pgx = 0;
    $totalcount = 0;
    # Set the sort parameters
    if (empty($oitem)) {
        $oitem = 'name';
    }
    if (empty($odir)) {
        $odir = 'ASC';
    }
}
$GLOBAL_CONFIG = array();
include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('pagin_insurance_list_max_block_rows');
if (empty($GLOBAL_CONFIG['pagin_insurance_list_max_block_rows'])) {
    $GLOBAL_CONFIG['pagin_insurance_list_max_block_rows'] = MAX_BLOCK_ROWS;
}
# Last resort, use the default defined at the start of this page
#Load and create paginator object
require_once $root_path . 'include/care_api_classes/class_paginator.php';
$pagen = new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
# Adjust the max nr of rows in a block
$pagen->setMaxCount($GLOBAL_CONFIG['pagin_insurance_list_max_block_rows']);
# Get all the active firms info
$firms = $ins_obj->getLimitActiveFirmsInfo($GLOBAL_CONFIG['pagin_insurance_list_max_block_rows'], $pgx, $oitem, $odir);
$linecount = $ins_obj->LastRecordCount();
$pagen->setTotalBlockCount($linecount);
# Count total available data
if (isset($totalcount) && $totalcount) {
示例#18
0
<?php

require_once 'care_api_classes/class_globalconfig.php';
require_once 'inc_environment_global.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('is%');
if ($GLOBAL_CONFIG['is_transmit_to_weberp_enable'] == "") {
    $sql = 'INSERT INTO care_config_global (`type`, `value`, `notes`, `status`, `history`, `modify_id`, `modify_time`, `create_id`, `create_time`) VALUES (\'is_transmit_to_weberp_enable\', \'0\', NULL, \'\', \'\', \'\', NOW(), \'\', \'0000-00-00 00:00:00\');';
    $db->Execute($sql);
}
$webERPServerURL = "http://192.168.210.145/webERPtanzania/api/api_xml-rpc.php";
$weberpuser = "******";
$weberppassword = "******";
$weberpDebugLevel = 0;
$is_transmit_to_weberp_enable = $GLOBAL_CONFIG['is_transmit_to_weberp_enable'];
示例#19
0
/* Create new person's insurance object */
$pinsure_obj = new PersonInsurance($pid);
/* Get the insurance classes */
$insurance_classes =& $pinsure_obj->getInsuranceClassInfoObject('class_nr,name,LD_var AS "LD_var"');
/* Create new person object */
$person_obj = new Person($pid);
/* Create encounter object */
$encounter_obj = new Encounter($encounter_nr);
/* Create a new billing object */
$bill_obj = new Bill();
/* Get all encounter classes */
$encounter_classes = $encounter_obj->AllEncounterClassesObject();
if ($pid != '' || $encounter_nr != '') {
    /* Get the patient global configs */
    $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
    $glob_obj->getConfig('patient_%');
    $glob_obj->getConfig('person_foto_path');
    $glob_obj->getConfig('encounter_%');
    if (!$GLOBAL_CONFIG['patient_service_care_hide']) {
        /* Get the care service classes*/
        $care_service = $encounter_obj->AllCareServiceClassesObject();
    }
    if (!$GLOBAL_CONFIG['patient_service_room_hide']) {
        /* Get the room service classes */
        $room_service = $encounter_obj->AllRoomServiceClassesObject();
    }
    if (!$GLOBAL_CONFIG['patient_service_att_dr_hide']) {
        /* Get the attending doctor service classes */
        $att_dr_service = $encounter_obj->AllAttDrServiceClassesObject();
    }
    /* Check whether config path exists, else use default path */
示例#20
0
    $user_id = $local_user . $sid;
    $user_id = ${$user_id};
}
if (isset($pid) && $pid != '') {
    $person_obj = new Person($pid);
    if ($data_obj =& $person_obj->getAllInfoObject()) {
        $zeile = $data_obj->FetchRow();
        //while(list($x,$v)=each($zeile))	$$x=$v;
        extract($zeile);
    } else {
        //
    }
}
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('person_%');
//$glob_obj->getConfig('patient_%');
$glob_obj->getConfig('notes_%');
if (!$GLOBAL_CONFIG['notes_preview_maxlen']) {
    $GLOBAL_CONFIG['notes_preview_maxlen'] = 60;
}
// hardcoded default value;
//$_SESSION['sess_full_pid']=$pid+$GLOBAL_CONFIG['person_id_nr_adder'];
$_SESSION['sess_full_pid'] = $pid;
/* Check whether config foto path exists, else use default path */
$photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $default_photo_path;
require_once $root_path . 'include/inc_photo_filename_resolve.php';
# set to safe defaults
//if(!isset($is_discharged)) $is_discharged=true;
if (!isset($edit)) {
    $edit = false;
示例#21
0
if (!isset($user_id) || !$user_id) {
    $user_id = $local_user . $sid;
    $user_id = ${$user_id};
}
if (isset($pid) && $pid != '') {
    $person_obj = new Person($pid);
    if ($data_obj =& $person_obj->getAllInfoObject()) {
        $zeile = $data_obj->FetchRow();
        while (list($x, $v) = each($zeile)) {
            ${$x} = $v;
        }
    }
    $sql = 'SELECT * FROM care_appointment WHERE pid=' . $pid;
    if ($result = $db->Execute($sql)) {
        $row = $result->RecordCount();
    }
}
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('person_%');
$glob_obj->getConfig('patient_%');
/* Check whether config foto path exists, else use default path */
$photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $default_photo_path;
require_once $root_path . 'include/inc_photo_filename_resolve.php';
if ($_SESSION['sess_parent_mod'] == 'admission') {
    $parent_admit = true;
    $page_title = $LDAdmission;
} else {
    $parent_admit = false;
    $page_title = $LDPatientRegister;
}
# Save data if save mode
if (isset($mode) && $mode == 'save') {
    $filter = 'main_info_';
    # The index filter
    $numeric = FALSE;
    # Values are not strictly numeric
    $addslash = TRUE;
    # Slashes should be added to the stored values
    # Save the configuration
    $glob_obj->saveConfigArray($_POST, $filter, $numeric, '', $addslash);
    # Loop back to self to get the newly stored values
    header("location:{$thisfile}" . URL_REDIRECT_APPEND . "&save_ok=1");
    exit;
    # Else get current global data
} else {
    $glob_obj->getConfig('main_info%');
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('system_admin');
# Title in toolbar
$smarty->assign('sToolbarTitle', $LDQuickInformer);
# href for help button
$smarty->assign('pbHelp', "javascript:gethelp('quickinfo.php')");
# href for close button
$smarty->assign('breakfile', $breakfile);
示例#23
0
}
$patregtable = 'care_person';
// The table of the patient registration data
//$dbtable='care_encounter'; // The table of admission data
/* Create new person's insurance object */
$pinsure_obj = new PersonInsurance($pid);
/* Get the insurance classes */
$insurance_classes =& $pinsure_obj->getInsuranceClassInfoObject('class_nr,name,LD_var');
/* Create new person object */
$person_obj = new Person($pid);
/* Create personell object */
$personell_obj = new Personell();
if ($pid || $personell_nr) {
    # Get the patient global configs
    $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
    $glob_obj->getConfig('personell_%');
    $glob_obj->getConfig('person_foto_path');
    # Check whether config path exists, else use default path
    $photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $default_photo_path;
    if ($pid) {
        # Check whether the person is currently admitted. If yes jump to display admission data
        if ($mode != 'save' && ($personell_nr = $personell_obj->Exists($pid))) {
            header('Location:personell_register_show.php' . URL_REDIRECT_APPEND . '&personell_nr=' . $personell_nr . '&origin=admit&sem=isadmitted&target=personell_reg');
            exit;
        }
        # Get the related insurance data
        $p_insurance =& $pinsure_obj->getPersonInsuranceObject($pid);
        if ($p_insurance == FALSE) {
            $insurance_show = TRUE;
        } else {
            if (!$p_insurance->RecordCount()) {
示例#24
0
    $user = new UserConfig();
    if ($user->getConfig($_COOKIE['ck_config'])) {
        $config =& $user->getConfigData();
        $config = array_merge($config, $config_new);
        if ($user->saveConfig($_COOKIE['ck_config'], $config)) {
            header('location:' . basename(__FILE__) . URL_REDIRECT_APPEND . '&saved=1');
            exit;
        }
    }
} elseif (!isset($cfg['template_smarty']) || empty($cfg['template_smarty'])) {
    if (!isset($GLOBAL_CONFIG)) {
        $GLOBAL_CONFIG = array();
    }
    include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
    $gc = new GlobalConfig($GLOBAL_CONFIG);
    $gc->getConfig('template_smarty');
    if (!empty($GLOBAL_CONFIG['template_smarty'])) {
        $cfg['template_smarty'] = $GLOBAL_CONFIG['template_smarty'];
    } else {
        $cfg['template_smarty'] = 'default';
    }
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('common');
# Toolbar title
?>
</font>
<form method="post">
<table border=0 cellspacing=1 cellpadding=2>  

  <tr background="../../gui/img/common/default/tableHeaderbg3.gif">
    <td><FONT  color="#000099"><b></b></td>
    <td><FONT  color="#000099"><b></b></td>
   <td><FONT  color="#000099"><b><?php 
echo $LDStatus;
?>
</b></td>
  </tr>

<?php 
$gc->getConfig('theme_control_%');
echo '<tr>
	<td bgcolor="#e9e9e9"><img ' . createComIcon($root_path, 'arrow_blueW.gif', '0') . '></td>
	<td bgcolor="#e9e9e9"><FONT  color="#0000cc"><b>' . $LDControlButImg . '</b> </FONT></td>';
echo '
	<td bgcolor="#e9e9e9" >
	<select name="theme_control_buttons">';
$tlist = explode(',', $GCONFIG['theme_control_theme_list']);
while (list($x, $v) = each($tlist)) {
    echo '<option value="' . $v . '"';
    if ($GCONFIG['theme_control_buttons'] == $v) {
        echo ' selected';
    }
    echo '>
		' . $v . '
		</option>';
    /**
     * Displaying the GUI
     */
    function display($skey = '')
    {
        global $db, $searchkey, $root_path, $firstname_too, $HTTP_POST_VARS, $HTTP_GET_VARS, $sid, $lang, $mode, $totalcount, $pgx, $odir, $oitem, $HTTP_SESSION_VARS, $dbf_nodate, $user_origin, $parent_admit, $status, $target, $origin;
        $this->thisfile = $filename;
        $this->searchkey = $skey;
        $this->mode = $mode;
        if (empty($this->targetfile)) {
            $withtarget = FALSE;
            $navcolspan = 5;
        } else {
            $withtarget = TRUE;
            $navcolspan = 6;
        }
        if (!empty($skey)) {
            $searchkey = $skey;
        }
        # Load the language tables
        $lang_tables = $this->langfile;
        include $root_path . 'include/inc_load_lang_tables.php';
        # Initialize pages control variables
        if ($mode == 'paginate') {
            $searchkey = $HTTP_SESSION_VARS['sess_searchkey'];
            //$searchkey='USE_SESSION_SEARCHKEY';
            //$mode='search';
        } else {
            # Reset paginator variables
            $pgx = 0;
            $totalcount = 0;
            $odir = '';
            $oitem = '';
        }
        # Create an array to hold the config values
        $GLOBAL_CONFIG = array();
        #Load and create paginator object
        include_once $root_path . 'include/care_api_classes/class_paginator.php';
        $pagen = new Paginator($pgx, $this->thisfile, $HTTP_SESSION_VARS['sess_searchkey'], $root_path);
        include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
        $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
        $glob_obj->getConfig('person_id_%');
        # Get the max nr of rows from global config
        $glob_obj->getConfig('pagin_person_search_max_block_rows');
        if (empty($GLOBAL_CONFIG['pagin_person_search_max_block_rows'])) {
            # Last resort, use the default defined at the start of this page
            $pagen->setMaxCount($max_block_rows);
        } else {
            $pagen->setMaxCount($GLOBAL_CONFIG['pagin_person_search_max_block_rows']);
        }
        //$db->debug=true;
        if (!defined('SHOW_FIRSTNAME_CONTROLLER')) {
            define('SHOW_FIRSTNAME_CONTROLLER', $this->show_firstname_controller);
        }
        if (SHOW_FIRSTNAME_CONTROLLER) {
            if (isset($HTTP_POST_VARS['firstname_too'])) {
                if ($HTTP_POST_VARS['firstname_too']) {
                    $firstname_too = 1;
                } elseif ($mode == 'paginate' && isset($HTTP_GET_VARS['firstname_too']) && $HTTP_GET_VARS['firstname_too']) {
                    $firstname_too = 1;
                }
            } elseif ($mode != 'search') {
                $firstname_too = TRUE;
            }
        }
        if (($this->mode == 'search' || $this->mode == 'paginate') && !empty($searchkey)) {
            # Translate *? wildcards
            $searchkey = strtr($searchkey, '*?', '%_');
            include_once $root_path . 'include/inc_date_format_functions.php';
            include_once $root_path . 'include/care_api_classes/class_person.php';
            $person =& new Person();
            # Set the sorting directive
            if (isset($oitem) && !empty($oitem)) {
                $sql3 = " ORDER BY {$oitem} {$odir}";
            }
            //$sql='SELECT * FROM '.$dbtable.$sql2;
            if ($mode == 'paginate') {
                $fromwhere = $HTTP_SESSION_VARS['sess_searchkey'];
                $sql = 'SELECT pid, name_last, name_first, date_birth, addr_zip, sex, death_date, status FROM ' . $fromwhere . $sql3;
                $ergebnis = $db->SelectLimit($sql, $pagen->MaxCount(), $pagen->BlockStartIndex());
                $linecount = $ergebnis->RecordCount();
            } else {
                $ergebnis = $person->SearchSelect($searchkey, $pagen->MaxCount(), $pagen->BlockStartIndex(), $oitem, $odir, $firstname_too);
                #Retrieve the sql fromwhere portion
                $fromwhere = $person->buffer;
                $HTTP_SESSION_VARS['sess_searchkey'] = $fromwhere;
                $sql = $person->getLastQuery();
                $linecount = $person->LastRecordCount();
            }
            if ($ergebnis) {
                if ($linecount == 1) {
                    if ($this->auto_show_bynumeric && $person->is_nr || $this->auto_show_byalphanumeric) {
                        $zeile = $ergebnis->FetchRow();
                        header("location:" . $this->targetfile . "?sid=" . $sid . "&lang=" . $lang . "&pid=" . $zeile['pid'] . "&edit=1&status=" . $status . "&user_origin=" . $user_origin . "&noresize=1&mode=");
                        exit;
                    }
                }
                $pagen->setTotalBlockCount($linecount);
                # If more than one count all available
                if (isset($totalcount) && $totalcount) {
                    $pagen->setTotalDataCount($totalcount);
                } else {
                    # Count total available data
                    $sql = 'SELECT COUNT(pid) AS maxnr FROM ' . $fromwhere;
                    if ($result = $db->Execute($sql)) {
                        if ($result->RecordCount()) {
                            $rescount = $result->FetchRow();
                            $totalcount = $rescount['maxnr'];
                        }
                    }
                    $pagen->setTotalDataCount($totalcount);
                }
                # Set the sort parameters
                $pagen->setSortItem($oitem);
                $pagen->setSortDirection($odir);
            } else {
                if ($show_sqlquery) {
                    echo $sql;
                }
            }
        } else {
            $mode = '';
        }
        $entry_block_bgcolor = $this->entry_block_bgcolor;
        $entry_border_bgcolor = $this->entry_border_bgcolor;
        $entry_body_bgcolor = $this->entry_body_bgcolor;
        $searchmask_bgcolor = $this->searchmask_bgcolor;
        ##############  Here starts the html output
        # Start Smarty templating here
        # Create smarty object without initiliazing the GUI (2nd param = FALSE)
        include_once $root_path . 'gui/smarty_template/smarty_care.class.php';
        $this->smarty = new smarty_care('common', FALSE);
        # Output any existing text before the search block
        if (!empty($this->pretext)) {
            $this->smarty->assign('sPretext', $this->pretext);
        }
        # Show tips and tricks link and the javascript
        if ($this->showtips) {
            ob_start();
            include_once $root_path . 'include/inc_js_gethelp.php';
            $sTemp = ob_get_contents();
            $this->smarty->assign('sJSGetHelp', $sTemp);
            ob_end_clean();
            $this->smarty->assign('LDTipsTricks', '<a href="javascript:gethelp(\'person_search_tips.php\')">' . $LDTipsTricks . '</a>');
        }
        #
        # Prepare the javascript validator
        #
        if (!isset($searchform_count) || !$searchform_count) {
            $this->smarty->assign('sJSFormCheck', '<script language="javascript">
			<!--
				function chkSearch(d){
					if((d.searchkey.value=="") || (d.searchkey.value==" ")){
						d.searchkey.focus();
						return false;
					}else	{
						return true;
					}
				}
			// -->
			</script>');
        }
        #
        # Prepare the search file
        #
        if (empty($this->searchfile)) {
            $search_script = $this->thisfile;
        } else {
            $search_script = $this->searchfile;
        }
        #
        # Prepare the form params
        #
        $sTemp = 'method="post" name="searchform';
        if ($searchform_count) {
            $sTemp = $sTemp . "_" . $searchform_count;
        }
        $sTemp = $sTemp . '" onSubmit="return chkSearch(this)"';
        if (isset($search_script) && $search_script != '') {
            $sTemp = $sTemp . ' action="' . $search_script . '"';
        }
        $this->smarty->assign('sFormParams', $sTemp);
        if (empty($this->prompt)) {
            $searchprompt = $LDEntryPrompt;
        } else {
            $searchprompt = $this->prompt;
        }
        //$searchprompt=$LDEnterEmployeeSearchKey;
        $this->smarty->assign('searchprompt', $searchprompt);
        #
        # Prepare the checkbox input
        #
        if (defined('SHOW_FIRSTNAME_CONTROLLER') && SHOW_FIRSTNAME_CONTROLLER) {
            if (isset($firstname_too) && $firstname_too) {
                $sTemp = 'checked';
            }
            $this->smarty->assign('sCheckBoxFirstName', '<input type="checkbox" name="firstname_too" ' . $sTemp . '>');
            $this->smarty->assign('LDIncludeFirstName', $LDIncludeFirstName);
        }
        #
        # Prepare the hidden inputs
        #
        $this->smarty->assign('sHiddenInputs', '<input type="image" ' . createLDImgSrc($root_path, 'searchlamp.gif', '0', 'absmiddle') . '>
				<input type="hidden" name="sid" value="' . $sid . '">
				<input type="hidden" name="lang" value="' . $lang . '">
				<input type="hidden" name="noresize" value="' . $noresize . '">
				<input type="hidden" name="target" value="' . $target . '">
				<input type="hidden" name="user_origin" value="' . $user_origin . '">
				<input type="hidden" name="origin" value="' . $origin . '">
				<input type="hidden" name="retpath" value="' . $retpath . '">
				<input type="hidden" name="aux1" value="' . $aux1 . '">
				<input type="hidden" name="ipath" value="' . $ipath . '">
				<input type="hidden" name="mode" value="search">');
        $this->smarty->assign('sCancelButton', '<a href="' . $this->cancelfile . URL_APPEND . '"><img ' . createLDImgSrc($root_path, 'cancel.gif', '0') . '></a>');
        //include($root_path.'include/inc_patient_searchmask.php');
        #
        # Create append data for previous and next page links
        #
        $this->targetappend .= "&firstname_too={$firstname_too}&origin={$origin}";
        //echo $mode;
        if ($parent_admit) {
            $bgimg = 'tableHeaderbg3.gif';
        } else {
            $bgimg = 'tableHeader_gr.gif';
        }
        $tbg = 'background="' . $root_path . 'gui/img/common/' . $theme_com_icon . '/' . $bgimg . '"';
        if ($mode == 'search' || $mode == 'paginate') {
            if ($linecount) {
                $this->smarty->assign('LDSearchFound', str_replace("~nr~", $totalcount, $LDSearchFound) . ' ' . $LDShowing . ' ' . $pagen->BlockStartNr() . ' ' . $LDTo . ' ' . $pagen->BlockEndNr() . '.');
            } else {
                $this->smarty->assign('LDSearchFound', str_replace('~nr~', '0', $LDSearchFound));
            }
        }
        if ($linecount) {
            $this->smarty->assign('bShowResult', TRUE);
            $img_male = createComIcon($root_path, 'spm.gif', '0');
            $img_female = createComIcon($root_path, 'spf.gif', '0');
            $this->smarty->assign('LDRegistryNr', $pagen->makeSortLink($LDRegistryNr, 'pid', $oitem, $odir, $this->targetappend));
            $this->smarty->assign('LDSex', $pagen->makeSortLink($LDSex, 'sex', $oitem, $odir, $this->targetappend));
            $this->smarty->assign('LDLastName', $pagen->makeSortLink($LDLastName, 'name_last', $oitem, $odir, $this->targetappend));
            $this->smarty->assign('LDFirstName', $pagen->makeSortLink($LDFirstName, 'name_first', $oitem, $odir, $this->targetappend));
            $this->smarty->assign('LDBday', $pagen->makeSortLink($LDBday, 'date_birth', $oitem, $odir, $this->targetappend));
            $this->smarty->assign('LDZipCode', $pagen->makeSortLink($LDZipCode, 'addr_zip', $oitem, $odir, $this->targetappend));
            if (!empty($this->targetfile)) {
                $this->smarty->assign('LDOptions', $LDOptions);
            }
            #
            # Generate the resulting list rows using the reg_search_list_row.tpl template
            #
            $sTemp = '';
            $toggle = 0;
            while ($zeile = $ergebnis->FetchRow()) {
                if ($zeile['status'] == '' || $zeile['status'] == 'normal') {
                    $this->smarty->assign('toggle', $toggle);
                    $toggle = !$toggle;
                    $this->smarty->assign('sRegistryNr', $zeile['pid']);
                    switch (strtolower($zeile['sex'])) {
                        case 'f':
                            $this->smarty->assign('sSex', '<img ' . $img_female . '>');
                            break;
                        case 'm':
                            $this->smarty->assign('sSex', '<img ' . $img_male . '>');
                            break;
                        default:
                            $this->smarty->assign('sSex', '&nbsp;');
                            break;
                    }
                    $this->smarty->assign('sLastName', ucfirst($zeile['name_last']));
                    $this->smarty->assign('sFirstName', ucfirst($zeile['name_first']));
                    #
                    # If person is dead show a black cross
                    #
                    if ($zeile['death_date'] && $zeile['death_date'] != $dbf_nodate) {
                        $this->smarty->assign('sCrossIcon', '<img ' . createComIcon($root_path, 'blackcross_sm.gif', '0', 'absmiddle') . '>');
                    } else {
                        $this->smarty->assign('sCrossIcon', '');
                    }
                    $this->smarty->assign('sBday', formatDate2Local($zeile['date_birth'], $date_format));
                    $this->smarty->assign('sZipCode', $zeile['addr_zip']);
                    if ($withtarget) {
                        $sTarget = "<a href=\"{$this->targetfile}" . URL_APPEND . "&pid=" . $zeile['pid'] . "&edit=1&status=" . $status . "&target=" . $target . "&user_origin=" . $user_origin . "&noresize=1&mode=\">";
                        $sTarget = $sTarget . '<img ' . createLDImgSrc($root_path, 'ok_small.gif', '0') . ' title="' . $LDShowDetails . '"></a>';
                        $this->smarty->assign('sOptions', $sTarget);
                    }
                    if (!file_exists($root_path . 'cache/barcodes/pn_' . $zeile['pid'] . '.png')) {
                        $this->smarty->assign('sHiddenBarcode', "<img src='" . $root_path . "classes/barcode/image.php?code=" . $zeile['pid'] . "&style=68&type=I25&width=180&height=50&xres=2&font=5&label=2' border=0 width=0 height=0>");
                    }
                    #
                    # Generate the row in buffer and append as string
                    #
                    ob_start();
                    $this->smarty->display('registration_admission/reg_search_list_row.tpl');
                    $sTemp = $sTemp . ob_get_contents();
                    ob_end_clean();
                }
            }
            #
            # Assign the rows string to template
            #
            $this->smarty->assign('sResultListRows', $sTemp);
            $this->smarty->assign('sPreviousPage', $pagen->makePrevLink($LDPrevious, $this->targetappend));
            $this->smarty->assign('sNextPage', $pagen->makeNextLink($LDNext, $this->targetappend));
        }
        #
        # Add eventual appending text block
        #
        if (!empty($this->posttext)) {
            $this->smarty->assign('sPostText', $this->posttext);
        }
        #
        # Displays the search page
        #
        if ($this->bReturnOnly) {
            ob_start();
            $this->smarty->display('registration_admission/reg_search_main.tpl');
            $sTemp = ob_get_contents();
            ob_end_clean();
            return $sTemp;
        } else {
            # show Template
            $this->smarty->display('registration_admission/reg_search_main.tpl');
        }
    }
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/
define('LANG_FILE', 'doctors.php');
define('NO_2LEVEL_CHK', 1);
require_once $root_path . 'include/inc_front_chain_lang.php';
require_once $root_path . 'include/care_api_classes/class_personell.php';
$pers_obj = new Personell();
$person =& $pers_obj->getPersonellInfo($nr);
require_once $root_path . 'include/care_api_classes/class_department.php';
$dept_obj = new Department();
$dept =& $dept_obj->getPhoneInfo($dept_nr);
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('person_%');
/* Check whether config foto path exists, else use default path */
$default_photo_path = 'fotos/registration';
$photo_filename = $person['photo_filename'];
$photo_path = is_dir($root_path . $GLOBAL_CONFIG['person_foto_path']) ? $GLOBAL_CONFIG['person_foto_path'] : $default_photo_path;
require_once $root_path . 'include/inc_photo_filename_resolve.php';
html_rtl($lang);
?>
<HEAD>
<?php 
echo setCharSet();
?>
<TITLE><?php 
echo $LDInfo4Duty;
?>
</TITLE>
示例#28
0
//$theme_control='aqua'; // Temporary initial theme
//$theme_control=$GLOBAL_CONFIG['theme_control_buttons'];
//$theme_com_icon='default'; // Temporary initial theme
//$theme_com_icon='winter_jelias'; // Temporary initial theme
//$theme_logo='default';
$theme_logo = 'lopo';
// The logo theme
# Create global config object
if (!isset($GLOBAL_CONFIG) || !is_array($GLOBAL_CONFIG)) {
    $GLOBAL_CONFIG = array();
}
require_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$gc = new GlobalConfig($GLOBAL_CONFIG);
# Set the control buttons theme
if (!isset($cfg['control_buttons']) || empty($cfg['control_buttons'])) {
    $gc->getConfig('theme_control_buttons');
    if (!isset($GLOBAL_CONFIG['theme_control_buttons']) || empty($GLOBAL_CONFIG['theme_control_buttons'])) {
        $theme_control = 'default';
        // this is the last default theme if the global item is not available, change this to the desired mascot theme
    } else {
        $theme_control = $GLOBAL_CONFIG['theme_control_buttons'];
    }
} else {
    $theme_control = $cfg['control_buttons'];
}
# Set the mascot theme
if (!isset($cfg['mascot']) || empty($cfg['mascot'])) {
    $gc->getConfig('theme_mascot');
    if (!isset($GLOBAL_CONFIG['theme_mascot']) || empty($GLOBAL_CONFIG['theme_mascot'])) {
        $theme_mascot = 'default';
        // this is the last default theme if the global item is not available, change this to the desired mascot theme
$z = SIGNAL_COLOR_LEVEL_ZERO;
/* Retrieve the SIGNAL_COLOR_LEVEL_FULL = for convenience purposes */
$f = SIGNAL_COLOR_LEVEL_FULL;
$_SESSION['sess_user_origin'] = 'nursing';
/* Create department object and load all medical depts */
require_once $root_path . 'include/care_api_classes/class_department.php';
$dept_obj = new Department();
$medical_depts = $dept_obj->getAllMedical();
/* Create encounter object */
require_once $root_path . 'include/care_api_classes/class_encounter.php';
$enc_obj = new Encounter();
/* Load global configs */
include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
$GLOBAL_CONFIG = array();
$glob_obj = new GlobalConfig($GLOBAL_CONFIG);
$glob_obj->getConfig('patient_%');
$_SESSION['logID'] = $_SESSION['sess_user_name'];
function Spacer()
{
    /*?>
    <TR bgColor=#dddddd height=1>
                    <TD colSpan=3><IMG height=1
                      src="../../gui/img/common/default/pixel.gif"
                      width=5></TD></TR>
    <?php
    */
}
/* Establish db connection */
if (!isset($db) || !$db) {
    include $root_path . 'include/inc_db_makelink.php';
}
    $user = new UserConfig();
    if ($user->getConfig($_COOKIE['ck_config'])) {
        $config =& $user->getConfigData();
        $config = array_merge($config, $config_new);
        if ($user->saveConfig($_COOKIE['ck_config'], $config)) {
            header('location:' . basename(__FILE__) . URL_REDIRECT_APPEND . '&saved=1');
            exit;
        }
    }
} elseif (!isset($cfg['mainmenu_tree']) || empty($cfg['mainmenu_tree'])) {
    if (!isset($GLOBAL_CONFIG)) {
        $GLOBAL_CONFIG = array();
    }
    include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
    $gc = new GlobalConfig($GLOBAL_CONFIG);
    $gc->getConfig('theme_mainmenu_tree');
    if (!empty($GLOBAL_CONFIG['theme_mainmenu_tree'])) {
        $cfg['mainmenu_tree'] = $GLOBAL_CONFIG['theme_mainmenu_tree'];
    } else {
        $cfg['mainmenu_tree'] = 'default';
    }
}
# Start Smarty templating here
/**
 * LOAD Smarty
 */
# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
require_once $root_path . 'gui/smarty_template/smarty_care.class.php';
$smarty = new smarty_care('common');
# Toolbar title