function showMdlCol($authorise, $blnFlag)
{
    if ($authorise == "GMO" || $authorise == "ADMIN" || $authorise == "DAO") {
        $intCount = 0;
        $resultdist = mysql_query("select * from district") or die(mysql_error());
        while ($rowdist = mysql_fetch_array($resultdist)) {
            $arrDistrict[$intCount] = $rowdist['name'];
            $arrDistrictId[$intCount] = $rowdist['districtid'];
            $intCount++;
        }
        $intCount = 0;
        $resultDis = mysql_query("select * from disease") or die(mysql_error());
        while ($rowDis = mysql_fetch_array($resultDis)) {
            $arrDisease[$intCount] = $rowDis['name'];
            $arrDiseaseId[$intCount] = $rowDis['diseaseid'];
            $intCount++;
        }
        $strId = "";
        $intReportedNo = "";
        $intFatalNo = "";
        if ($blnFlag == 'false' || $blnFlag == 'phpValidError') {
            $intDistrictId = trim($_POST['cmbDistrict']);
            $intDiseaseId = trim($_POST['cmbDisease']);
            $intReportedNo = trim($_POST['txtReportedNo']);
            $intFatalNo = trim($_POST['txtFatalNo']);
        }
        if (isset($_GET['intBulkCaseId'])) {
            $strId = "edit";
            $intBulkCaseId = $_GET['intBulkCaseId'];
            $resultCase = mysql_query("SELECT * FROM bulkcase where bulkcaseid='{$intBulkCaseId}' ") or die(mysql_error());
            $rowCase = mysql_fetch_array($resultCase);
            $intDistrictId = $rowCase['districtid'];
            $intDiseaseId = $rowCase['diseaseid'];
            $intReportedNo = $rowCase['reportedcase'];
            $intFatalNo = $rowCase['fatalcase'];
            $dteCreatedon = getDateFromDb($rowCase['createdon']);
        } else {
            if (isset($_GET['intBulkCaseViewId'])) {
                $strId = "view";
                $intBulkCaseId = $_GET['intBulkCaseViewId'];
                $resultCase = mysql_query("SELECT * FROM bulkcase where bulkcaseid='{$intBulkCaseId}' ") or die(mysql_error());
                $rowCase = mysql_fetch_array($resultCase);
                $intDistrictId = $rowCase['districtid'];
                $intDiseaseId = $rowCase['diseaseid'];
                $intReportedNo = $rowCase['reportedcase'];
                $intFatalNo = $rowCase['fatalcase'];
                $dteCreatedon = getDateFromDb($rowCase['createdon']);
            } else {
                $strId = "add";
            }
        }
        if ($blnFlag == 'success') {
            echo '<h3>Updated Successfully</h3>';
        } else {
            getLastUrl();
            $lastUrl = $_SESSION['lastUrl'];
            echo '<table class="tblForm">
				<tr>
					<td>';
            if ($strId == "view") {
                echo '<h3>View Bulk Case Reports</h3>';
            } else {
                if ($strId == "edit") {
                    echo '<h3>Edit View Bulk Case Reports</h3>';
                } else {
                    echo '<h3>Add Bulk Case Reports</h3>';
                }
            }
            echo '</td>
				</tr>
				<tr>
					<td>';
            if ($strId != "view") {
                echo '<i> ( Fields marked with * are compulsary. )</i>';
            }
            echo '<form action="./addbulkcasereport.php"
										 name="addBulkCase" id="addBulkCase"
										 onsubmit="javascript:return validateAddBulkForm()" method="POST">
							<table class="formTab">
								<tr>
									<td class="formLabel">
										District';
            if ($strId != "view") {
                echo ' *';
            }
            echo '	</td>
									<td class="formContent">';
            if ($strId == "view") {
                for ($intCount = 0; $intCount < count($arrDistrictId); $intCount++) {
                    if ($arrDistrictId[$intCount] == $intDistrictId) {
                        $districtName = $arrDistrict[$intCount];
                        break;
                    }
                }
                echo ' : ' . $districtName;
            } else {
                echo '<select name="cmpDistrict" id="cmpDistrict">
												<option selected value="select">--select--</option>';
                for ($intCount = 0; $intCount < count($arrDistrictId); $intCount++) {
                    if ($arrDistrictId[$intCount] == $intDistrictId) {
                        echo '<option selected	value="' . $arrDistrictId[$intCount] . '">' . $arrDistrict[$intCount] . '</option>';
                    } else {
                        echo '<option value="' . $arrDistrictId[$intCount] . '">' . $arrDistrict[$intCount] . '</option>';
                    }
                }
                echo '</select>
											<br>
											<div class="dsplyWarning" id="errDistrict">
											</div>';
            }
            echo '</td>
								</tr>
								<tr>
									<td class="formLabel">
										Disease';
            if ($strId != "view") {
                echo ' *';
            }
            echo '	</td>
									<td class="formContent">';
            if ($strId == "view") {
                for ($intCount = 0; $intCount < count($arrDiseaseId); $intCount++) {
                    if ($arrDiseaseId[$intCount] == $intDiseaseId) {
                        $diseaseName = $arrDisease[$intCount];
                        break;
                    }
                }
                echo ' : ' . $diseaseName;
            } else {
                echo '<select name="cmpDisease" id="cmpDisease">
												<option selected value="select">--select--</option>';
                for ($intCount = 0; $intCount < count($arrDiseaseId); $intCount++) {
                    if ($arrDiseaseId[$intCount] == $intDiseaseId) {
                        echo '<option selected	value="' . $arrDiseaseId[$intCount] . '">' . $arrDisease[$intCount] . '</option>';
                    } else {
                        echo '<option value="' . $arrDiseaseId[$intCount] . '">' . $arrDisease[$intCount] . '</option>';
                    }
                }
                echo '</select>
											<br>
											<div class="dsplyWarning" id="errDisease">
											</div>';
            }
            echo '</td>
								</tr>
								<tr>
									<td class="formLabel">
										Reported cases';
            if ($strId != "view") {
                echo ' *';
            }
            echo '</td>
									<td class="formContent">';
            if ($strId == "view") {
                echo ': ' . $intReportedNo;
            } else {
                echo '<input type="text" name="txtReportedNo" id="txtReportedNo"
															maxlength="6" value="' . $intReportedNo . '" >';
            }
            if ($strId != "view") {
                echo '<br><i> ( Enter the total number of reported cases. )
											</i>';
            }
            echo '<br>
										 <div class="dsplyWarning" id="errReportedNo">
										 </div>
									</td>
								</tr>
								<tr>
									<td class="formLabel">
										Fatal cases
									</td>
									<td class="formContent">';
            if ($strId == "view") {
                echo ': ' . $intFatalNo;
            } else {
                echo '<input type="text" name="txtFatalNo" id="txtFatalNo"
															maxlength="6" value="' . $intFatalNo . '" >';
            }
            if ($strId != "view") {
                echo '<br><i> ( Enter the number of fatal cases in the reported cases. )
											</i>';
            }
            echo '<br>
										 <div class="dsplyWarning" id="errFatalNo">
										 </div>
									</td>
								</tr>';
            if ($strId == "view" || $strId == "edit") {
                echo '<tr>
										<td class="formLabel">
											Created Date
										</td>
										<td class="formContent">';
                if ($strId == "view") {
                    echo ': ' . $dteCreatedon;
                } else {
                    echo '<input class="noBrdrInput" READONLY type="text"
													value="' . $dteCreatedon . '" >';
                }
                echo '</td>
									</tr>';
            }
            echo '<tr>
									<td>
										<input type="hidden" name="txtId" id="txtId" value="' . $strId . '" >';
            if ($strId == 'edit') {
                echo '<input type="hidden" name="txtBulkCaseId"   id="txtBulkCaseId"
																value="' . $intBulkCaseId . '" >';
            }
            echo '</td>
									<td>';
            if ($strId == 'add') {
                echo '<br>
											<input class="subButton" type="submit" value="Submit" name="Submit">
											&nbsp;&nbsp;
											<input class="backButton" type="button" value="Cancel" name="Back"
												onclick="javascript:changePage()">';
            } else {
                if ($strId == 'edit') {
                    echo '<br>
											<input class="subButton" type="submit" value="Submit" name="Submit">
											&nbsp;&nbsp;';
                    echo '<input class="backButton" type="button" value="Back" name="Back"
													onclick="javascript:changeViewPage(\'' . $lastUrl . '\')">';
                } else {
                    if ($strId == 'view') {
                        echo '<input class="backButton" type="button" value="Back" name="Back"
												onclick="javascript:changeViewPage(\'' . $lastUrl . '\')">';
                    } else {
                    }
                }
            }
            echo '</td>
								</tr>
								<tr>
									<td colspan="2">';
            if ($blnFlag == 'true') {
                echo '<h3>Case reports Saved Successfully</h3>';
            } else {
                if ($blnFlag == 'success') {
                    echo '<h3>Case reports Updated Successfully</h3>';
                } else {
                    if ($blnFlag == 'phpValidError') {
                        echo '<h3>Error in given details.Check whether javascript is enabled or check whether you have entered valid details</h3>';
                    } else {
                    }
                }
            }
            echo '</td>
								</tr>
							</table>
						</form>
					</td>
				</tr>
			</table>';
        }
    } else {
        echo '<h3>No data is stored in the database or you are not authorised to view this data
					</h3>';
    }
}
function showMdlCol($UserType, $flag)
{
    $arrFatal = array("Fatal", "Admitted");
    $intCount = 0;
    $Eresult = mysql_query("select * from disease") or die(mysql_error());
    while ($erow = mysql_fetch_array($Eresult)) {
        $content = $erow['name'];
        $countid = $erow['diseaseid'];
        $arrDisease[$intCount] = $content;
        $arrDiseaseId[$intCount] = $countid;
        $intCount++;
    }
    $intCount = 0;
    $Dresult = mysql_query("select * from district") or die(mysql_error());
    while ($drow = mysql_fetch_array($Dresult)) {
        $content = $drow['name'];
        $countid = $drow['districtid'];
        $arrDistrict[$intCount] = $content;
        $arrDistrictId[$intCount] = $countid;
        $intCount++;
    }
    if ($UserType == "DAO" || $UserType == "GMO" || $UserType == "ADMIN" || $UserType == "HOSPITAL") {
        getLastUrl();
        $lastUrl = $_SESSION['lastUrl'];
        $id = "";
        $arrCaseStatus = array("Admitted", "Fatal");
        $caseId = "";
        $caseName = "";
        $caseAge = "";
        $caseSex = "";
        $caseAddress1 = "";
        $caseAddress2 = "";
        $casePincode = "";
        $caseHospitalId = "";
        $caseDisease = "";
        $caseDiseaseId = "";
        $caseDistrictId = "";
        $caseFatal = "";
        $caseReportedOn = "";
        $caseDiedOn = "";
        $caseDate = "";
        $hId = "";
        $hName = "";
        if ($flag == 'false' || $flag == 'phpValidError') {
            $caseName = $_POST['txtName'];
            $caseAge = $_POST['txtAge'];
            $caseSex = $_POST['rdoSex'];
            $caseAddress1 = $_POST['txtAddress1'];
            $caseAddress2 = $_POST['txtAddress2'];
            $casePincode = $_POST['txtPincode'];
            $caseHospitalId = $_POST['cmbHospital'];
            $caseDistrictId = $_POST['cmbDistrict'];
            $caseDisease = $_POST['cmbDisease'];
            $casefatal = $_POST['cmbFatal'];
            $caseReportedOn = $_POST['txtReportedOn'];
            $caseDiedOn = $_POST['txtDiedOn'];
            $caseDate = $_POST['txtCaseDate'];
        }
        /* check for edit page.Edit option is shown */
        if (isset($_GET['casereportid'])) {
            $id = "edit";
            $caseId = $_GET['casereportid'];
            $resultCaseReport = mysql_query("SELECT * FROM casereport where\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcasereportid='{$caseId}'") or die(mysql_error());
            $rowCaseReport = mysql_fetch_array($resultCaseReport);
            $caseName = $rowCaseReport['name'];
            $caseAge = $rowCaseReport['age'];
            $caseSex = $rowCaseReport['sex'];
            $caseAddress1 = $rowCaseReport['address1'];
            $caseAddress2 = $rowCaseReport['address2'];
            $casePincode = $rowCaseReport['pincode'];
            $caseDiseaseId = $rowCaseReport['diseaseid'];
            $caseDistrictId = $rowCaseReport['districtid'];
            $caseHospitalId = $rowCaseReport['hospitalid'];
            $casePostOfficeId = $rowCaseReport['postofficeid'];
            $caseFatal = $rowCaseReport['fatal'];
            $caseReportedOn = getDateFromDb($rowCaseReport['reportedon']);
            if ($rowCaseReport['diedon'] == "") {
                $caseDiedOn = " ";
            } else {
                $caseDiedOn = getDateFromDb($rowCaseReport['diedon']);
            }
            $caseDate = getDateFromDb($rowCaseReport['casedate']);
        } else {
            $id = "add";
        }
        if ($flag == 'success') {
            echo '<h3>Updated Successfully</h3>';
        } else {
            echo "\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td >";
            if ($id == "edit") {
                echo "<h3>Edit Case Report</h3>";
            } else {
                echo "<h3>Add Case Report</h3>";
            }
            echo "\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<i> ( Fields marked with * are compulsary. )</i>\n\t\t\t\t\t\t<form   action=\"addcasereport.php\"\n\t\t\t\t\t\t\tonsubmit=\"javascript:return validateCaseReportForm('" . $UserType . "','" . $id . "')\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t    method=\"POST\">\n\t\t\t\t\t\t\t<table class=\"formTab\">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\t\t\tName of Patient *\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t  <input type=\"text\" name=\"txtName\" id=\"txtName\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"50\" value='" . $caseName . "' />\n\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t <i> ( Enter name of the patient. )</i>\n\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errName\">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\t\tAge *\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t  <input type=\"text\" name=\"txtAge\" id=\"txtAge\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"3\" value='" . $caseAge . "' />\n\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errAge\">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\t\tSex *\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td class=\"formContent\">";
            if ($caseSex == "Female") {
                echo "<input type=\"radio\" name=\"rdoSex\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"Male\" />\tMale\n\t\t\t\t\t\t\t\t\t  <input type=\"radio\" name=\"rdoSex\" id=\"rdoSex\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"Female\" checked=\"checked\" />\tFemale";
            } else {
                echo " <input type=\"radio\" name=\"rdoSex\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"Male\" checked=\"checked\" />\tMale\n\t\t\t\t\t\t\t\t\t  <input type=\"radio\" name=\"rdoSex\" id=\"rdoSex\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue=\"Female\" />\tFemale";
            }
            echo "\t<br>\n\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errSex\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tAddress1 *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t  <input type=\"text\" name=\"txtAddress1\" id=\"txtAddress1\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"100\" value='" . $caseAddress1 . "' />\n\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t <i> ( Enter address of the patient. )</i>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errAddress1\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tAddress2\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t  <input type=\"text\" name=\"txtAddress2\" id=\"txtAddress2\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"100\" value='" . $caseAddress2 . "' />\n\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errAddress2\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tDistrict *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t<select name=\"cmbDistrict\" id=\"cmbDistrict\"\n\t\t\t\t\t\t\t\t\t\t\t\tonchange=\"javascript:selectPostOffice(this)\" >\n\t\t\t\t\t\t\t\t\t<option selected value=\"select\">--select--</option>";
            for ($intCount = 0; $intCount < count($arrDistrictId); $intCount++) {
                if ($arrDistrictId[$intCount] == $caseDistrictId) {
                    echo '<option selected	value="' . $arrDistrictId[$intCount] . '">' . $arrDistrict[$intCount] . '</option>';
                } else {
                    echo '<option value="' . $arrDistrictId[$intCount] . '">' . $arrDistrict[$intCount] . '</option>';
                }
            }
            echo "\t\t</select>\n\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t <i> ( Select district of the patient. )</i>\n\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errDistrict\">\n\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tPost Office *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\" id=\"postOfficeId\">\n\t\t\t\t\t\t\t\t<select name=\"cmbPostOffice\" id=\"cmbPostOffice\" >\n\t\t\t\t\t\t\t\t\t<option value=\"select\">--select--</option>";
            if ($id == "edit") {
                $resultPO = mysql_query("select name from postoffice\n\t\t\t\t\t\t\t\t\t\twhere postofficeid='" . $casePostOfficeId . "' ") or die(mysql_error());
                $rowPO = mysql_fetch_array($resultPO);
                echo '<option selected value="' . $casePostOfficeId . '">
											' . $rowPO['name'] . '</option>';
            }
            echo "</select>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <i> ( Select post office of the patient. )</i>\n\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errPostOffice\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class= \"hideTr\" id=\"newPostOfficeTr\">\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tSpecify the Post office name\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\" >\n\t\t\t\t\t\t\t  <input type=\"text\" name=\"txtNewPostOffice\"\n\t\t\t\t\t\t\t\t\t\tid=\"txtNewPostOffice\"/>\n\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errNewPostOffice\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class= \"hideTr\" id=\"nearPostOfficeTr\">\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tNear Post Office\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\" id=\"NearpostOfficeId\">\n\t\t\t\t\t\t\t\t<select name=\"cmbNearPostOffice\" id=\"cmbNearPostOffice\">\n\t\t\t\t\t\t\t\t\t<option value=\"select\">--select--</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tPincode\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"txtPincode\" id=\"txtPincode\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"6\" value='" . $casePincode . "' />\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errPincode\">\n\t\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tHospital *\n\t\t\t\t\t\t\t</td>";
            if ($UserType == "HOSPITAL") {
                $username = $_SESSION['userName'];
                $result = mysql_query("SELECT name,hospitalid FROM hospital WHERE\n\t\t\t\t\t\t\t\t\t\t\tusername='******' ") or die(mysql_error());
                $row = mysql_fetch_array($result);
                $hName = $row['name'];
                $hId = $row['hospitalid'];
                echo "<td class=\"formContent\">";
                if ($id == "edit") {
                    echo "<input class=\"noBrdrInput\" type=\"text\" readonly\n\t\t\t\t\t\t\t\t\t\t\t\t name=\"txtHospital\"\tid=\"txtHospital\" value='" . $hName . "'/>";
                } else {
                    echo "<input class=\"noBrdrInput\" type=\"text\" readonly\n\t\t\t\t\t\t\t\t\t\t\t\t name=\"txtHospital\" id=\"txtHospital\" value='" . $hName . "'/>";
                }
                echo "<input type=\"hidden\" name=\"cmbHospital\" id=\"cmbHospital\"\n\t\t\t\t\t\t\t\t\t\t value='" . $hId . "' />\n\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errHospital\">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</td>";
            } else {
                if ($UserType == "GMO" || $UserType == "DAO" || $UserType == "ADMIN") {
                    $username = $_SESSION['userName'];
                    if ($UserType == "GMO") {
                        $resultGmo = mysql_query("select districtid from gmo\n\t\t\t\t\t\t\t\t\t\twhere username='******' ") or die(mysql_error());
                        $rowGmo = mysql_fetch_array($resultGmo);
                        $distId = $rowGmo['districtid'];
                        $result = mysql_query("SELECT hospital.name, hospital.hospitalid,\n\t\t\t\t\t\t\t\t\t\thospital.districtid ,user.status\n\t\t\t\t\t\t\t\t\t\tFROM hospital\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN user on  hospital.username= user.username\n\t\t\t\t\t\t\t\t\t\tWHERE\thospital.districtid='" . $distId . "'\n\t\t\t\t\t\t\t\t\t\t\t\tand user.status ='Approved'") or die(mysql_error());
                    } else {
                        if ($UserType == "DAO") {
                            $resultDao = mysql_query("select districtid from dao\n\t\t\t\t\t\t\t\t\t\twhere username='******' ") or die(mysql_error());
                            $rowDao = mysql_fetch_array($resultDao);
                            $distId = $rowDao['districtid'];
                            $result = mysql_query("SELECT hospital.name, hospital.hospitalid,\n\t\t\t\t\t\t\t\t\t\thospital.districtid, user.status\n\t\t\t\t\t\t\t\t\t\tFROM hospital\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN user on  hospital.username= user.username\n\t\t\t\t\t\t\t\t\t\tWHERE\thospital.districtid='" . $distId . "'\n\t\t\t\t\t\t\t\t\t\t\tand user.status ='Approved'") or die(mysql_error());
                        } else {
                            if ($UserType == "ADMIN") {
                                $result = mysql_query("SELECT hospital.name, hospital.hospitalid,\n\t\t\t\t\t\t\t\t\t\thospital.districtid\tFROM hospital\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN user on  hospital.username= user.username\n\t\t\t\t\t\t\t\t\t\tWHERE\tuser.status ='Approved'") or die(mysql_error());
                            } else {
                            }
                        }
                    }
                    $intcount = 0;
                    while ($crow = mysql_fetch_array($result)) {
                        $arrHospital[$intcount] = $crow['name'];
                        $arrHospitalId[$intcount] = $crow['hospitalid'];
                        $intcount++;
                    }
                    echo "<td class=\"formContent\" id=\"hospitalId\" >\n\t\t\t\t\t\t\t\t\t<select name=\"cmbHospital\" id=\"cmbHospital\" >\n\t\t\t\t\t\t\t\t\t\t<option selected value=\"select\">--select--</option>";
                    for ($intCount = 0; $intCount < count($arrHospitalId); $intCount++) {
                        if ($arrHospitalId[$intCount] == $caseHospitalId) {
                            echo '<option selected	value="' . $arrHospitalId[$intCount] . '">' . $arrHospital[$intCount] . '</option>';
                        } else {
                            echo '<option value="' . $arrHospitalId[$intCount] . '">' . $arrHospital[$intCount] . '</option>';
                        }
                    }
                    echo "</select>\n\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t<div class=\"dsplyWarning\" id=\"errHospital\">\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</td>";
                } else {
                    echo "\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t</td>";
                }
            }
            echo "</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tDisease *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t<select name=\"cmbDisease\" id=\"cmbDisease\" >\n\t\t\t\t\t\t\t\t\t<option selected value=\"select\">--select--</option>";
            for ($intCount = 0; $intCount < count($arrDiseaseId); $intCount++) {
                if ($arrDiseaseId[$intCount] == $caseDiseaseId) {
                    echo '<option selected	value="' . $arrDiseaseId[$intCount] . '">' . $arrDisease[$intCount] . '</option>';
                } else {
                    echo '<option value="' . $arrDiseaseId[$intCount] . '">' . $arrDisease[$intCount] . '</option>';
                }
            }
            echo "\t</select>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errDisease\">\n\t\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tStatus *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t<select name=\"cmbFatal\" id=\"cmbFatal\" >\n\t\t\t\t\t\t\t\t\t<option selected value=\"select\">--select--</option>";
            for ($intCount = 0; $intCount < count($arrFatal); $intCount++) {
                if ($arrFatal[$intCount] == $caseFatal) {
                    echo '<option selected	value="' . $arrFatal[$intCount] . '">' . $arrFatal[$intCount] . '</option>';
                } else {
                    echo '<option value="' . $arrFatal[$intCount] . '">' . $arrFatal[$intCount] . '</option>';
                }
            }
            echo "</select>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errFatal\">\n\t\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\tDied on\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"txtDiedOn\" id=\"txtDiedOn\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"10\" value='" . $caseDiedOn . "' />(DD/MM/YYYY)<br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errDiedOn\">\n\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tCase Date *\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"txtCaseDate\" id=\"txtCaseDate\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"10\" value='" . $caseDate . "' />(DD/MM/YYYY)<br>\n\t\t\t\t\t\t\t\t <i> ( Date on which patient started showing symptoms. )</i>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errCaseDate\">\n\t\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tReported on *\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t <input type=\"text\" name=\"txtReportedOn\" id=\"txtReportedOn\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tmaxlength=\"10\" value='" . $caseReportedOn . "' />(DD/MM/YYYY)\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <i> ( Date on which case was reported to the authorities. )</i>\n\t\t\t\t\t\t\t\t <br>\n\t\t\t\t\t\t\t\t <div class=\"dsplyWarning\" id=\"errReportedOn\">\n\t\t\t \t\t\t\t\t </div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<input \ttype=\"hidden\" name=\"Id\" id=\"txtId\" value='" . $id . "'>";
            if ($id == 'edit') {
                echo '<input type="hidden" name="txtCaseId"   id="txtCaseId"
															value=' . $caseId . '>';
            } else {
            }
            echo "\t</td>\n\t\t\t\t\t\t\t<td>";
            if ($id == "edit") {
                echo "<br>\n\t\t\t\t\t\t\t\t<input class=\"subButton\" type=\"submit\" value=\"Submit\" name=\"Submit\" />\n\t\t\t\t\t\t\t\t&nbsp;&nbsp;\n\t\t\t\t\t\t\t\t<input class=\"backButton\" type=\"button\" value=\"Back\" name=\"Back\"\n\t\t\t\t\t\t\t\t\t\t\tonclick=\"javascript:changeViewPage('" . $lastUrl . "')\">";
            } else {
                echo "<br>\n\t\t\t\t\t\t\t\t<input class=\"subButton\" type=\"submit\" value=\"Submit\" name=\"Submit\" />\n\t\t\t\t\t\t\t\t&nbsp;&nbsp;\n\t\t\t\t\t\t\t\t<input class=\"backButton\" type=\"button\" value=\"Cancel\" name=\"Back\"\n\t\t\t\t\t\t\t\t\t\t\tonclick=\"javascript:changePage()\">";
            }
            echo "\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">";
            if ($flag == 'true') {
                echo '<h3>Saved Successfully</h3>';
            } else {
                if ($flag == 'false') {
                    echo '<h3>Case already Reported</h3>';
                } else {
                    if ($flag == 'phpValidError') {
                        echo '<h3>Error in given details.Check whether javascript is enabled or check whether you have entered valid details</h3>';
                    } else {
                    }
                }
            }
            echo "\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t</form>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>";
        }
    } else {
        echo '<h3>No data is stored in the database or you are not authorised to view this data</h3>';
    }
}
function showMdlCol($UserType)
{
    if ($UserType == "DAO" || $UserType == "GMO" || $UserType == "HOSPITAL" || $UserType == "ADMIN") {
        getLastUrl();
        $lastUrl = $_SESSION['lastUrl'];
        $id = $_GET['caseid'];
        $result = mysql_query("SELECT hospital.name as hname, district.name as \n\t\t\tdistname, postoffice.name as pname, disease.name as dname, fatal, reportedon, \n\t\t\tdiedon, casedate, casereport.name as cname, age, sex, address1, address2, \n\t\t\tcasereport.pincode, createdon    \n\t\t\tFROM casereport\n\t\t\tLEFT JOIN district on casereport.districtid = district.districtid\n\t\t\tLEFT JOIN hospital on casereport.hospitalid = hospital.hospitalid\n\t\t\tLEFT JOIN postoffice on casereport.postofficeid = postoffice.postofficeid\n\t\t\tLEFT JOIN disease on casereport.diseaseid = disease.diseaseid\n\t\t\tWHERE casereportid='{$id}' ") or die(mysql_error());
        $row = mysql_fetch_array($result);
        echo "\t<table>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<h3> View Case Report</h3>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<table>\t\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\t\tName of Patient\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t:\t" . $row['cname'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tAge\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['age'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tSex\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['sex'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tAddress1\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['address1'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tAddress2\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['address2'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tDistrict\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['distname'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tPost Office\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['pname'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tPincode\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['pincode'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tHospital\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\" >\n\t\t\t\t\t\t\t\t:\t" . $row['hname'] . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tDisease\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['dname'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tStatus\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . $row['fatal'] . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tReported on\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . getDateFromDb($row['reportedon']) . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tDied on\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t: ";
        if ($row['diedon'] != "") {
            echo getDateFromDb($row['diedon']);
        } else {
            echo $row['diedon'];
        }
        echo "</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tCase Date\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . getDateFromDb($row['casedate']) . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"formLabel\">\n\t\t\t\t\t\t\t\tCreated on\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"formContent\">\n\t\t\t\t\t\t\t\t:\t" . getDateFromDb($row['createdon']) . "\n\t\t\t\t\t\t\t</td>\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>";
        echo '<input class="backButton" type="button" value="Back" name="back"
									onclick="javascript:changeViewPage(\'' . $lastUrl . '\')" />';
        echo "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\t\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>";
    } else {
        echo '<h3>You are not Authorised to view this page</h3>';
    }
}
function listCaseReport(&$authorise, &$intResultNum, &$result)
{
    $strContent = '<table class="listContentTab" id="tblList">';
    $strContent .= '<tr>
				<th class="tdBorder">District</th>
				<th class="tdBorder">Disease</th>
				<th class="tdBorder">Report cases</th>
				<th class="tdBorder">Fatal cases</th>
				<th class="tdBorder">Created Date</th>
				<th class="tdBorder">View</th>
				<th class="tdBorder">Edit</th></tr>';
    $color = "";
    while ($row = mysql_fetch_array($result)) {
        if ($color == 0) {
            $strContent .= '<tr><td class="tdContent">' . $row['distname'] . '</td>';
            $color = 1;
        } else {
            $strContent .= '<tr class="listTrColor">
				<td class="tdContent">' . $row['distname'] . '</td>';
            $color = 0;
        }
        $strContent .= '<td class="tdContent">' . $row['diseasename'] . '</td>
			<td class="tdContent">' . $row['reportedcase'] . '</td>
			<td class="tdContent">' . $row['fatalcase'] . '</td>
			<td class="tdContentImg">' . getDateFromDb($row['createdon']) . '</td>
			<td class="tdContentImg">';
        $strContent .= "<a href=\"./addbulkcasereport.php?intBulkCaseViewId=" . $row['bulkcaseid'] . "\">\n\t\t\t\t\t<img class=\"editButton\" src=\"../images/view.gif\" alt=\"View\" />\n\t\t\t\t</a></td>";
        $strContent .= "<td class=\"tdContentImg\">\n\t\t\t\t<a href=\"./addbulkcasereport.php?intBulkCaseId=" . $row['bulkcaseid'] . "\">\n\t\t\t\t\t<img class=\"editButton\" src=\"../images/edit.gif\" alt=\"Edit\" />\n\t\t\t\t</a></td></tr>";
    }
    $strContent .= '</table>';
    return $strContent;
}
function displayContent($type, $opt)
{
    $curDt = date("y/m/d");
    $curDate = explode("/", $curDt);
    $month = $curDate[1] - 1;
    $dte = 2000 + $curDate[0] . '-' . $curDate[1] . '-' . $curDate[2];
    $dts = 2000 + $curDate[0] . '-' . $month . '-' . $curDate[2];
    $startdate = $dts;
    $enddate = $dte;
    $color = 0;
    $intDiedTot = 0;
    $intAdmTot = 0;
    $diedMax = 0;
    $admMax = 0;
    $intCount1 = 0;
    $arrValues[0][0] = 0;
    $max = 0;
    if ($type == 'Summary') {
        //Getting the number of died patients for a particular disease
        $resultset = mysql_query("select districtname,sum(totaldied) as tottaldied from \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(select district.name as districtname,bulkrecord.fatalcase as totaldied from district\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(select districtid,sum(fatalcase) as fatalcase from bulkcase where createdon between \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $startdate . "' and '" . $enddate . "' \t\t\t group by districtid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as bulkrecord on district.districtid=bulkrecord.districtid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(select district.name as districtname,diedrec.diedtot as totaldied from district\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tleft join \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT count(*) as diedtot ,disease.name,casereport.districtid as distid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcasereport.fatal\tFROM disease \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tleft join \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcasereport on disease.diseaseid=casereport.diseaseid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere casereport.fatal='Fatal' and casedate between '" . $startdate . "' and '" . $enddate . "' \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgroup by districtid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as diedrec\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton district.districtid=diedrec.distid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as finalcasereport group by districtname \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
        //Getting the number of admitted patients for a particular disease
        $resultnotdied = mysql_query("select districtname,sum(totaladmitted) as totaladmitted from\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(select district.name as districtname,bulkrecord.reportedcase as \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t totaladmitted from district\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t left join\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (select districtid,sum(reportedcase) as reportedcase from bulkcase \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t where createdon between '" . $startdate . "' and '" . $enddate . "' group by districtid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) as bulkrecord on district.districtid=bulkrecord.districtid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(select district.name as districtname,diedrec.diedtot as \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotaladmitted from district\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tleft join \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT count(*) as diedtot ,disease.name,casereport.districtid as distid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcasereport.fatal\tFROM disease \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tleft join \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcasereport on disease.diseaseid=casereport.diseaseid \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere casedate between '" . $startdate . "' and '" . $enddate . "'  group by districtid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as diedrec\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ton district.districtid=diedrec.distid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as finalcasereport group by districtname \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
        $intCount = mysql_num_rows($resultset);
        if ($intCount > 0) {
            $strContent = '<h4>List of cases reported between ' . getDateFromDb($dts) . ' and ' . getDateFromDb($dte) . '</h4>';
            $strContent .= '<table class="tblContent" id="tblList">';
            $strContent .= '<tr><th class="tdBorder">District</th>';
            $strContent .= '<th class="tdBorder">Died</th>';
            $strContent .= '<th class="tdBorder">Reported</th></tr>';
            while (($row = mysql_fetch_array($resultset)) && ($row1 = mysql_fetch_array($resultnotdied))) {
                if ($color == 0) {
                    $color = 1;
                    $strClass = "class=\"trColor1\"";
                } else {
                    $color = 0;
                    $strClass = "";
                }
                $strContent .= "<tr " . $strClass . "><td class=\"tdContent\">\n\t\t\t<a href=\"#\" \n\t\t\tonclick=\"javascript:changeContentDisease('" . $row['districtname'] . "','3')\">" . $row['districtname'] . "</a></td>";
                $arrXLabels[$intCount1] = $row['districtname'];
                $strContent .= '<td class="tdContent">' . $row['tottaldied'] . '</td>';
                if ($diedMax < $row['tottaldied']) {
                    $diedMax = $row['tottaldied'];
                } else {
                }
                $strContent .= '<td class="tdContent">' . $row1['totaladmitted'] . '</td></tr>';
                if ($admMax < $row1['totaladmitted']) {
                    $admMax = $row1['totaladmitted'];
                } else {
                }
                $intDiedTot += $row['tottaldied'];
                $intAdmTot += $row1['totaladmitted'];
                $arrValues[$intCount1][$intCount1] = $row['tottaldied'];
                $arrValues[$intCount1][$intCount1 + 1] = $row1['totaladmitted'];
                $intCount1++;
            }
            $strContent .= '<tr>
										<td class="tdContent">
										</td>
										<td class="tdContent"7 >
											' . $intDiedTot . '
										</td>
										<td class="tdContent">
											' . $intAdmTot . '
										</td>
									</tr>';
            $strContent .= showGraphHeading();
            $strContent .= showColorInfo();
            $max = $diedMax > $admMax ? $diedMax : $admMax;
            //Creating graph according to the given record
            $str = createBarGraph($arrXLabels, $arrValues, $max, 'Districts');
            $strContent .= '<tr class="trGraph">
										<td colspan="3">
											' . $str . '
										</td>
									</tr>';
            //Information about the graph xcordinate values
            $strContent .= showGraphXcordinateInfo($arrXLabels);
            $strContent .= '<tr>
										<td class="tdButton" colspan="3">
											<a class="highlight" href="" 
											onclick="javascript:printPage(\'Summary\',\'1\');return false;">
												<img class="imgPrint" src="../images/printbutton.gif" 
												alt="Print">
											</a><br>
										</td>
									</tr>
								</table>';
            return $strContent;
        } else {
            return "<br><b>No records found</b>";
        }
    } else {
        if ($type == 'By Disease') {
            $dname = $opt;
            $intCount1 = 0;
            //Getting the number of died patients for a particular disease
            $resultset = mysql_query("select sum(died.totaldied) as totaldied,died.dname from\n\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t(select totaldied as totaldied,district.name as dname from district\n\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\t(select sum(fatalcase) as totaldied,districtid,disease.name from disease \n\t\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\tbulkcase on disease.diseaseid=bulkcase.diseaseid where createdon \n\t\t\t\t\t\t\t\t\tbetween '" . $startdate . "' and '" . $enddate . "'    and disease.name='" . $dname . "'\n\t\t\t\t\t\t\t\t\tgroup by districtid\n\t\t\t\t\t\t\t\t\t) as diseaserec \n\t\t\t\t\t\t\t\ton diseaserec.districtid=district.districtid\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t(select diedrec.totaldied as totaldied,district.name as dname \n\t\t\t\t\t\t\t\t from district\t\n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t (SELECT count(*) as totaldied ,disease.name,casereport.districtid as disid,\n\t\t\t\t\t\t\t\t casereport.fatal \n\t\t\t\t\t\t\t\t FROM disease \n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t casereport on disease.diseaseid=casereport.diseaseid where fatal='Fatal' and\n\t\t\t\t\t\t\t\t casedate between '" . $startdate . "' and '" . $enddate . "'  \n\t\t\t\t\t\t\t\t and disease.name='" . $dname . "'group by districtid\n\t\t\t\t         ) as diedrec on district.districtid=diedrec.disid\n                )\n\t\t\t\t\t\t\t)as died group by died.dname") or die(mysql_error());
            //Getting the number of admitted patients for a particular disease
            $resultnotdied = mysql_query("select sum(admitted.totalreported) as totalreported,admitted.dname from\n\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t(select totalreported as totalreported,district.name as dname from district\n\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\t(select sum(reportedcase) as totalreported,districtid,disease.name from disease \n\t\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\tbulkcase on disease.diseaseid=bulkcase.diseaseid where createdon \n\t\t\t\t\t\t\t\t\tbetween '" . $startdate . "' and '" . $enddate . "'  and disease.name='" . $dname . "'\n\t\t\t\t\t\t\t\t\tgroup by districtid\n\t\t\t\t\t\t\t\t\t) as diseaserec \n\t\t\t\t\t\t\t\ton diseaserec.districtid=district.districtid\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t(select admittedrec.totalreported as totalreported,district.name as dname \n\t\t\t\t\t\t\t\t from district\t\n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t (SELECT count(*) as totalreported ,disease.name,casereport.districtid as disid,\n\t\t\t\t\t\t\t\t casereport.fatal \n\t\t\t\t\t\t\t\t FROM disease \n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t casereport on disease.diseaseid=casereport.diseaseid where \n\t\t\t\t\t\t\t\t casedate between '" . $startdate . "' and '" . $enddate . "' and disease.name='" . $dname . "'group by districtid\n\t\t\t\t         ) as admittedrec on district.districtid=admittedrec.disid\n                )\n\t\t\t\t\t\t\t)as admitted group by admitted.dname\n") or die(mysql_error());
            $color = 0;
            $intCount = mysql_num_rows($resultset);
            if ($intCount > 0) {
                $strContent = '<h4>List of cases reported between ' . getDateFromDb($dts) . ' 
			and ' . getDateFromDb($dte) . ' for ' . $opt . ' </h4>';
                $strContent .= '<table id="tblList" ><tr>';
                $strContent .= '<th class="tdBorder">District</th>';
                $strContent .= '<th class="tdBorder">Died</th>';
                $strContent .= '<th class="tdBorder">Reported</th></tr>';
                while (($row = mysql_fetch_array($resultset)) && ($row1 = mysql_fetch_array($resultnotdied))) {
                    if ($color == 0) {
                        $strContent .= "<tr>";
                        $color = 1;
                    } else {
                        $strContent .= '<tr class="trColor1">';
                        $color = 0;
                    }
                    $strContent .= "<td class=\"tdContent\">\n\t\t\t\t\t" . $row['dname'] . "</td>";
                    $strContent .= '<td class="tdContent">' . $row['totaldied'] . '</td>';
                    $strContent .= '<td class="tdContent">' . $row1['totalreported'] . '</td></tr>';
                    $arrXLabels[$intCount1] = $row['dname'];
                    if ($diedMax < $row['totaldied']) {
                        $diedMax = $row['totaldied'];
                    }
                    if ($admMax < $row1['totalreported']) {
                        $admMax = $row1['totalreported'];
                    } else {
                    }
                    $intDiedTot += $row['totaldied'];
                    $intAdmTot += $row1['totalreported'];
                    $arrValues[$intCount1][$intCount1] = $row['totaldied'];
                    $arrValues[$intCount1][$intCount1 + 1] = $row1['totalreported'];
                    $intCount1++;
                }
                $strContent .= '<tr>
											<td class="tdContent">
											</td>
											<td class="tdContent">
												' . $intDiedTot . '
											</td>
											<td class="tdContent">
												' . $intAdmTot . '
											</td>
										</tr>';
                $strContent .= showGraphHeading();
                $strContent .= showColorInfo();
                $max = $diedMax > $admMax ? $diedMax : $admMax;
                //Creating graph according to the given record
                $str = createBarGraph($arrXLabels, $arrValues, $max, 'Districts');
                $strContent .= '<tr class="trGraph"><td colspan="3">' . $str . '</td></tr>';
                //Information about the graph xcordinate values
                $strContent .= showGraphXcordinateInfo($arrXLabels);
                $strContent .= '<tr>
											<td class="tdButton">
												<a href="" 
			onclick="javascript: printPage(\'By Disease\',\'' . $dname . '\');return false;">
													<img class="imgPrint" 
													src="../images/printbutton.gif" alt="Print">
												</a>
											</td>
											<td class="tdButton">
												<a href="summary.php"	target="contentFrame">
													<img class="imgBck" 
													src="../images/backbutton01.gif" alt="Back">
												</a>
											</td>
										</tr>
									</table>';
                return $strContent;
            } else {
                return "<br><b>No records found</b>";
            }
        } else {
            if ($type == 'Dist') {
                //Getting the number of died patients in the given district
                $district = $opt;
                $resultset = mysql_query("select sum(adm.diedtotal) as diedtotal,adm.dname as diseasename from\n\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t(select totaldied as diedtotal,disease.name as dname from disease\n\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\t(select sum(fatalcase) as totaldied,diseaseid,district.name from district \n\t\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\tbulkcase on district.districtid=bulkcase.districtid where createdon \n\t\t\t\t\t\t\t\t\tbetween '" . $startdate . "' and '" . $enddate . "'  and district.name='" . $district . "'\n\t\t\t\t\t\t\t\t\tgroup by diseaseid\n\t\t\t\t\t\t\t\t\t) as diseaserec \n\t\t\t\t\t\t\t\ton diseaserec.diseaseid=disease.diseaseid\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t(select diedrec.diedtot as diedtotal,disease.name as dname \n\t\t\t\t\t\t\t\t from disease\t\n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t (SELECT count(*) as diedtot ,district.name,casereport.diseaseid as disid,\n\t\t\t\t\t\t\t\t casereport.fatal \n\t\t\t\t\t\t\t\t FROM district \n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t casereport on district.districtid=casereport.districtid where \n\t\t\t\t\t\t\t\t district.name='" . $district . "' and casereport.fatal='Fatal' and casedate\n\t\t\t\t         between '" . $startdate . "' and '" . $enddate . "' group by diseaseid\n\t\t\t\t         ) as diedrec on disease.diseaseid=diedrec.disid\n                )\n\t\t\t\t\t\t\t)as adm group by adm.dname") or die(mysql_error());
                //Getting the number of admitted patients in the given district
                $resultnotdead = mysql_query("select sum(admitted.totalreported) as totalreported,admitted.dname from\n\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t(select totalreported as totalreported,disease.name as dname from disease\n\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\t(select sum(reportedcase) as totalreported,diseaseid,district.name from district \n\t\t\t\t\t\t\t\t\tleft join\n\t\t\t\t\t\t\t\t\tbulkcase on district.districtid=bulkcase.districtid where createdon \n\t\t\t\t\t\t\t\t\tbetween '" . $startdate . "' and '" . $enddate . "'  and district.name='" . $district . "'\n\t\t\t\t\t\t\t\t\tgroup by diseaseid\n\t\t\t\t\t\t\t\t\t) as diseaserec \n\t\t\t\t\t\t\t\ton diseaserec.diseaseid=disease.diseaseid\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tunion all\n\t\t\t\t\t\t\t\t(select admittedrec.totalreported as totalreported,disease.name as dname \n\t\t\t\t\t\t\t\t from disease\t\n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t (SELECT count(*) as totalreported ,district.name,casereport.diseaseid as disid,\n\t\t\t\t\t\t\t\t casereport.fatal \n\t\t\t\t\t\t\t\t FROM district \n\t\t\t\t\t\t\t\t left join \n\t\t\t\t\t\t\t\t casereport on district.districtid=casereport.districtid where \n\t\t\t\t\t\t\t\t district.name='" . $district . "' and casedate\n\t\t\t\t         between '" . $startdate . "' and '" . $enddate . "' group by diseaseid\n\t\t\t\t         ) as admittedrec on disease.diseaseid=admittedrec.disid\n                )\n\t\t\t\t\t\t\t)as admitted group by admitted.dname") or die(mysql_error());
                $color = 0;
                $intCount = mysql_num_rows($resultset);
                if ($intCount > 0) {
                    $strContent = '<h4>List of cases reported between ' . getDateFromDb($dts) . ' 
			and ' . getDateFromDb($dte) . ' in ' . $opt . '</h4>';
                    $strContent .= '<table id="tblList" ><tr>';
                    $strContent .= '<th class="tdBorder">Disease</th>';
                    $strContent .= '<th class="tdBorder">Died</th>';
                    $strContent .= '<th class="tdBorder">Reported</th></tr>';
                    while (($row = mysql_fetch_array($resultset)) && ($row1 = mysql_fetch_array($resultnotdead))) {
                        if ($color == 0) {
                            $strContent .= "<tr>";
                            $color = 1;
                        } else {
                            $strContent .= '<tr class="trColor1">';
                            $color = 0;
                        }
                        $strContent .= '<td class="tdContent">' . $row['diseasename'] . '</td>';
                        $strContent .= '<td class="tdContent">' . $row['diedtotal'] . '</td>';
                        $strContent .= '<td class="tdContent">' . $row1['totalreported'] . '</td></tr>';
                        $arrXLabels[$intCount1] = $row['diseasename'];
                        if ($diedMax < $row['diedtotal']) {
                            $diedMax = $row['diedtotal'];
                        }
                        if ($admMax < $row1['totalreported']) {
                            $admMax = $row1['totalreported'];
                        } else {
                        }
                        $intDiedTot += $row['diedtotal'];
                        $intAdmTot += $row1['totalreported'];
                        $arrValues[$intCount1][$intCount1] = $row['diedtotal'];
                        $arrValues[$intCount1][$intCount1 + 1] = $row1['totalreported'];
                        $intCount1++;
                    }
                    $strContent .= '<tr>
											<td class="tdContent">
											</td>
											<td class="tdContent">
												' . $intDiedTot . '
											</td>
											<td class="tdContent">
												' . $intAdmTot . '	
											</td>
										</tr>';
                    $strContent .= showGraphHeading();
                    $strContent .= showColorInfo();
                    $max = $diedMax > $admMax ? $diedMax : $admMax;
                    $str = createBarGraph($arrXLabels, $arrValues, $max, 'Diseases');
                    $strContent .= '<tr class="trGraph">
											<td colspan="3">
												' . $str . '
											</td>
										</tr>';
                    //Information about the graph xcordinate values
                    $strContent .= showGraphXcordinateInfo($arrXLabels);
                    $strContent .= '<tr>
											<td class="tdButton">
												<a href="" 
						onclick="javascript: printPage(\'Dist\',\'' . $district . '\');return false;">
													<img class="imgPrint" src="../images/printbutton.gif" 
													alt="Print">
												</a>
											</td>
											<td class="tdButton">
												<a href="summary.php"	target="contentFrame">
													<img class="imgBck"	src="../images/backbutton01.gif" 
													alt="Back">
												</a>
											</td>
										</tr>
									</table>';
                    return $strContent;
                } else {
                }
            } else {
                //Getting the number of died patients in the given district
                $strDiseaseName = $opt;
                $color = 0;
                $strContent = '<h4>List of cases reported between ' . getDateFromDb($dts) . ' and 
			' . getDateFromDb($dte) . ' for ' . $strDiseaseName . ' according to age group</h4>
				<h4>Case without age information in the reports are not included. </h4>';
                $strContent .= '<table id="tblList" ><tr>';
                $strContent .= '<th class="tdBorder">Age Group</th>';
                $strContent .= '<th class="tdBorder">Died</th>';
                $strContent .= '<th class="tdBorder">Reported</th></tr>';
                $strQuery = "select 10 as commonagegroup";
                for ($intCount = 20; $intCount < 120; $intCount += 10) {
                    $strQuery .= " union all select " . $intCount . " as commonagegroup";
                }
                $result1 = mysql_query("select commonagegrouptbl.commonagegroup as age,\n\t\t\t\t\tagecasereport.diedcount as diedcount from\t(" . $strQuery . ") \n\t\t\t\t\tas commonagegrouptbl\n\t\t\t\tleft join \n\t\t\t\t\t(select count(*) as diedcount,casereportagegroup .agegroup as age from \n\t\t\t\t\t\t(select casereportid,districtid,diseaseid,casedate,fatal,\n\t\t\t\t\t\t\tcase \n\t\t\t\t\t\t\t\t when age between 0 and 10\n\t\t\t\t\t\t\t\t\t\t then '10'\n\t\t\t\t\t\t \t\t when age between 10 and 20\n\t\t\t\t\t\t\t\t\t\t then '20'\n\t\t\t\t\t\t\t\t when age between 20 and 30\n\t\t\t\t \t\t\t\t\t\t then '30'\n\t\t\t\t\t\t\t\t when age between 30 and 40\n\t\t\t\t\t\t\t\t\t   then '40'\n \t\t\t\t\t\t\t\t when age between 40 and 50\n\t\t\t\t\t\t\t\t\t   then '50'\n\t\t\t\t\t\t\t\t when age between 50 and 60\n\t\t\t\t\t\t\t\t\t   then '60'\n\t\t\t\t\t\t\t\t when age between 60 and 70\n\t\t \t\t\t\t\t\t     then '70'\n\t\t\t\t\t\t\t\t when age between 70 and 80\n\t\t\t\t\t\t\t\t\t   then '80'\n\t\t\t\t\t\t\t\t when age between 90 and 100\n\t\t\t\t\t\t\t\t\t   then '100'\n\t\t\t\t\t\t\t\t else '110'\n\t\t\t\t \t\t\tend\n\t\t\t\t\t\t\tas agegroup\n\t\t\t\t\t\tfrom casereport \n\t\t\t\t\t\twhere casedate between '{$dts}' and \t\t'{$dte}' and fatal='Fatal'\n\t\t\t\t\t\t) as casereportagegroup \n\t\t\t\t\t\tleft join \n\t\t\t\t\t\tdisease\n\t\t\t\t\t\ton disease.diseaseid=casereportagegroup .diseaseid\n\t\t\t\t\t\twhere disease.name='{$strDiseaseName}'\n\t\t\t\t\t\tgroup by casereportagegroup .agegroup\n\t\t\t\t\t) as agecasereport\n\t\t\t\t\ton agecasereport.age=commonagegrouptbl.commonagegroup\n\t\t\t\t");
                $result2 = mysql_query("select commonagegrouptbl.commonagegroup as age,\n\t\t\t\t\t\tagecasereport.admittedcount as admittedcount from (" . $strQuery . ") \n\t\t\t\t\t\tas commonagegrouptbl\n\t\t\t\t\tleft join \n\t\t\t\t\t\t(select count(*) as admittedcount,casereportagegroup .agegroup as age from \n\t\t\t\t\t\t\t(select casereportid,districtid,diseaseid,casedate,fatal,\n\t\t\t\t\t \t\t\tcase \n\t\t\t\t\t\t\t\t\twhen age between 0 and 10\n\t\t\t\t\t\t\t\t\t  then '10'\n\t\t\t\t\t\t\t\t\twhen age between 10 and 20\n\t\t\t\t\t\t\t\t\t  then '20'\n \t\t\t\t\t\t\t\t  when age between 20 and 30\n\t\t\t\t \t\t\t\t\t  then '30'\n\t\t\t\t\t\t\t\t\twhen age between 30 and 40\n\t\t\t\t\t\t\t\t\t\tthen '40'\n \t\t\t\t\t\t\t\t\twhen age between 40 and 50\n\t\t\t\t\t\t\t\t\t\tthen '50'\n\t\t\t\t\t\t\t\t\twhen age between 50 and 60\n\t\t\t\t\t\t\t\t\t  then '60'\n\t\t\t\t\t\t\t\t\twhen age between 60 and 70\n\t\t \t\t\t\t\t\t\t  then '70'\n\t\t\t\t\t\t\t\t\twhen age between 70 and 80\n\t\t\t\t\t\t\t\t\t  then '80'\n\t\t\t\t\t\t\t\t\twhen age between 90 and 100\n\t\t\t\t\t\t\t\t\t  then '100'\n\t\t\t\t\t\t\t\t\telse '110'\n\t\t\t\t \t\t\t\tend\n\t\t\t\t\t\t\t\tas agegroup\n\t\t\t\t\t\t\t from casereport \n\t\t\t\t\t\t\t where casedate between '{$dts}' and \t\t'{$dte}' \n\t\t\t\t\t\t\t) as casereportagegroup \n\t\t\t\t\t\t\tleft join \n\t\t\t\t\t\t\tdisease\n\t\t\t\t\t\t\ton disease.diseaseid=casereportagegroup .diseaseid\n\t\t\t\t\t\t\twhere disease.name='{$strDiseaseName}'\n\t\t\t\t\t\t\tgroup by casereportagegroup .agegroup\n\t\t\t\t\t\t) as agecasereport\n\t\t\t\t\t\ton agecasereport.age=commonagegrouptbl.commonagegroup");
                while (($row = mysql_fetch_array($result1)) && ($row1 = mysql_fetch_array($result2))) {
                    if ($color == 0) {
                        $strContent .= "<tr>";
                        $color = 1;
                    } else {
                        $strContent .= '<tr class="trColor1">';
                        $color = 0;
                    }
                    if ($row['age'] == 110) {
                        $intstartAge = 'Above 100';
                    } else {
                        $intstartAge = $row['age'] - 10;
                        $intstartAge .= '-' . $row['age'];
                    }
                    $arrXLabels[$intCount1] = $intstartAge;
                    $strContent .= '<td class="tdContent">' . $intstartAge . '</td>';
                    $strContent .= '<td class="tdContent">' . $row['diedcount'] . '</td>';
                    $strContent .= '<td class="tdContent">' . $row1['admittedcount'] . '</td></tr>';
                    if ($diedMax < $row['diedcount']) {
                        $diedMax = $row['diedcount'];
                    }
                    if ($admMax < $row1['admittedcount']) {
                        $admMax = $row1['admittedcount'];
                    } else {
                    }
                    $intDiedTot += $row['diedcount'];
                    $intAdmTot += $row1['admittedcount'];
                    $arrValues[$intCount1][$intCount1] = $row['diedcount'];
                    $arrValues[$intCount1][$intCount1 + 1] = $row1['admittedcount'];
                    $intCount1++;
                }
                $arrXLabels[--$intCount1] = 'Above 100';
                $strContent .= '<tr>
											<td class="tdContent">
											</td>
											<td class="tdContent">
												' . $intDiedTot . '
											</td>
											<td class="tdContent">
												' . $intAdmTot . '	
											</td>
										</tr>';
                $strContent .= showGraphHeading();
                $strContent .= showColorInfo();
                $max = $diedMax > $admMax ? $diedMax : $admMax;
                $str = createBarGraph($arrXLabels, $arrValues, $max, 'Age Group');
                $strContent .= '<tr class="trGraph">
											<td colspan="3">
												' . $str . '
											</td>
										</tr>';
                //Information about the graph xcordinate values
                $strContent .= showGraphXcordinateInfo($arrXLabels);
                $strContent .= '<tr>
											<td class="tdButton">
												<a href="" 
												onclick="javascript: printPage(\'By Age Group\',\'' . $strDiseaseName . '\');return false;">
													<img class="imgPrint" src="../images/printbutton.gif" 
													alt="Print">
												</a>
											</td>	 
											<td class="tdButton">
												<a href="summary.php"	target="contentFrame">
													<img class="imgBck"	src="../images/backbutton01.gif" 
													alt="Back">
												</a>
											</td>	 
										</tr>
									</table>';
                return $strContent;
            }
        }
    }
}
function showContent($authorise, $selectedText, $option)
{
    $strContent = "";
    $choice = 0;
    $dte1 = "";
    $dte2 = "";
    $curDate = "";
    $event = "";
    switch ($option) {
        case "1":
            $year = $_GET['MYear'];
            $dte1 = $year . "-" . $selectedText . "-" . "01";
            $dte2 = $year . "-" . $selectedText . "-" . "31";
            $filterval = "eventtime between '" . $dte1 . "' and '" . $dte2 . "' ";
            $choice = 1;
            break;
        case "2":
            $curDate = date("d.m.Y");
            $arrDate = explode(".", $curDate);
            $dte1 = $selectedText . "-01-01";
            $dte2 = $selectedText . "-12-31";
            $filterval = "eventtime between '" . $dte1 . "' and '" . $dte2 . "' ";
            $choice = 2;
            break;
        case "3":
            if (isset($_GET['Datestart'])) {
                $startdate = getDateToDb($_GET['Datestart']);
                $enddate = getDateToDb($_GET['Dateclose']);
            } else {
                $arrDate = strtEndDateMonthDiff();
                $startdate = $arrDate[0];
                $enddate = $arrDate[1];
            }
            $filterval = "eventtime between '" . $startdate . "' and '" . $enddate . "' ";
            $choice = 3;
            break;
        case "4":
            $filterval = "event like '%" . $selectedText . "' ";
            $choice = 4;
            break;
        default:
            break;
    }
    $result = mysql_query("select * from eventlog where 1=1  and " . $filterval . " ") or die(mysql_error());
    $paginationQuery = "select * from eventlog where 1=1  and " . $filterval;
    $intCount = mysql_num_rows($result);
    if ($intCount > 0) {
        if ($choice == 1) {
            echo '<h4>Report on ' . getMonth($selectedText) . ' ' . $_GET['MYear'] . '</h4><br>';
        } else {
            if ($choice == 2) {
                echo '<h4>Report For The Year ' . $selectedText . '</h4><br>';
            } else {
                if ($choice == 3) {
                    if (isset($_GET['Datestart'])) {
                        echo '<h4>Report on ' . $_GET['Datestart'] . ' and ' . $_GET['Dateclose'] . '</h4><br>';
                    } else {
                        echo '<h4>Report on ' . getDateFromDb($startdate) . ' and ' . getDateFromDb($enddate) . '</h4><br>';
                    }
                } else {
                    echo '<h4>Report on  ' . $selectedText . '</h4><br>';
                }
            }
        }
        /* function for pagination */
        list($result, $classObj, $dispyListInfo) = classPagination($paginationQuery, $intCount);
        $listData = listEvent($authorise, $intCount, $result);
        $strContent .= $listData;
        $strContent .= '<br /><br />';
        $strContent .= $dispyListInfo . '<br />';
        $strContent .= $classObj->navigationBar();
    } else {
        $strContent .= "No data is stored in the database or you are not authorised to view this data";
    }
    echo $strContent;
}
function listCaseReport(&$authorise, &$intResultNum, &$result)
{
    $strContent = '<table class="listContentTab" id="tblList">';
    $strContent .= '<tr>
				<th class="tdBorder">Patient Name</th>
				<th class="tdBorder">Age</th>
				<th class="tdBorder">Sex</th>
				<th class="tdBorder">Disease</th>';
    if ($authorise == "DAO" || $authorise == "GMO" || $authorise == "ADMIN") {
        $strContent .= '<th class="tdBorder">Hospital</th>';
    }
    $strContent .= '<th class="tdBorder">Case Date</th>
		<th class="tdBorder">View</th>
		<th class="tdBorder">Edit</th></tr>';
    $color = "";
    while ($row = mysql_fetch_array($result)) {
        if ($color == 0) {
            $strContent .= '<tr><td class="tdContent">' . $row['pname'] . '</td>';
            $color = 1;
        } else {
            $strContent .= '<tr class="listTrColor">
				<td class="tdContent">' . $row['pname'] . '</td>';
            $color = 0;
        }
        $strContent .= '<td class="tdContent">' . $row['age'] . '</td>
			<td class="tdContent">' . $row['sex'] . '</td>
			<td class="tdContent">' . $row['dname'] . '</td>';
        if ($authorise == "DAO" || $authorise == "GMO" || $authorise == "ADMIN") {
            $strContent .= '<td class="tdContent">' . $row['hname'] . '</td>';
        }
        $strContent .= "<td class=\"tdContentImg\">" . getDateFromDb($row['casedate']) . "</td>\n\t\t\t<td class=\"tdContentImg\">\n\t\t\t\t<a href=\"./viewcasereport.php?caseid=" . $row['casereportid'] . "\">\n\t\t\t\t\t<img class=\"editButton\" src=\"../images/view.gif\" alt=\"View\" />\n\t\t\t\t</a></td>";
        $strContent .= "<td class=\"tdContentImg\">\n\t\t\t\t<a href=\"./addcasereport.php?casereportid=" . $row['casereportid'] . "\">\n\t\t\t\t\t<img class=\"editButton\" src=\"../images/edit.gif\" alt=\"Edit\" />\n\t\t\t\t</a></td></tr>";
    }
    $strContent .= '</table>';
    return $strContent;
}
     }
     $kml[] = '<td style="border:thin solid #000000">' . $rowCasereportAdmit['count(*)'] . '</td>';
     $kml[] = '</tr></table>]]></description>';
     $kml[] = '<styleUrl>#' . $rowDisease['name'] . '</styleUrl>';
     $kml[] = '<Point>';
     $kml[] = '<coordinates>' . $rowCasereportAdmit['districtlong'] . ',' . $rowCasereportAdmit['districtlat'] . ',0</coordinates>';
     $kml[] = '</Point>';
     $kml[] = '</Placemark>';
 } else {
     $kml[] = '<Placemark>';
     $kml[] = '<description><![CDATA[<table style="border:thin solid #000000;font-size:10px;
                               width:175px;background-color:#E9E9DA">
                                 <tr>
                                   <th colspan="3" style="border:thin solid #000000">' . $rowDisease['name'] . '
                                     Victims between
                                             ' . getDateFromDb($startDate) . ' and ' . getDateFromDb($endDate) . '
                                   </th>
                                 </tr>
                                 <tr>
                                   <th  style="border:thin solid #000000">
                                     Post office
                                   </th >
                                   <th style="border:thin solid #000000">
                                     Died
                                   </th>
                                   <th style="border:thin solid #000000">
                                     Reported
                                   </th>
                                 </tr>
                                 <tr>';
     $kml[] = '<td style="border:thin solid #000000">' . $rowCasereportAdmit['postofficename'] . '</td>';
function fileReadCSV($fileName)
{
    $pincode = "";
    $diedon = "";
    $strcontent = "";
    $strReason = "";
    $distId = "";
    $disId = "";
    $hosId = "";
    $postId = "";
    $strcontent .= '<table>
		<tr>
			<td>';
    $handle = "";
    $createdOn = "";
    $strValue = "";
    $diedon = "";
    $userName = $_SESSION['userName'];
    $createdOn = date("d/m/Y");
    $handle = fopen("{$fileName}", "r");
    while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
        if (strlen($data[0]) > 1) {
            if ($data[11] == "" || $data[11] == " " || $data[11] == NULL || strlen($data[11]) == 0) {
                $data[11] = $data[11];
            } else {
                $data[11] = getDateToDb($data[11]);
            }
            mysql_query("insert into dummycasereport\n\t\t\t(\n\t\t\t\tname,\n\t\t\t\tage,\n\t\t\t\tsex,\n\t\t\t\taddress1,\n\t\t\t\taddress2,\n\t\t\t\tdistrictname,\n\t\t\t\tpostofficename,\n\t\t\t\tpincode,\n\t\t\t\thospitalname,\n\t\t\t\tdiseasename,\n\t\t\t\tfatal,\n\t\t\t\tdiedon,\n\t\t\t\tcasedate,\n\t\t\t\treportedon,\n\t\t\t\tusername,\n\t\t\t\tcreatedon\n\t\t\t)\n\t\t\tvalues\n\t\t\t(\n\t\t\t\t'" . trim(preventInj($data[0])) . "',\n\t\t\t\t'" . trim(preventInj($data[1])) . "',\n\t\t\t\t'" . trim(preventInj($data[2])) . "',\n\t\t\t\t'" . trim(preventInj($data[3])) . "',\n\t\t\t\t'" . trim(preventInj($data[4])) . "',\n\t\t\t\t'" . trim(preventInj($data[5])) . "',\n\t\t\t\t'" . trim(preventInj($data[6])) . "',\n\t\t\t\t'" . trim(preventInj($data[7])) . "',\n\t\t\t\t'" . trim(preventInj($data[8])) . "',\n\t\t\t\t'" . trim(preventInj($data[9])) . "',\n\t\t\t\t'" . trim(preventInj($data[10])) . "',\n\t\t\t\t'" . trim(preventInj($data[11])) . "',\n\t\t\t\t'" . trim(preventInj(getDateToDb($data[12]))) . "',\n\t\t\t\t'" . trim(preventInj(getDateToDb($data[13]))) . "',\n\t\t\t\t'" . trim(preventInj($userName)) . "',\n\t\t\t\t'" . trim(preventInj(getDateToDb($createdOn))) . "'\n\t\t\t)\n\t\t\t") or die(mysql_error());
        }
    }
    //$strcontent.="Inserting of dummy case report finished...wait <br />";
    fclose($handle);
    $result = mysql_query("SELECT dummycasereport.name as name, age, sex, address1, address2,\n\t\t\tdistrict.districtid as districtid, postofficeid, dummycasereport.pincode as pincode,\n\t\t\thospitalid, diseaseid, fatal, reportedon, diedon, casedate, dummycasereport.username,\n\t\t\tcreatedon, casereportid\n\t\tFROM\n\t\t\tdummycasereport\n\t\tLEFT JOIN\n\t\t\tdistrict on dummycasereport.districtname = district.name\n\t\tLEFT JOIN\n\t\t\tdisease on dummycasereport.diseasename = disease.name\n\t\tLEFT JOIN\n\t\t\tpostoffice on dummycasereport.postofficename = postoffice.name\n\t\tLEFT JOIN\n\t\t\thospital on dummycasereport.hospitalname = hospital.name\n\t\tWHERE district.districtid is NOT NULL AND  diseaseid is NOT NULL AND\n\t\t\tpostofficeid is NOT NULL AND hospitalid is NOT NULL") or die(mysql_error());
    $intResultNum = mysql_num_rows($result);
    while ($row = mysql_fetch_array($result)) {
        //check the same result is reported earlier
        $resultExist = mysql_query("SELECT * from casereport where name='" . $row['name'] . "'\n\t\t\tand age='" . $row['age'] . "'\n\t\t\tand sex='" . $row['sex'] . "'\n\t\t\tand fatal='" . $row['fatal'] . "'\n\t\t\tand address1='" . $row['address1'] . "'\n\t\t\tand address2='" . $row['address2'] . "'\n\t\t\tand districtid='" . $row['districtid'] . "'\n\t\t\tand postofficeid='" . $row['postofficeid'] . "'\n\t\t\tand pincode='" . $row['pincode'] . "'\n\t\t\tand hospitalid='" . $row['hospitalid'] . "'\n\t\t\tand diseaseid='" . $row['diseaseid'] . "'\n\t\t\tand fatal='" . $row['fatal'] . "'\n\t\t\tand reportedon='" . $row['reportedon'] . "'\n\t\t\tand diedon=\t'" . $row['diedon'] . "'\n\t\t\tand casedate='" . $row['casedate'] . "'\n\t\t") or die(mysql_error());
        $intnameExists = mysql_num_rows($resultExist);
        if ($intnameExists > 0) {
            //case alreay reported
        } else {
            mysql_query("insert into casereport\n\t\t\t(\n\t\t\t\tname,\n\t\t\t\tage,\n\t\t\t\tsex,\n\t\t\t\taddress1,\n\t\t\t\taddress2,\n\t\t\t\tdistrictid,\n\t\t\t\tpostofficeid,\n\t\t\t\tpincode,\n\t\t\t\thospitalid,\n\t\t\t\tdiseaseid,\n\t\t\t\tfatal,\n\t\t\t\tdiedon,\n\t\t\t\tcasedate,\n\t\t\t\treportedon,\n\t\t\t\tusername,\n\t\t\t\tcreatedon\n\t\t\t)\n\t\t\tvalues\n\t\t\t(\n\t\t\t\t'" . $row['name'] . "',\n\t\t\t\t'" . $row['age'] . "',\n\t\t\t\t'" . $row['sex'] . "',\n\t\t\t\t'" . $row['address1'] . "',\n\t\t\t\t'" . $row['address2'] . "',\n\t\t\t\t'" . $row['districtid'] . "',\n\t\t\t\t'" . $row['postofficeid'] . "',\n\t\t\t\t'" . $row['pincode'] . "',\n\t\t\t\t'" . $row['hospitalid'] . "',\n\t\t\t\t'" . $row['diseaseid'] . "',\n\t\t\t\t'" . $row['fatal'] . "',\n\t\t\t\t'" . $row['diedon'] . "',\n\t\t\t\t'" . $row['casedate'] . "',\n\t\t\t\t'" . $row['reportedon'] . "',\n\t\t\t\t'" . $row['username'] . "',\n\t\t\t\t'" . $row['createdon'] . "'\n\t\t\t)\n\t\t\t") or die(mysql_error());
            $resultMax = mysql_query("SELECT MAX(casereportid) as maxId from casereport") or die(mysql_error());
            $rowMax = mysql_fetch_array($resultMax);
            $maxId = $rowMax['maxId'];
            mysql_query("UPDATE casereport SET diedon = NULL WHERE diedon='0000-00-00'\n\t\t\t\t\t\tand casereportid='" . $maxId . "' ") or die(mysql_error());
            mysql_query("UPDATE casereport SET pincode = NULL WHERE pincode=0\n\t\t\t\t\t\tand casereportid='" . $maxId . "' ") or die(mysql_error());
            $username = $_SESSION['userName'];
            $description = "Cases Imported by  " . $username . " is loaded into the database";
            insertEventData('Import_Case', "Case_Imported", $username, $description);
        }
        mysql_query("delete from dummycasereport where casereportid='" . $row['casereportid'] . "' ") or die(mysql_error());
    }
    //$strcontent.="Valid datas are inserted to a case report table <br />";
    $result = mysql_query("SELECT * FROM dummycasereport") or die(mysql_error());
    $intResultNum = mysql_num_rows($result);
    if ($intResultNum > 0) {
        while ($row = mysql_fetch_array($result)) {
            $resultCheck = mysql_query("SELECT dummycasereport.name as name, age, sex, address1,\n\t\t\t\taddress2, district.districtid as districtid, postofficeid, dummycasereport.pincode\n\t\t\t\tas pincode, hospitalid, diseaseid, fatal, reportedon, diedon, casedate,\n\t\t\t\tdummycasereport.username, createdon, casereportid\n\t\t\tFROM\n\t\t\t\tdummycasereport\n\t\t\tLEFT JOIN\n\t\t\t\tdistrict on dummycasereport.districtname = district.name\n\t\t\tLEFT JOIN\n\t\t\t\tdisease on dummycasereport.diseasename = disease.name\n\t\t\tLEFT JOIN\n\t\t\t\tpostoffice on dummycasereport.postofficename = postoffice.name\n\t\t\tLEFT JOIN\n\t\t\t\thospital on dummycasereport.hospitalname = hospital.name\n\t\t\tWHERE casereportid='" . $row['casereportid'] . "' ") or die(mysql_error());
            $rowCheck = mysql_fetch_array($resultCheck);
            $distId = $rowCheck['districtid'];
            $disId = $rowCheck['diseaseid'];
            $hosId = $rowCheck['hospitalid'];
            $postId = $rowCheck['postofficeid'];
            $strReason = "Reason to Reject: ";
            if ($distId == NULL) {
                $strReason .= "Check the district name\tis same as in the database. ";
            }
            if ($disId == NULL) {
                $strReason .= "Check the disease name\tis same as in the database. ";
            }
            if ($hosId == NULL) {
                $strReason .= "Check the hospital name\tis same as in the database. ";
            }
            if ($postId == NULL) {
                $strReason .= "Check the postoffice name is same as in the database. ";
            }
            if ($row['diedon'] == "" || $row['diedon'] == " " || $row['diedon'] == NULL) {
                $diedon = NULL;
            } else {
                $diedon = getDateFromDb($row['diedon']);
            }
            if ($diedon == '00/00/0000') {
                $diedon = NULL;
            }
            $strValue .= $row['name'];
            $strValue .= "\t";
            $strValue .= $row['age'];
            $strValue .= "\t";
            $strValue .= $row['sex'];
            $strValue .= "\t";
            $strValue .= $row['address1'];
            $strValue .= "\t";
            $strValue .= $row['address2'];
            $strValue .= "\t";
            $strValue .= $row['districtname'];
            $strValue .= "\t";
            $strValue .= $row['postofficename'];
            $strValue .= "\t";
            $strValue .= $pincode;
            $strValue .= "\t";
            $strValue .= $row['hospitalname'];
            $strValue .= "\t";
            $strValue .= $row['diseasename'];
            $strValue .= "\t";
            $strValue .= $row['fatal'];
            $strValue .= "\t";
            $strValue .= $diedon;
            $strValue .= "\t";
            $strValue .= getDateFromDb($row['casedate']);
            $strValue .= "\t";
            $strValue .= getDateFromDb($row['reportedon']);
            $strValue .= "\t";
            $strValue .= $strReason;
            $strValue .= "\n";
            $strReason = "";
        }
        $intResultNum = $intResultNum * 2;
        $intResultNum = $intResultNum + 1;
        $strcontent .= '</td>
			</tr>
			<tr>
				</td>';
        $strcontent .= '<form>';
        $strcontent .= '<textarea READONLY class="displayBack" rows="' . $intResultNum . '" cols="100">';
        $strcontent .= $strValue;
        $strcontent .= '</textarea>';
        $strcontent .= '</form>';
        $strcontent .= '</td>
			</tr>
			<tr>
				<td>';
        $strcontent .= "Invalid datas are given back for manual insertion <br />";
        $strcontent .= 'Copy the above contents and insert the contents manually through "Add Case Report" link or modify the contents and try again.<span class="impMessage">You must remove the "Reason to Reject:" from the page before re-import the file</span>';
        $strcontent .= '</td>
			</tr>
			<tr>
				<td>';
    }
    mysql_query("delete from dummycasereport") or die(mysql_error());
    $strcontent .= 'Valid contents are uploaded successfully';
    $strcontent .= '</td>
		</tr>
	</table>';
    return $strcontent;
}