/** * method searchBooking by date, customer name, customer id, customner phone * @param $date * @param $customerName * @param $id (CMND) * @param $numberphone * @return Gui html * @author thanhtuan */ public function searchBooking($date, $customerName, $id, $numberphone) { // make $to from $from $from = new DateTime($date); $to = new DateTime($date); $to->modify("+1 day"); $dao = new BookingDAO(); $arr = $dao->search($from->format('Y-m-d H:i:s'), $to->format('Y-m-d H:i:s'), $customerName, $id); $data = ""; $data = $data . "<table>\r\n\t\t<table>\r\n\t\t<tr>\r\n\t\t<th>Mã phiếu</th>\r\n\t\t<th>Ngày lập</th>\r\n\t\t<th>Họ tên khách hàng</th>\r\n\t\t<th>Số CMND</th>\r\n\t\t<th>Số điện thoại</th>\r\n\t\t<th>Người tiếp nhận</th>\r\n\t\t</tr>"; foreach ($arr as $value) { $MaPhieu = isset($value["MaPhieu"]) ? $value["MaPhieu"] : ""; $NgayLap = isset($value["NgayLap"]) ? $value["NgayLap"] : ""; $HoTenKH = isset($value["HoTenKH"]) ? $value["HoTenKH"] : ""; $CMND = isset($value["CMND"]) ? $value["CMND"] : ""; $SDT = isset($value["SDT"]) ? $value["SDT"] : ""; $NguoiTiepNhan = isset($value["NguoiTiepNhan"]) ? $value["NguoiTiepNhan"] : ""; $data = $data . "<tr>"; $data = $data . "<td><a href='javascript:selectBooking(\"" . $MaPhieu . "\")'>{$MaPhieu}</a></td>"; $data = $data . "<td>{$NgayLap}</td>"; $data = $data . "<td>{$HoTenKH}</td>"; $data = $data . "<td>{$CMND}</td>"; $data = $data . "<td>{$SDT}</td>"; $data = $data . "<td>{$NguoiTiepNhan}</td>"; $data = $data . "</tr>"; } $data = $data . "</table>"; return $data; }
/** * main save_Booking method * @param $bookingInfo array customer info: customer name, id number, phone number * @param $tableId array * @param $fromDate array * @param $toDate array * @author hathao298@gmail.com, thanhtuan * @return return true if success else return false * * */ public function saveBooking($bookingInfo, $tableId, $fromDate, $toDate) { try { //check table id $dao = new TableDAO(); $price = array(); foreach ($tableId as $id) { $table = $dao->getTableInfo($id); if ($table == null) { return "invalid"; } else { array_push($price, $table["GiaThanh"]); } } // prepare data to saving $arrBookingInfo = array(); $arrBookingDetailInfo = array(); for ($i = 0; $i < sizeof($tableId); $i++) { $bookingDetailInfo = array("MaBanAn" => $tableId[$i], "MaNH" => $bookingInfo["MaNH"], "MaPhieu" => $bookingInfo["MaPhieu"], "GiaThanh" => $price[$i], "TuThoiGian" => $fromDate[$i], "DenThoiGian" => $toDate[$i]); array_push($arrBookingDetailInfo, $bookingDetailInfo); } //save data try { $dao = new BookingDAO(); return $dao->save($bookingInfo, $arrBookingDetailInfo); } catch (Exception $e) { return false; } return false; } catch (Exception $e) { echo "Not Connect to database"; } return false; }