Index: mhs4/Diet.Class.php
===================================================================
--- mhs4/Diet.Class.php	(revision 7968)
+++ mhs4/Diet.Class.php	(working copy)
@@ -249,6 +249,9 @@
 			case "Diet/api/searchMeal":
 				$result = $this->searchMeal($a);
 				break;
+			case "Diet/api/fetchOrders":
+				$result = $this->fetchOrders($a);
+				break;
 			case "Diet/api/fetchMeals":
 				$result = $this->fetchMeals($_REQUEST);
 				break;
@@ -367,7 +370,7 @@
 					selectWard=>$selectWard,
              );
 		}
-		
+		/*
 		function choiceMeal(&$view){
 			
 			$view = 'Diet/choiceMeal.pug';
@@ -401,6 +404,56 @@
 
              );
 		}
+		*/
+		function fetchOrders($a){
+			if($a[selectWard])
+				$ward = " and ward=:selectWard ";
+			if($a[guardian])
+				$guardian = " and forguardian=:guardian ";
+			if($a[alt])
+				$alt = " and mealtype='선택식' ";
+			if($a[mealtime])
+				$mealtime = " and mealtime=:mealtime ";
+			$orders = query("
+				select c.*, b.*, a.* from mealorder a
+					join uis.ocs_patient b on
+						patientno=b.no
+						
+					left join wardmap c on	
+						c.room=b.room and c.bedno=b.bedno
+					where
+						date>=:startDate and date<=:endDate
+						$ward
+						$alt
+						$guardian
+						$mealtime
+					order by ward, c.room, c.bedno
+					limit 1000
+			", $a);
+			$tastes = array();
+			foreach($orders as &$o) {
+				$pno = $o[patientno];
+				if (!$tastes[$pno]) // query수 줄이기
+					$tastes[$pno] = query("select content from mealtaste 
+					join mealorderoption b on mealoptionno=b.no
+					where patientno=:patientno and checked=1", $o);
+				$o[tastes] = $tastes[$pno];
+			}
+			if($a[tastes]) {
+				$orders = array_filter($orders, function($o){
+					return count($o[tastes]) > 0;
+				});
+			}
+			return $orders;
+		}
+		function Orders(&$view){
+			$view = 'Diet/orders.pug';
+			$a = $_REQUEST;
+			return array(
+				wards=>query("select * from s4ward where hid='IM39'",$a),
+			);
+		}
+
 		function searchSummary(&$view){
 			
 			$a = $_REQUEST;
Index: mhs4/Mail.Class.php
===================================================================
--- mhs4/Mail.Class.php	(revision 7968)
+++ mhs4/Mail.Class.php	(working copy)
@@ -21,7 +21,13 @@
 		{
 			if($a[limit])
 				$limit = "limit $a[limit]";
-				
+			/*
+			print_r($a);
+			echo "Select * from mail where 
+				hid=:hid and room=:room and bedno=:bedno 
+				and done=0 
+				$limit";
+			*/
 			$rows = query("Select * from mail where 
 				hid=:hid and room=:room and bedno=:bedno 
 				and done=0 
Index: mhs4/Stats.Class.php
===================================================================
--- mhs4/Stats.Class.php	(revision 7968)
+++ mhs4/Stats.Class.php	(working copy)
@@ -87,7 +87,8 @@
 				if($a[objective] && $a[objective] != 'all')
 						$objective = " and a.name=:objective ";
 				$menu = query("select content from s4log group by content", $a);
-				$wardList = query("select ward from wardmap group by ward", $a);
+				//$wardList = query("select ward from wardmap group by ward", $a);
+				$wardList = query("select name from s4ward", $a);
 				$data = query("SELECT  visittime, ward, room, bedno, content FROM s4log order by visittime desc limit 100", $a);
 
 				return array(
@@ -110,7 +111,8 @@
 						$objective = " and a.name=:objective ";
 
 				$menu = query("select content from s4log group by content", $a);
-				$wardList = query("select ward from wardmap group by ward", $a);
+				//$wardList = query("select ward from wardmap group by ward", $a);
+				$wardList = query("select name from s4ward", $a);
 				$sumCnt = query ("select count(*) cnt from s4log", $a);
 				$data = query("SELECT max(ward) ward, max(room) room, max(bedno) bedno, max(content) content  , COUNT(*) cnt, round( (COUNT(*)/(select COUNT(*) from s4log )*100),2) percent FROM `s4log` GROUP by content", $a);
 
Index: mhs4/view/Stats/list.pug
===================================================================
--- mhs4/view/Stats/list.pug	(revision 7968)
+++ mhs4/view/Stats/list.pug	(working copy)
@@ -18,7 +18,7 @@
 		select.form-control(id="selectWard" class="selectOption")
 			option 전체
 			template(v-for="w in wardList") 
-				option(:title='w.ward') {{w.ward}}
+				option(:title='w.name') {{w.name}}
 				
 	input(class="search btn btn-secondary btn-align" type="button" id="searchBtn" v-on:click="search" value="검색")
 	input(class="download btn btn-secondary" type="button" id="downloadBtn" v-on:click="downloadExcel" value="엑셀 다운로드")
Index: mhs4/view/Stats/summary.pug
===================================================================
--- mhs4/view/Stats/summary.pug	(revision 7968)
+++ mhs4/view/Stats/summary.pug	(working copy)
@@ -17,7 +17,7 @@
 		select.form-control(id="selectWard" class="selectOption")
 			option 전체
 			template(v-for="w in wardList") 
-				option(:title='w.ward') {{w.ward}}
+				option(:title='w.name') {{w.name}}
 				
 	input(class="search btn btn-secondary btn-align" type="button" id="searchBtn" v-on:click="search" value="검색")
 	input(class="download btn btn-secondary" type="button" id="downloadBtn" v-on:click="downloadExcel" value="엑셀 다운로드")
