示例#1
0
 public function convertSingleToArray($data)
 {
     $tableInfo = Utility::getTableInfo($data->getTableid());
     $config = Utility::getConfig();
     $code = '';
     $value = '';
     $desc = '';
     if ($data->getCouponId() != -1) {
         $coupon = Utility::getCouponInfo($data->getCouponId());
         //            echo '<pre>';
         //            print_r($coupon);
         //            echo '</pre>';
         $code = $coupon->getCode();
         if ($coupon->getReuse() == 1) {
             $code = $coupon->getDescription();
         }
         $type = $coupon->getType();
         if ($type == 0) {
             $value = 'Reduce :' . number_format($coupon->getValue()) . ' ' . $config['currency'];
         } else {
             $value = 'Reduce :' . $coupon->getValue() . '%';
         }
         $desc = $coupon->getDescription();
     }
     $userInfo = Utility::getUserInfo($data->getUserId());
     $surtax = Utility::getSurTaxInfo($data->getSurtaxId());
     if ($surtax) {
         $surtaxType = $surtax->getType();
         $surtaxValue = $surtax->getValue();
     } else {
         $surtaxType = 'Cash';
         $surtaxValue = 0;
     }
     $taxType = Utility::convertSurtaxType($surtaxType);
     //print_r($coupon);
     $array = array();
     $array['id'] = $data->getId();
     $array['tableId'] = $tableInfo->getName();
     $array['createDate'] = date('d/m/Y h:i:s', $data->getCreateDate());
     $array['totalCost'] = number_format($data->getTotalCost());
     $array['totalRealCost'] = number_format($data->getTotalRealCost());
     $array['coupon'] = $code;
     $array['couponValue'] = $value;
     $array['couponDesc'] = $desc;
     $array['surtax'] = number_format($surtaxValue) . ' ' . $taxType;
     $array['userid'] = $userInfo->getUserName();
     $array['status'] = $data->getStatus();
     $array['customer_id'] = $data->getCustomerId();
     $array['newDate'] = $data->getNewDate();
     return $array;
 }
示例#2
0
 public function convertSingleToArray($data)
 {
     $menuInfo = Utility::getMenuInfo($data->getMenuId());
     $menuCostType = Utility::getMenuCostType($data->getCostType());
     $couponInfo = Utility::getCouponInfo($data->getDiscount());
     $array = array();
     $array['id'] = $data->getId();
     $array['orderid'] = 'Order #' . $data->getOrderId();
     $array['menuid'] = '<a href="/admin/index/add/' . $data->getMenuId() . '" target="_blank" >' . $menuInfo->getName() . '</a>';
     $array['quantity'] = $data->getQuantity();
     $array['menucost'] = Utility::formatCost($data->getMenuCost());
     $array['menucosttype'] = $menuCostType;
     $array['discount'] = $couponInfo->getDescription();
     $array['realcost'] = Utility::formatCost($data->getRealCost());
     return $array;
 }
示例#3
0
    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;
        }
    }