public function ajaxDetailOrderAction() { $response = array(); $coupons = Utility::getCouponCheckExpire(); $couponHtml = ''; foreach ($coupons as $coupon) { $couponHtml .= '<option value="' . $coupon->getId() . '">' . $coupon->getDescription() . '</option>'; } if ($this->getRequest()->isXmlHttpRequest()) { $orderId = $this->params()->fromPost('order_id'); $orderDetailModel = $this->modelOrderDetail->findBy(array('orderId' => $orderId)); $html = ''; $response['data'] = ''; if (!empty($orderDetailModel)) { foreach ($orderDetailModel as $orderDetail) { $menu = Utility::getMenuInfo($orderDetail->getMenuId()); $counponInfo = Utility::getCouponInfo($orderDetail->getDiscount()); $html .= '<tr> <td > ' . $menu->getName() . ' <input type="hidden" name="data' . $orderDetail->getId() . '[orderDetailId]" value="' . $orderDetail->getId() . '" /> </td> <td>' . $orderDetail->getRealCost() . '</td> <td> ' . $orderDetail->getQuantity() . ' <input type="hidden" name="data' . $orderDetail->getId() . '[menuCost]" value="' . $orderDetail->getMenuCost() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[menuId]" value="' . $orderDetail->getMenuId() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[costType]" value="' . $orderDetail->getCostType() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[oldQty]" value="' . $orderDetail->getQuantity() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[discountValue]" value="' . $counponInfo->getValue() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[discountId]" value="' . $counponInfo->getId() . '" /> <input type="hidden" name="data' . $orderDetail->getId() . '[discountType]" value="' . $counponInfo->getType() . '" /> </td> <td> <input type="text" name="data' . $orderDetail->getId() . '[qty]" class="input-small" /> </td> <td> <select name="data' . $orderDetail->getId() . '[newCoupon]"> <option value="-1">Select...</option> ' . $couponHtml . ' </select> </td> </tr>'; } $response['data'] = $html; $response['oldOrderId'] = $orderId; } echo json_encode($response); die; } }