function pregtest() { //function นัด pregtest $sql = "SELECT\n concat('สถานบริการ(สถานีอนามัย/PCU): ',chospital.`hosname`,' หมู่ที่:',ifnull(chospital.`mu`,'...'),' ต.',\n\tifnull(csubdistrict.`subdistname`,' ...'),' อ.',ifnull(cdistrict.`distname`,' ...'),' จ.',\n\tifnull(cprovince.`provname`,'...')) AS chospital_hosname\nFROM\n `chospital` chospital \n INNER JOIN `office` office ON chospital.`hoscode` = office.`offid`\n left outer join `csubdistrict` csubdistrict ON chospital.`provcode` = csubdistrict.`provcode`\n AND chospital.`distcode` = csubdistrict.`distcode`\n AND chospital.`subdistcode` = csubdistrict.`subdistcode`\n left outer JOIN `cdistrict` cdistrict ON chospital.`provcode` = cdistrict.`provcode`\n AND chospital.`distcode` = cdistrict.`distcode`\n INNER JOIN `cprovince` cprovince ON chospital.`provcode` = cprovince.`provcode`"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $hosp = $row[chospital_hosname]; $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND house.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $str = retdaterangstr($_GET[str]); $sto = retdaterangsto($_GET[str]); $strx = retDatets($str); $stox = retDatets($sto); $sql = "SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisit.visitdate,\nvisitfp.pregtest,\nvisitfp.pregtestresult,\nvisit.username\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nINNER JOIN visit ON person.pcucodeperson = visit.pcucodeperson AND person.pid = visit.pid\nINNER JOIN visitfp ON visit.pcucodeperson = visitfp.pcucodeperson AND visit.pid = visitfp.pid AND visit.visitdate = visitfp.datefp\nwhere visitfp.pregtest = '17' and visit.visitdate between '{$str}' and '{$sto}' {$wvill}\norder by visit.visitdate,person.fname"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>รายงานการตรวจทดสอบการตั้งครรภ์<br>'; $txt .= "ข้อมูลวันที่ {$strx} ถึง {$stox} {$mu}</b></p><b>{$hosp}</b><table width='99%' border='0' cellspacing='1' cellpadding='1' class='table table-striped table-hover table-bordered'>\n <tr>\n <th width='4%' scope='col'><div align='center'>ลำดับ</th>\n\t<th width='5%' scope='col'><div align='center'>HN</th>\n <th width='10%' scope='col'><div align='center'>ชื่อ - สกุล</th>\n\t<th width='5%' scope='col'><div align='center'>อายุ</th>\n <th width='6%' scope='col'><div align='center'>บ้านเลขที่</th>\n\t<th width='4%' scope='col'><div align='center'>หมู่ที่</th>\n <th width='4%' scope='col'><div align='center'>วันที่ตรวจ</th>\n\t<th width='9%' scope='col'><div align='center'>ผลการตรวจ</th>\n\t<th width='9%' scope='col'><div align='center'>ผู้ตรวจ</th>\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $userv = getusername($row[username]); if ($row[pregtestresult] == "0") { $pregtestname = "ไม่ตั้งครรภ์"; } elseif ($row[pregtestresult] == "1") { $pregtestname = "ตั้งครรภ์"; } elseif ($row[pregtestresult] == "3") { $pregtestname = "แปลผลไม่ได้"; } else { $pregtestname = ""; } if ($row[visitdate] == "") { $appsick = ""; } else { $appsick = retDatets($row[visitdate]); } ++$i; if ($i % 2 == 1) { $cr = " class='altrow'"; } else { $cr = ""; } $txt .= " <tr {$cr}>\n <td><div align='center'>{$i}</div></td>\n\t<td><div align='center'>{$row['pid']}</div></td>\n <td>{$row['pname']}</td>\n\t<td><div align='center'>{$row['age']}</div></td>\n <td><div align='center'>{$row['hno']}</div></td>\n <td><div align='center'>{$moo}</div></td>\n\t<td><div align='center'>{$appsick}</div></td>\n\t<td><div align='center'>{$pregtestname}</div></td>\n\t<td><div align='left'>{$userv}</div></td>\n </tr>"; } $txt .= "</table><br>"; echo $txt; }
function pregtest() { //function นัด pregtest $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND house.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $str = retdaterangstr($_GET[str]); $sto = retdaterangsto($_GET[str]); $strx = retDatets($str); $stox = retDatets($sto); $sql = "SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisit.visitdate,\nvisitfp.pregtest,\nvisitfp.pregtestresult,\nvisit.username\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nINNER JOIN visit ON person.pcucodeperson = visit.pcucodeperson AND person.pid = visit.pid\nINNER JOIN visitfp ON visit.pcucodeperson = visitfp.pcucodeperson AND visit.pid = visitfp.pid AND visit.visitdate = visitfp.datefp\nwhere visitfp.pregtest = '17' and visit.visitdate between '{$str}' and '{$sto}' {$wvill}\norder by visit.visitdate,person.fname"; $result = mysql_query($sql); $xml = '<markers>'; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $userv = getusername($row[username]); if ($row[pregtestresult] == "0") { $pregtestname = "ไม่ตั้งครรภ์"; } elseif ($row[pregtestresult] == "1") { $pregtestname = "ตั้งครรภ์"; } elseif ($row[pregtestresult] == "3") { $pregtestname = "แปลผลไม่ได้"; } else { $pregtestname = ""; } if ($row[visitdate] == "") { $appsick = ""; } else { $appsick = retDatets($row[visitdate]); } $xml .= '<marker '; $xml .= 'pid="' . $row[pid] . '" '; $xml .= 'pname="' . $row[pname] . '" '; $xml .= 'age="' . $row[age] . '" '; $xml .= 'hno="' . $row[hno] . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'sick="' . $appsick . '" '; $xml .= 'labresult="' . $pregtestname . '" '; $xml .= 'userv="' . $userv . '" '; $xml .= 'lat="' . $row[ygis] . '" '; $xml .= 'lng="' . $row[xgis] . '" '; $xml .= '/>'; } $xml .= '</markers>'; echo $xml; }
function fp() { //function นัด fp $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND perapp.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $chk_ncd = $_GET[chk_ncd]; if ($chk_ncd == "2") { $chkncd = " AND vper.visitdate is not null"; } else { if ($chk_ncd == "3") { $chkncd = " AND vper.visitdate is null"; } else { $chkncd = ""; } } $str = $_GET[str]; $strx = retDatets($str); $sql = "SELECT\nperapp.*,\nvper.visitdate as datechk\nFROM\n(\nSELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisitfp.datedue,\ncdrug.drugname,\ncdrug.drugtypesub,\nvisitfp.datefp\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nINNER JOIN visitfp ON person.pcucodeperson = visitfp.pcucodeperson AND person.pid = visitfp.pid\ninner JOIN cdrug on visitfp.fpcode = cdrug.drugcode\nLEFT JOIN ctitle ON person.prename = ctitle.titlecode\nwhere visitfp.datedue = '{$str}') as perapp\nleft JOIN (SELECT visit.* FROM visit WHERE visit.visitdate = '{$str}') as vper \non perapp.pcucodeperson = vper.pcucodeperson and perapp.pid = vper.pid\nwhere perapp.pcucodeperson is not null {$chkncd} {$wvill}\norder by perapp.villcode,perapp.fname"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>รายงานการนัดวางแผนครอบครัว'; $txt .= "<br>ข้อมูลการนัดวันที่ {$_GET['str']} {$mu}</b></p><br><b>{$hosp}</b><table width='99%' border='0' cellspacing='1' cellpadding='1' class='table table-striped table-hover table-bordered'>\n <tr>\n <th width='4%' scope='col'><div align='center'>ลำดับ</div></th>\n\t<th width='10%' scope='col'><div align='center'>เลขบัตรประชาชน</div></th>\n <th width='10%' scope='col'><div align='center'>ชื่อ - สกุล</div></th>\n\t<th width='5%' scope='col'><div align='center'>อายุ</div></th>\n <th width='6%' scope='col'><div align='center'>บ้านเลขที่</div></th>\n\t<th width='4%' scope='col'><div align='center'>หมู่ที่</div></th>\n <th width='4%' scope='col'><div align='center'>วันที่นัด</div></th>\n\t<th width='4%' scope='col'><div align='center'>ประเภทการนัด</div></th>\n\t<th width='9%' scope='col'><div align='center'>##</div></th>\n\t<th width='9%' scope='col'><div align='center'>วันที่มารับบริการ</div></th>\n\t\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $title = getTitle($row[prename]); if ($row[drugtypesub] == "0") { $apptypename = "วชย.ทดสอบตั้งครรภ์"; } elseif ($row[drugtypesub] == "1") { $apptypename = "ยาเม็ด"; } elseif ($row[drugtypesub] == "2") { $apptypename = "ยาฉีด"; } elseif ($row[drugtypesub] == "3") { $apptypename = "ยาฝัง"; } elseif ($row[drugtypesub] == "4") { $apptypename = "ห่วง"; } elseif ($row[drugtypesub] == "5") { $apptypename = "ถุงยางอนามัย"; } elseif ($row[drugtypesub] == "6") { $apptypename = "หมันชาย"; } else { $apptypename = "หมันหญิง"; } if ($row[datedue] == "") { $appsick = ""; } else { $appsick = retDatets($row[datedue]); } if ($row[datechk] == "") { $sick = ""; } else { $sick = retDatets($row[datechk]); } if ($row[datechk] == "") { $sicksign = "ขาดนัด"; } else { $sicksign = "มาตามนัด"; } ++$i; if ($i % 2 == 1) { $cr = " class='altrow'"; } else { $cr = ""; } $txt .= " <tr {$cr}>\n <td><div align='center'>{$i}</div></td>\n\t<td><div align='center'>{$row['idcard']}</div></td>\n <td>{$row['pname']}</td>\n\t<td><div align='center'>{$row['age']}</div></td>\n <td><div align='center'>{$row['hno']}</div></td>\n <td><div align='center'>{$moo}</div></td>\n\t<td><div align='center'>{$appsick}</div></td>\n\t<td><div align='center'>{$apptypename}</div></td>\n\t<td><div align='center'>{$sicksign}</div></td>\n\t<td><div align='center'>{$sick}</div></td>\n </tr>"; } $txt .= "</table><br>"; echo $txt; }
<?php set_time_limit(0); include "../includes/conndb.php"; include "../includes/config.inc.php"; //ดึงชื่อสถานบริการ $sql = "SELECT\n concat('สถานบริการ(สถานีอนามัย/PCU): ',chospital.`hosname`,' หมู่ที่:',ifnull(chospital.`mu`,'...'),' ต.',\n\tifnull(csubdistrict.`subdistname`,' ...'),' อ.',ifnull(cdistrict.`distname`,' ...'),' จ.',\n\tifnull(cprovince.`provname`,'...')) AS chospital_hosname\nFROM\n `chospital` chospital \n INNER JOIN `office` office ON chospital.`hoscode` = office.`offid`\n left outer join `csubdistrict` csubdistrict ON chospital.`provcode` = csubdistrict.`provcode`\n AND chospital.`distcode` = csubdistrict.`distcode`\n AND chospital.`subdistcode` = csubdistrict.`subdistcode`\n left outer JOIN `cdistrict` cdistrict ON chospital.`provcode` = cdistrict.`provcode`\n AND chospital.`distcode` = cdistrict.`distcode`\n INNER JOIN `cprovince` cprovince ON chospital.`provcode` = cprovince.`provcode`"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $hosp = $row[chospital_hosname]; $ptype = $_GET[ptype]; $village = $_GET[village]; if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } if ($village == '00000000') { $ect2 = ""; } else { $ect2 = " h.villcode = '{$village}' AND "; } if ($ptype == '00') { $ect = ""; } else { $ect = " pt.persontypecode = '{$ptype}' AND "; } if ($ptype == '00') { $ect3 = "บุคคลสำคัญ"; } else { $ect3 = persontype($ptype);
include "../includes/config.inc.php"; //ดึงชื่อสถานบริการ $sql = "SELECT\n concat('สถานบริการ(สถานีอนามัย/PCU): ',chospital.`hosname`,' หมู่ที่:',ifnull(chospital.`mu`,'...'),' ต.',\n\tifnull(csubdistrict.`subdistname`,' ...'),' อ.',ifnull(cdistrict.`distname`,' ...'),' จ.',\n\tifnull(cprovince.`provname`,'...')) AS chospital_hosname\nFROM\n `chospital` chospital \n INNER JOIN `office` office ON chospital.`hoscode` = office.`offid`\n left outer join `csubdistrict` csubdistrict ON chospital.`provcode` = csubdistrict.`provcode`\n AND chospital.`distcode` = csubdistrict.`distcode`\n AND chospital.`subdistcode` = csubdistrict.`subdistcode`\n left outer JOIN `cdistrict` cdistrict ON chospital.`provcode` = cdistrict.`provcode`\n AND chospital.`distcode` = cdistrict.`distcode`\n INNER JOIN `cprovince` cprovince ON chospital.`provcode` = cprovince.`provcode`"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $hosp = $row[chospital_hosname]; $villcode = $_GET[village]; if ($villcode == "00000000") { $wvill = ""; } else { $wvill = " AND house.villcode='{$villcode}' "; } if ($villcode == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($villcode); } $str = $_GET[str]; $strx = retDatets($str); $live_type = $_GET[live_type]; if ($live_type == '2') { $live_type_name = "ตามทะเบียนบ้าน(0,1,2)"; } elseif ($live_type == '1') { $live_type_name = "ที่อาศัยอยู่จริง (0,1,3)"; } else { $live_type_name = "ทั้งหมดในเขตรับผิดชอบ(0,1,2,3)"; } if ($live_type == '2') { $live_type2 = "and person.typelive in ('0','1','2')"; } elseif ($live_type == '1') { $live_type2 = "and person.typelive in ('0','1','3')";
<script src="../js/jquery.1.11.0.min.js"></script> <script src="../js/bootstrap.min.js"></script> </head> <body> <?php $villcode = $_GET[village]; if ($villcode == '00000000') { $wt = " "; } else { $wt = " AND villcode='{$villcode}' "; } if ($villcode == "00000000") { $ect3 = "ทุกหมู่บ้าน"; } else { $ect3 = getvillagename($villcode); } $sql = "SELECT\ncount(distinct person.pid) as countofpid,\nhouse.villcode,\nvillage.villname\nFROM\nperson\nINNER JOIN house ON person.pcucodeperson = house.pcucode AND person.hcode = house.hcode\nINNER JOIN ctitle ON person.prename = ctitle.titlecode\nINNER JOIN village ON house.pcucode = village.pcucode AND house.villcode = village.villcode\nwhere {$ect2}\nRight(11-((Left(person.idcard,1)*13)+(Mid(person.idcard,2,1)*12)+(Mid(person.idcard,3,1)*11)+(Mid(person.idcard,4,1)*10)+(Mid(person.idcard,5,1)*9)+(Mid(person.idcard,6,1)*8)+(Mid(person.idcard,7,1)*7)+(Mid(person.idcard,8,1)*6)+(Mid(person.idcard,9,1)*5)+(Mid(person.idcard,10,1)*4)+(Mid(person.idcard,11,1)*3)+(Mid(person.idcard,12,1)*2)) Mod 11,1) <> Right(person.idcard,1)\ngroup by house.villcode\norder by house.villcode"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>จำนวนประชาชนที่เลขบัตรผิด<br>'; $txt .= "{$ect3}</b></p><table width='95%' border='0' cellspacing='1' cellpadding='1' class='table table-striped table-hover table-bordered'>\n <tr>\n <th width='8%' scope='col'><div align='center'>ลำดับ</div></th>\n <th width='22%' scope='col'><div align='center'>หมู่บ้าน</div></th>\n <th width='8%' scope='col'><div align='center'>จำนวน</div></th>\n <th width='8%' scope='col'><div align='center'>หมายเหตุ</div></th>\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $sum_countofpid = $sum_countofpid + $row[countofpid]; ++$i; if ($i % 2 == 1) { $cr = " class='altrow'"; } else { $cr = ""; }
} if ($live_type == '2') { $live_type2 = "and person.typelive in ('0','1','2')"; } elseif ($live_type == '1') { $live_type2 = "and person.typelive in ('0','1','3')"; } else { $live_type2 = "and person.typelive in ('0','1','2','3')"; } $sql = "SELECT\npepi.pcucodeperson,\npepi.villcode,\ncount(DISTINCT pepi.pid) as pchild,\nCOUNT(DISTINCT IF(vepi.files18epi = '061', pepi.pid, NULL)) AS pmmr\nFROM\n(SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nconcat(ifnull(titlename,'..') ,fname,' ',lname) as pname,\nperson.birth,\ngetagemonth(person.birth,now()) as age,\nhouse.hno,\nhouse.villcode,\nhouse.xgis,\nhouse.ygis\nFROM\nhouse\nINNER JOIN person on person.pcucodeperson = house.pcucode and person.hcode = house.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nwhere person.birth BETWEEN '{$str}' and '{$sto}' and ((person.dischargetype is null) or (person.dischargetype = '9')) {$wvill} {$live_type2}) as pepi\nleft JOIN\n(SELECT\nvisitepi.pcucodeperson,\nvisitepi.pid,\nvisitepi.dateepi,\nvisitepi.vaccinecode,\nvisitepi.hosservice,\ncdrug.files18epi\nFROM\nvisitepi\nINNER JOIN cdrug on cdrug.drugcode = visitepi.vaccinecode\nwhere cdrug.files18epi = '061') as vepi\non pepi.pcucodeperson = vepi.pcucodeperson and pepi.pid = vepi.pid\nGROUP BY pepi.pcucodeperson,pepi.villcode"; $result = mysql_query($sql); $txt = '<p align=\'center\'><b>รายงานเด็กอายุ 1 ปี ได้รับวัคซีน MMR<br>'; $txt .= "(เด็กเกิดระหว่างวันที่ {$_GET['str']} ถึง {$_GET['sto']}) <br>{$mu}</b></p><b>{$live_type_name}</b><br><b>{$hosp}</b><table width='95%' border='0' cellspacing='1' cellpadding='1' class='tbhl'>\n <tr>\n <th width='4%' scope='col'>ลำดับ</th>\n <th width='10%' scope='col'>หมู่บ้าน</th>\n\t<th width='4%' scope='col'>หมู่ที่</th>\n\t<th width='4%' scope='col'>เด็กอายุ 1 ปี</th>\n\t<th width='4%' scope='col'>ได้รับ MMR</th>\n <th width='4%' scope='col'>ร้อยละ</th>\n </tr>"; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $villname = getvillagename($row[villcode]); if ($row[pchild] == "0") { $percen = "0"; } else { $percen = $row[pmmr] / $row[pchild] * 100; } $percent1 = number_format($percen, 2, '.', ''); $sumpchild = $sumpchild + $row[pchild]; $sumpmmr = $sumpmmr + $row[pmmr]; if ($sumpchild == "0") { $percenx = "0"; } else { $percenx = $sumpmmr / $sumpchild * 100; } $percent1x = number_format($percenx, 2, '.', ''); ++$i;
} elseif ($live_type == '1') { $live_type2 = "and person.typelive in ('0','1','3')"; } else { $live_type2 = "and person.typelive in ('0','1','2','3')"; } //Generate the chart element $strXML = "<chart caption='ร้อยละเด็กอายุ 1 ปี ได้รับวัคซีน MMR' subCaption='" . $hosp . "' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix='' animation=' " . $animateChart . "'>"; // Fetch all factory records // $strQuery = "select * from Factory_Master"; // $result = mysql_query($strQuery) or die(mysql_error()); $sql = "SELECT\npepi.pcucodeperson,\npepi.villcode,\nCOUNT(DISTINCT IF(vepi.files18epi = '061', pepi.pid, NULL))/count(DISTINCT pepi.pid)*100 AS percent\nFROM\n(SELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nconcat(ifnull(titlename,'..') ,fname,' ',lname) as pname,\nperson.birth,\ngetagemonth(person.birth,now()) as age,\nhouse.hno,\nhouse.villcode,\nhouse.xgis,\nhouse.ygis\nFROM\nhouse\nINNER JOIN person on person.pcucodeperson = house.pcucode and person.hcode = house.hcode\nLEFT JOIN ctitle on ctitle.titlecode = person.prename\nwhere person.birth BETWEEN '2012-04-01' and '2013-03-31' and person.typelive in ('0','1','3','2') and ((person.dischargetype is null) or (person.dischargetype = '9'))) as pepi\nleft JOIN\n(SELECT\nvisitepi.pcucodeperson,\nvisitepi.pid,\nvisitepi.dateepi,\nvisitepi.vaccinecode,\nvisitepi.hosservice,\ncdrug.files18epi\nFROM\nvisitepi\nINNER JOIN cdrug on cdrug.drugcode = visitepi.vaccinecode\nwhere cdrug.files18epi = '061') as vepi\non pepi.pcucodeperson = vepi.pcucodeperson and pepi.pid = vepi.pid\nGROUP BY pepi.pcucodeperson,pepi.villcode"; $result = mysql_query($sql); //Iterate through each factory if ($result) { while ($ors2 = mysql_fetch_array($result)) { $villname = getvillagename($ors2[villcode]); $percent1x = number_format($ors2['percent'], 2, '.', ''); $strXML .= "<set label='" . $villname . "' value='" . $percent1x . "' />"; } } mysql_close($link); //Finally, close <chart> element $strXML .= "</chart>"; //Create the chart - Pie 3D Chart with data from strXML echo renderChart("FusionCharts/Column2D.swf", "", $strXML, "FactorySum", 750, 450, false, false); echo "<center><b>เด็กเกิดระหว่างวันที่ " . $_GET[str] . "-" . $_GET[sto] . " " . $live_type_name . " " . $mu . "</b></center>"; } else { header("Location: login.php"); } ?>
function fp() { //function นัด fp $village = $_GET[village]; if ($village == "00000000") { $wvill = ""; } else { $wvill = " AND perapp.villcode='{$village}' "; } if ($village == "00000000") { $mu = "ทุกหมู่บ้าน"; } else { $mu = getvillagename($village); } $chk_ncd = $_GET[chk_ncd]; if ($chk_ncd == "2") { $chkncd = " AND vper.visitdate is not null"; } else { if ($chk_ncd == "3") { $chkncd = " AND vper.visitdate is null"; } else { $chkncd = ""; } } $str = $_GET[str]; $strx = retDatets($str); $sql = "SELECT\nperapp.*,\nvper.visitdate as datechk\nFROM\n(\nSELECT\nperson.pcucodeperson,\nperson.pid,\nperson.idcard,\nperson.fname,\nconcat(ctitle.titlename, person.fname , ' ' , person.lname) AS pname,\nperson.birth,\nROUND(DATEDIFF(now(),person.birth)/365.25) AS age,\nhouse.villcode,\nhouse.hno,\nhouse.hcode,\nhouse.xgis,\nhouse.ygis,\nvisitfp.datedue,\ncdrug.drugname,\ncdrug.drugtypesub,\nvisitfp.datefp\nFROM\nhouse\nINNER JOIN person ON house.pcucode = person.pcucodeperson AND house.hcode = person.hcode\nINNER JOIN visitfp ON person.pcucodeperson = visitfp.pcucodeperson AND person.pid = visitfp.pid\ninner JOIN cdrug on visitfp.fpcode = cdrug.drugcode\nLEFT JOIN ctitle ON person.prename = ctitle.titlecode\nwhere visitfp.datedue = '{$str}') as perapp\nleft JOIN (SELECT visit.* FROM visit WHERE visit.visitdate = '{$str}') as vper \non perapp.pcucodeperson = vper.pcucodeperson and perapp.pid = vper.pid\nwhere perapp.pcucodeperson is not null {$chkncd} {$wvill}\norder by perapp.villcode,perapp.fname"; $result = mysql_query($sql); $xml = '<markers>'; while ($row = mysql_fetch_array($result)) { $moo = substr($row[villcode], 6, 2); $vill = getMooVillage($row[villcode]); $title = getTitle($row[prename]); if ($row[drugtypesub] == "0") { $apptypename = "วชย.ทดสอบตั้งครรภ์"; } elseif ($row[drugtypesub] == "1") { $apptypename = "ยาเม็ด"; } elseif ($row[drugtypesub] == "2") { $apptypename = "ยาฉีด"; } elseif ($row[drugtypesub] == "3") { $apptypename = "ยาฝัง"; } elseif ($row[drugtypesub] == "4") { $apptypename = "ห่วง"; } elseif ($row[drugtypesub] == "5") { $apptypename = "ถุงยางอนามัย"; } elseif ($row[drugtypesub] == "6") { $apptypename = "หมันชาย"; } else { $apptypename = "หมันหญิง"; } if ($row[datedue] == "") { $appsick = ""; } else { $appsick = retDatets($row[datedue]); } if ($row[datechk] == "") { $sick = ""; } else { $sick = retDatets($row[datechk]); } if ($row[datechk] == "") { $sicksign = "ขาดนัด"; } else { $sicksign = "มาตามนัด"; } $xml .= '<marker '; $xml .= 'pid="' . $row[pid] . '" '; $xml .= 'pname="' . $row[pname] . '" '; $xml .= 'age="' . $row[age] . '" '; $xml .= 'hno="' . $row[hno] . '" '; $xml .= 'moo="' . $moo . '" '; $xml .= 'appsick="' . $appsick . '" '; $xml .= 'apptypename="' . $apptypename . '" '; $xml .= 'sicksign="' . $sicksign . '" '; $xml .= 'lat="' . $row[ygis] . '" '; $xml .= 'lng="' . $row[xgis] . '" '; $xml .= '/>'; } $xml .= '</markers>'; echo $xml; }
include "../includes/config.inc.php"; //ดึงชื่อสถานบริการ $sql = "SELECT\n concat('สถานบริการ(สถานีอนามัย/PCU): ',chospital.`hosname`,' หมู่ที่:',ifnull(chospital.`mu`,'...'),' ต.',\n\tifnull(csubdistrict.`subdistname`,' ...'),' อ.',ifnull(cdistrict.`distname`,' ...'),' จ.',\n\tifnull(cprovince.`provname`,'...')) AS chospital_hosname\nFROM\n `chospital` chospital \n INNER JOIN `office` office ON chospital.`hoscode` = office.`offid`\n left outer join `csubdistrict` csubdistrict ON chospital.`provcode` = csubdistrict.`provcode`\n AND chospital.`distcode` = csubdistrict.`distcode`\n AND chospital.`subdistcode` = csubdistrict.`subdistcode`\n left outer JOIN `cdistrict` cdistrict ON chospital.`provcode` = cdistrict.`provcode`\n AND chospital.`distcode` = cdistrict.`distcode`\n INNER JOIN `cprovince` cprovince ON chospital.`provcode` = cprovince.`provcode`"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $hosp = $row[chospital_hosname]; $village = $_GET[village]; if ($village == '00000000') { $ect2 = ""; } else { $ect2 = " house.villcode = '{$village}' AND "; } if ($village == "00000000") { $ect3 = "ทุกหมู่บ้าน"; } else { $ect3 = getvillagename($village); } //ตัวแปร array ที่ใ้ชสำหรับแสดงกราฟ $villname = array(); // ตัวแปรแกน x //ตัวแปรแกน y $couuntofhcode = array(); //หมดตัวแปรแกน y //sql สำหรับดึงข้อมูล จาก jhcis $sql = "SELECT count(distinct house.hcode) as couuntofhcode,\nhouse.villcode,\nvillage.villname \nFROM house\nINNER JOIN village on village.pcucode = house.pcucode and village.villcode = house.villcode \nWHERE {$ect2} SUBSTRING(house.villcode,7,2) <> '00'\ngroup by house.villcode\nORDER BY house.villcode"; //จบ sql $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { //array_push คือการนำค่าที่ได้จาก sql ใส่เข้าไปตัวแปร array array_push($couuntofhcode, $row[couuntofhcode]); array_push($villname, $row[villname]);