/** * Statictics by time. * @param MongoDate $from * @param MongoDate $to * @return array */ private function staticticsFoodByTime($from, $to) { $fDao = new FoodDAO(); $d = new MongoDate(strtotime($to)); // echo date("Y-m-d H:i:s", $d->sec); $foodWithUnitPrices = $fDao->getListFoodWithUnitPrice($from, $to); // 2. Compute total values $result = array(); foreach ($foodWithUnitPrices as $key => $food) { $temp["MaMonAn"] = $food["MaMonAn"]; $temp["TenMonAn"] = $food["TenMonAn"]; $revenues = $fDao->getFoodAmout($food["MaChiTietThucDon_MonAn"]); $temp["TongDoanhThu"] = $revenues == null ? 0 : $revenues; $result[] = $temp; } return $result; }
/** * show table html food info confirmation. * @param unknown_type $MaCTThucDon_MonAns * @param unknown_type $amounts */ public function htmlShowFoodInfoConfirmTable($MaCTThucDon_MonAns, $amounts, $bookingID) { $idSize = count($MaCTThucDon_MonAns); $amountSize = count($amounts); if ($idSize != $amountSize) { return; } $html = '<table> <tr> <th>Món ăn</th> <th>Đơn giá</th> <th>Số lượng</th> <th>Thành tiền</th> </tr>'; $total = 0; $dao = new FoodDAO(); for ($i = 0; $i < $idSize; $i++) { $data = $dao->getFoodByMenuFoodDetailID($MaCTThucDon_MonAns[$i]); $value = $amounts[$i] * $data["DonGia"]; $total += $value; // generate html $html .= "<tr><td class='cell_import' value=\"" . $data["MaChiTietThucDon_MonAn"] . "\">" . $data["TenMonAn"] . "</td>"; $html .= ' <td class="cell_import">' . $data["DonGia"] . '</td> <td class="cell_import">' . $amounts[$i] . '</td> <td class="cell_import">' . $value . '</td> </tr> '; } $html .= '</table>'; $overview = '<p>Xin xác nhận lại thông tin đã nhập và nhấp "Lưu"</p>'; $overview .= '<table> <tr> <td>Ngày lập</td> <td>' . date("Y-m-d H:i:s"); $overview .= '</td> </tr> <tr> <td>Mã phiếu đặt chỗ</td> <td>' . $bookingID; $overview .= '</td> </tr> <tr> <td>Tổng tiền</td> <td id="total">' . $total; $overview .= '</td> </tr> </table>'; return $overview . $html; }