<?php $merchant_maximum_order = Yii::app()->functions->getOption("merchant_maximum_order", $merchant_id); ?> <?php if (is_numeric($merchant_maximum_order)) { ?> <?php echo CHtml::hiddenField('merchant_maximum_order', unPrettyPrice($merchant_maximum_order)); echo CHtml::hiddenField('merchant_maximum_order_pretty', baseCurrency() . prettyFormat($merchant_maximum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Maximum Order is"); ?> <?php echo displayPrice(baseCurrency(), prettyFormat($merchant_maximum_order, $merchant_id)); ?> </p> <?php } ?> <div class="delivery_options uk-form" style="margin-top:10px;"> <h5><?php echo Yii::t("default", "Delivery Options"); ?> </h5> <?php echo CHtml::dropDownList('delivery_type', $now, (array) Yii::app()->functions->DeliveryOptions($merchant_id)); ?>
public function getCart() { $merchant_id = isset($this->data['mtid']) ? $this->data['mtid'] : ''; if (!is_numeric($merchant_id)) { echo Yii::t("default", "Merchant ID is missing"); return; } $is_merchant_open = Yii::app()->functions->isMerchantOpen($merchant_id); $is_merchant_open1 = $is_merchant_open; $merchant_preorder = Yii::app()->functions->getOption("merchant_preorder", $merchant_id); $disbabled_table_booking = Yii::app()->functions->getOption("merchant_table_booking", $merchant_id); if ($merchant_preorder == 1) { $is_merchant_open = true; } echo CHtml::hiddenField('is_merchant_open', $is_merchant_open == true ? 1 : 2); $close_msg = Yii::app()->functions->getOption("merchant_close_msg", $merchant_id); if (empty($close_msg)) { $close_msg = Yii::t("default", "This restaurant is closed now. Please check the opening times."); } ?> <div class="order-list-wrap"> <h5><?php echo Yii::t("default", "Your Order"); ?> </h5> <div class="item-order-wrap"></div> <!--END item-order-wrap--> <!--VOUCHER STARTS HERE--> <?php //Widgets::applyVoucher($merchant_id); ?> <!--VOUCHER STARTS HERE--> <?php $minimum_order = Yii::app()->functions->getOption('merchant_minimum_order', $merchant_id); ?> <?php if (!empty($minimum_order)) { ?> <?php echo CHtml::hiddenField('minimum_order', unPrettyPrice($minimum_order)); //echo CHtml::hiddenField('minimum_order_pretty',baseCurrency().prettyFormat($minimum_order)) echo CHtml::hiddenField('minimum_order_pretty', prettyFormat($minimum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Subtotal must exceed"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?> <?php $merchant_maximum_order = Yii::app()->functions->getOption("merchant_maximum_order", $merchant_id); ?> <?php if (is_numeric($merchant_maximum_order)) { ?> <?php echo CHtml::hiddenField('merchant_maximum_order', unPrettyPrice($merchant_maximum_order)); echo CHtml::hiddenField('merchant_maximum_order_pretty', baseCurrency() . prettyFormat($merchant_maximum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Maximum Order is"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?> <div class="delivery_options uk-form" style="margin-top:10px;"> <h5><?php echo Yii::t("default", "Delivery Options"); ?> </h5> <?php echo CHtml::dropDownList('delivery_type', $now, (array) Yii::app()->functions->DeliveryOptions($merchant_id)); ?> <?php echo CHtml::textField('delivery_date', $now, array('class' => "j_date")); ?> <?php echo CHtml::textField('delivery_time', $now_time, array('class' => "timepick", 'placeholder' => Yii::t("default", "Delivery Time"))); ?> <span class="uk-text-small uk-text-muted"><?php echo Yii::t("default", "Delivery ASAP?"); ?> </span> <?php echo CHtml::checkBox('delivery_asap', false, array('class' => "icheck")); ?> </div> <?php if (yii::app()->functions->validateSellLimit($merchant_id)) { ?> <?php if ($is_merchant_open1) { ?> <a href="javascript:;" class="uk-button checkout"><?php echo Yii::t("default", "Checkout"); ?> </a> <?php } else { ?> <?php if ($merchant_preorder == 1) { ?> <a href="javascript:;" class="uk-button checkout"><?php echo Yii::t("default", "Pre-Order"); ?> </a> <?php } else { ?> <p class="uk-alert uk-alert-warning"><?php echo Yii::t("default", "Sorry merchant is closed."); ?> </p> <p><?php echo prettyDate(date('c'), true); ?> </p> <?php } ?> <?php } ?> <?php } else { ?> <?php $msg = Yii::t("default", "This merchant is not currently accepting orders."); ?> <p class="uk-text-danger"><?php echo $msg; ?> </p> <?php } ?> </div> <!--order-list-wrap--> <?php die; }
public function rptAdminSalesRpt() { $and = ''; if (isset($this->data['start_date']) && isset($this->data['end_date'])) { if (!empty($this->data['start_date']) && !empty($this->data['end_date'])) { $and = " AND date_created BETWEEN '" . $this->data['start_date'] . " 00:00:00' AND \r\n\t \t\t '" . $this->data['end_date'] . " 23:59:00'\r\n\t \t\t "; } } $order_status_id = ''; $or = ''; if (isset($this->data['stats_id'])) { if (is_array($this->data['stats_id']) && count($this->data['stats_id']) >= 1) { foreach ($this->data['stats_id'] as $stats_id) { $order_status_id .= "'{$stats_id}',"; } if (!empty($order_status_id)) { $order_status_id = substr($order_status_id, 0, -1); } } } if (!empty($order_status_id)) { $and .= " AND status IN ({$order_status_id})"; } $DbExt = new DbExt(); $merchant_id = isset($this->data['merchant_id']) ? $this->data['merchant_id'] : ''; $stmt = "SELECT a.*,\r\n\t \t(\r\n\t \tselect concat(first_name,' ',last_name)\r\n\t \tfrom\r\n\t \t{{client}}\r\n\t \twhere\r\n\t \tclient_id=a.client_id\r\n\t \t) as client_name,\r\n\t \t\r\n\t \t(\r\n\t \tselect group_concat(item_name)\r\n\t \tfrom\r\n\t \t{{order_details}}\r\n\t \twhere\r\n\t \torder_id=a.order_id\r\n\t \t) as item\r\n\t \t\r\n\t \tFROM\r\n\t \t{{order}} a\r\n\t \tWHERE\r\n\t \tmerchant_id='{$merchant_id}'\r\n\t \tAND status NOT IN ('" . initialStatus() . "')\t \t\r\n\t \t{$and}\r\n\t \tORDER BY order_id DESC\r\n\t \tLIMIT 0,2000\r\n\t \t"; /*dump($this->data); dump($stmt);*/ $_SESSION['kr_export_stmt'] = $stmt; if ($res = $DbExt->rst($stmt)) { foreach ($res as $val) { $action = "<a data-id=\"" . $val['order_id'] . "\" class=\"edit-order\" href=\"javascript:\">" . Yii::t("default", "Edit") . "</a>"; $action .= "<a data-id=\"" . $val['order_id'] . "\" class=\"view-receipt\" href=\"javascript:\">" . Yii::t("default", "View") . "</a>"; /*$date=prettyDate($val['date_created'],true); $date=Yii::app()->functions->translateDate($date);*/ $date = FormatDateTime($val['date_created']); $feed_data['aaData'][] = array($val['order_id'], ucwords($val['client_name']), $val['item'], ucwords(Yii::t("default", $val['trans_type'])), strtoupper(Yii::t("default", $val['payment_type'])), prettyFormat($val['sub_total'], $merchant_id), prettyFormat($val['tax'], $merchant_id), prettyFormat($val['total_w_tax'], $merchant_id), ucwords($val['status']), $date); } $this->otableOutput($feed_data); } $this->otableNodata(); }
public static function salesReceipt($data = '', $item_details = '') { $tr = ""; if (is_array($data) && count($data) >= 1) { foreach ($data as $val) { $tr .= "<tr>"; $tr .= "<td>" . $val['label'] . "</td>"; $tr .= "<td>" . $val['value'] . "</td>"; $tr .= "</tr>"; } } $mid = isset($item_details['total']['mid']) ? $item_details['total']['mid'] : ''; //dump($mid); $tr .= "<tr>"; $tr .= "<td colspan=\"2\"> </td>"; $tr .= "</tr>"; if (isset($item_details['item'])) { if (is_array($item_details['item']) && count($item_details['item']) >= 1) { foreach ($item_details['item'] as $item) { //dump($item); $notes = ''; $item_total = $item['qty'] * $item['discounted_price']; if (!empty($item['order_notes'])) { $notes = "<p>" . $item['order_notes'] . "</p>"; } $cookref = ''; if (!empty($item['cooking_ref'])) { $cookref = "<p>" . $item['cooking_ref'] . "</p>"; } $size = ''; if (!empty($item['size_words'])) { $size = "<p>" . $item['size_words'] . "</p>"; } $tr .= "<tr>"; $tr .= "<td>" . $item['qty'] . " " . $item['item_name'] . $size . $notes . $cookref . "</td>"; $tr .= "<td>" . prettyFormat($item_total, $mid) . "</td>"; $tr .= "</tr>"; if (isset($item['sub_item'])) { foreach ($item['sub_item'] as $itemsub) { $subitem_total = $itemsub['addon_qty'] * $itemsub['addon_price']; $tr .= "<tr>"; $tr .= "<td style=\"text-indent:10px;\">" . $itemsub['addon_name'] . "</td>"; $tr .= "<td>" . prettyFormat($subitem_total, $mid) . "</td>"; $tr .= "</tr>"; } } } } } $tr .= "<tr>"; $tr .= "<td colspan=\"2\"> </td>"; $tr .= "</tr>"; //dump($item_details['total']); if (isset($item_details['total'])) { $tr .= "<tr>"; $tr .= "<td>" . Yii::t("default", "Subtotal") . ":</td>"; $tr .= "<td>" . prettyFormat($item_details['total']['subtotal'], $mid) . "</td>"; $tr .= "</tr>"; if (!empty($item_details['total']['delivery_charges'])) { $tr .= "<tr>"; $tr .= "<td>" . Yii::t("default", "Delivery Fee") . ":</td>"; $tr .= "<td>" . prettyFormat($item_details['total']['delivery_charges'], $mid) . "</td>"; $tr .= "</tr>"; } $tr .= "<tr>"; $tr .= "<td>" . Yii::t("default", "Tax") . " " . $item_details['total']['tax_amt'] . "%</td>"; $tr .= "<td>" . prettyFormat($item_details['total']['taxable_total'], $mid) . "</td>"; $tr .= "</tr>"; $tr .= "<tr>"; $tr .= "<td>" . Yii::t("default", "Total") . ":</td>"; $tr .= "<td>" . $item_details['total']['curr'] . prettyFormat($item_details['total']['total'], $mid) . "</td>"; $tr .= "</tr>"; } ob_start(); ?> <div style="display: block;max-height: 70px;max-width: 200px;"> <?php echo Widgets::receiptLogo(); ?> </div> <h3><?php echo Yii::t("default", "Order Details"); ?> </h3> <table border="0"> <?php echo $tr; ?> </table> <?php $receipt = ob_get_contents(); ob_end_clean(); return $receipt; }
public function faxSendNotification($merchant_info = '', $package_id = '', $payment_method = '', $price) { $fax_email_notification = Yii::app()->functions->getOptionAdmin("fax_email_notification"); /*dump($merchant_info); dump($package_id); dump($payment_method);*/ $package_info = $this->getFaxPackagesById($package_id); if (!empty($fax_email_notification) && is_array($package_info) && count($package_info) >= 1) { $tpl = EmailTPL::faxNotification(); $tpl = smarty('merchant-name', $merchant_info['restaurant_name'], $tpl); $tpl = smarty('amount', displayPrice(getCurrencyCode(), prettyFormat($price)), $tpl); $tpl = smarty('payment-method', $payment_method, $tpl); $tpl = smarty('package-name', $package_info['title'], $tpl); sendEmail($fax_email_notification, '', "New Fax Payment Has been receive", $tpl); } }
$minimum_order = Yii::app()->functions->getOption('merchant_minimum_order', $merchant_id); ?> <?php if (!empty($minimum_order)) { ?> <?php echo CHtml::hiddenField('minimum_order', unPrettyPrice($minimum_order)); echo CHtml::hiddenField('minimum_order_pretty', baseCurrency() . prettyFormat($minimum_order)); ?> <p class="uk-text-muted"><?php echo Yii::t("default", "Subtotal must exceed"); ?> <?php echo baseCurrency() . prettyFormat($minimum_order, $merchant_id); ?> </p> <?php } ?> <div class="spacer2"></div> <a href="javascript:;" class="uk-button uk-button-success place_order"><?php echo Yii::t("default", "Place Order"); ?> </a> </div> <!--order-list-wrap--> </div> <!--grid-2--> <div class="clear"></div>
<?php if ($val['promo_price'] >= 1) { ?> <span class="normal-price"> <?php echo Yii::app()->functions->adminCurrencySymbol() . prettyFormat($val['price']); ?> </span> <?php echo Yii::app()->functions->adminCurrencySymbol() . prettyFormat($val['promo_price']); ?> <?php } else { ?> <?php echo Yii::app()->functions->adminCurrencySymbol() . prettyFormat($val['price']); ?> <?php } ?> </h3> <p class="uk-text-muted"><?php echo $val['description']; ?> </p> <p class="even"> <?php if ($val['expiration_type'] == "year") { ?> <?php echo Yii::t("default", "Membership Limit");
public function displayMenu($menu = '', $mode = '', $mtid = '') { ?> <?php if ($mode == 2 || $mode == 1) { ?> <div class="<?php echo $mode == 2 ? "active-menu-2" : "active-menu-{$mode}"; ?> "> <div class="categories-wrap-mobile"> <div data-uk-dropdown="{mode:'click'}" class="uk-button-dropdown"> <button class="uk-button"><?php echo Yii::t("default", "Categories"); ?> <span class="sortby_text"></span><i class="uk-icon-caret-down"></i></button> <div class="uk-dropdown" > <ul class="uk-nav uk-nav-dropdown"> <?php foreach ($menu as $val) { ?> <li> <a href="javascript:;" data-id="cat-<?php echo $val['category_id']; ?> " class="goto-category"> <?php echo ucwords($val['category_name']); ?> </a> </li> <?php } ?> </ul> </div> </div> </div> <!--categories-wrap--> <!--<div class="clear"></div>--> <?php foreach ($menu as $val) { //dump($val); ?> <h2 class="cat-<?php echo $val['category_id']; ?> "> <?php echo qTranslate($val['category_name'], 'category_name', $val); ?> <?php //echo Widgets::displayCatSpicyIconByID($val['category_id']) ?> <?php echo Widgets::displaySpicyIconNew($val['dish']); ?> </h2> <?php if (!empty($val['category_description'])) { ?> <p><?php echo qTranslate($val['category_description'], 'category_description', $val); ?> </p> <?php } ?> <p style="margin-top:-10px;" class="uk-text-small uk-text-muted"><?php echo Widgets::categorySpicyNotes($val['category_id']); ?> </span> <?php if (is_array($val['item']) && count($val['item']) >= 1) { ?> <?php $x = 1; ?> <?php foreach ($val['item'] as $item) { //dump($item); ?> <?php $atts = ''; if ($item['single_item'] == 2) { $atts .= 'data-price="' . $item['single_details']['price'] . '"'; $atts .= " "; $atts .= 'data-size="' . $item['single_details']['size'] . '"'; } ?> <a href="javascript:;" rel="<?php echo $item['item_id']; ?> " class="menu-item" data-single="<?php echo $item['single_item']; ?> " <?php echo $atts; ?> > <div class="table-div <?php echo count($val['item']) == $x ? "last" : ''; ?> "> <div class="table-col-1"><?php Widgets::displayMenuPic($item['photo']); ?> </div> <div class="table-col-2"> <div class="ux-price"> <samp></samp> <h4> <?php echo qTranslate($item['item_name'], 'item_name', $item); ?> <?php echo Widgets::displaySpicyIconNew($item['dish']); ?> </h4> <?php //echo Widgets::displaySpicyIcon($item['spicydish'],'',$mtid); ?> <h5 class="hide-food-price"> <?php if (!empty($item['discount'])) { ?> <span class="strike-tru"> <?php echo displayPrice(getCurrencyCode(), prettyFormat($item['prices'][0]['price'])); ?> </span> <?php echo displayPrice(getCurrencyCode(), prettyFormat($item['prices'][0]['price'] - $item['discount'])); ?> <?php } else { ?> <?php echo displayPrice(getCurrencyCode(), prettyFormat($item['prices'][0]['price'])); ?> <?php } ?> </h5> </div> <p><?php echo qTranslate($item['item_description'], 'item_description', $item); ?> </p> </div> </div> </a> <?php $x++; ?> <?php } ?> <?php } else { ?> <p class="uk-text-muted"><?php echo t("No food item"); ?> </p> <?php } ?> <?php } ?> </div> <!--active-menu-2--> <?php } ?> <?php }
<label class="uk-form-label"><?php echo Yii::t("default", "Package Name"); ?> </label> <span class="uk-text-muted"><?php echo $info['package_name']; ?> </span> </div> <div class="uk-form-row"> <label class="uk-form-label"><?php echo Yii::t("default", "Package Price"); ?> </label> <span class="uk-text-muted"><?php echo prettyFormat($info['package_price']); ?> </span> </div> <div class="uk-form-row"> <label class="uk-form-label"><?php echo Yii::t("default", "Membership Expired On"); ?> </label> <span class="uk-text-muted"><?php echo $info['membership_expired']; ?> </span> </div> <div class="uk-form-row"> <label class="uk-form-label"><?php
public function displayOrderHTML($data = '', $cart_item = '', $receipt = false, $new_order_id = '') { $item_array = ''; $this->code = 2; $htm = ''; $subtotal = 0; $mid = isset($data['merchant_id']) ? $data['merchant_id'] : ''; if (empty($mid)) { $this->msg = Yii::t("default", "Merchant ID is empty"); return; } Yii::app()->functions->data = "list"; $food_item = Yii::app()->functions->getFoodItemLists($mid); $subcat_list = Yii::app()->functions->getAddOnLists($mid); //dump($cart_item); //dump($food_item); if (isset($cart_item)) { if (is_array($cart_item) && count($cart_item) >= 1) { $x = 0; foreach ($cart_item as $key => $val) { $val['notes'] = isset($val['notes']) ? $val['notes'] : ""; $size_words = ''; $t = !empty($val['price']) ? explode("|", $val['price']) : ''; if (is_array($t) && count($t) >= 1) { $val['price'] = $t[0]; $size_words = $t[1]; } $price = cleanNumber(unPrettyPrice($val['price'])); if (!empty($val['discount'])) { $val['discount'] = unPrettyPrice($val['discount']); $price = $price - $val['discount']; } $qty = $val['qty']; /** fixed addon qty */ $total_price = $val['qty'] * $price; /** check if item is taxable*/ //dump($val); $food_taxable = true; if (isset($val['non_taxable'])) { if ($val['non_taxable'] == 2) { $food_taxable = false; } } $subtotal = $subtotal + $total_price; if ($food_taxable == false) { $subtotal_non = $subtotal_non + $total_price; } /*$size_words=''; if ( $price_size=explodeData($val['price'])){ if (isset($price_size[1])){ $size_words=$price_size[1]; } } */ /** Translation */ $food_infos = ''; $size_info_trans = ''; $cooking_ref_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { $food_info = $this->getFoodItem($val['item_id']); $food_infos['item_name_trans'] = !empty($food_info['item_name_trans']) ? json_decode($food_info['item_name_trans'], true) : ''; if (!empty($size_words)) { $size_info_trans = $this->getSizeTranslation($size_words, $mid); } if (!empty($val['cooking_ref'])) { $cooking_ref_trans = $this->getCookingTranslation($val['cooking_ref'], $mid); } } $htm .= '<div class="item-order-list item-row">'; $htm .= '<div class="a">' . $val['qty'] . '</div>'; $htm .= '<div class="b">' . qTranslate($food_item[$val['item_id']], 'item_name', $food_infos); if (!empty($size_words)) { $htm .= "(" . ucwords(qTranslate($size_words, 'size_name', $size_info_trans)) . ")"; } // array value $item_array[$key] = array('item_id' => $val['item_id'], 'item_name' => $food_item[$val['item_id']], 'size_words' => $size_words, 'qty' => $val['qty'], 'normal_price' => prettyFormat($val['price']), 'discounted_price' => $price, 'order_notes' => isset($val['notes']) ? $val['notes'] : '', 'cooking_ref' => isset($val['cooking_ref']) ? $val['cooking_ref'] : '', 'ingredients' => isset($val['ingredients']) ? $val['ingredients'] : '', 'non_taxable' => isset($val['non_taxable']) ? $val['non_taxable'] : 1); $htm .= Widgets::displaySpicyIconByID($val['item_id']); if (!empty($val['discount'])) { $htm .= "<p class=\"uk-text-small\">" . "<span class=\"normal-price\">" . displayPrice(baseCurrency(), prettyFormat($val['price'])) . " </span>" . "<span class=\"sale-price\">" . displayPrice(baseCurrency(), prettyFormat($price)) . "</span>" . "</p>"; } else { $htm .= "<p class=\"uk-text-small\">" . "<span class=\"base-price\">" . displayPrice(baseCurrency(), prettyFormat($val['price'])) . "</span>" . "</p>"; } if (!empty($val['cooking_ref'])) { $htm .= "<p class=\"uk-text-small\">" . qTranslate($val['cooking_ref'], 'cooking_name', $cooking_ref_trans) . "</p>"; } if (!empty($val['notes'])) { $htm .= "<p class=\"uk-text-small\">" . $val['notes'] . "</p>"; } /*ingredients*/ if (isset($val['ingredients'])) { if (!empty($val['ingredients'])) { if (is_array($val['ingredients']) && count($val['ingredients']) >= 1) { $htm .= "<p class=\"uk-text-small ingredients-label\">" . t("Ingredients") . ":</p>"; foreach ($val['ingredients'] as $val_ingred) { $htm .= "<p class=\"uk-text-small\">" . $val_ingred . "</p>"; } } } } $htm .= '</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="c">'; if ($receipt == false) { $htm .= '<a href="javascript:;" class="edit_item" data-row="' . $key . '" rel="' . $val['item_id'] . '" > <i class="fa fa-pencil-square-o"></i> </a>'; $htm .= '<a href="javascript:;" class="delete_item" data-row="' . $key . '" rel="' . $val['item_id'] . '" > <i class="fa fa-trash-o"></i> </a>'; } $htm .= '</div>'; $htm .= '<div class="d">' . displayPrice(baseCurrency(), prettyFormat($total_price, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="clear"></div>'; /*SUB ITEM*/ //dump($val); //$item_array[$key]['sub_item']=$val['sub_item']; $val['sub_item'] = isset($val['sub_item']) ? $val['sub_item'] : ''; if (is_array($val['sub_item']) && count($val['sub_item']) >= 1) { foreach ($val['sub_item'] as $cat_id => $val_sub) { if (array_key_exists($cat_id, (array) $subcat_list)) { //** Translation */ $subcategory_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { if ($subcategory_tran = $this->getAddonCategory($cat_id)) { $subcategory_trans['subcategory_name_trans'] = !empty($subcategory_tran['subcategory_name_trans']) ? json_decode($subcategory_tran['subcategory_name_trans'], true) : ''; } } $htm .= '<div class="a"></div>'; $htm .= '<div class="b uk-text-success">' . ucwords(qTranslate($subcat_list[$cat_id], 'subcategory_name', $subcategory_trans)) . '</div>'; $htm .= '<div class="clear"></div>'; } $addon_qty = 1; foreach ($val_sub as $addon_row => $val_subs) { if (isset($val['addon_qty'][$cat_id])) { $addon_qty = $val['addon_qty'][$cat_id][$addon_row]; } else { $addon_qty = $addon_qty * $qty; /** fixed addon qty */ /*if ( in_array($val['item_id'],(array)$added_item)){ $addon_qty=0; }*/ } $val_subs = explodeData($val_subs); //dump($val_subs); $addon_raw_price = prettyFormat($val_subs[1]); $addon_item_price = unPrettyPrice($val_subs[1]); $addon_item_price = $addon_qty * $addon_item_price; /** two flavor */ if ($val['two_flavors'] == 2) { if ($val_subs[3] == "") { $subtotal += $addon_item_price; if ($food_taxable == false) { $subtotal_non += $addon_item_price; } } } else { /** check if item is taxable*/ $subtotal += $addon_item_price; if ($food_taxable == false) { $subtotal_non += $addon_item_price; } } $item_array[$key]['sub_item'][] = array('addon_name' => $val_subs[2], 'addon_category' => $subcat_list[$cat_id], 'addon_qty' => $addon_qty, 'addon_price' => unPrettyPrice($val_subs[1])); /**translation */ $addon_name_trans = ''; if ($this->getOptionAdmin("enabled_multiple_translation") == 2) { $addon_name_trans = $this->getAddonTranslation($val_subs[2], $mid); } $htm .= '<div class="a">' . $addon_qty . 'x</div>'; $htm .= '<div class="b uk-text-muted">' . "{$addon_raw_price} " . ucwords(qTranslate($val_subs[2], 'sub_item_name', $addon_name_trans)) . '</div>'; $htm .= '<div class="manage">'; if ($addon_item_price != 0) { $htm .= '<div class="d">' . displayPrice(baseCurrency(), prettyFormat($addon_item_price)) . '</div>'; } else { $htm .= '<div class="d">-</div>'; } $htm .= '</div>'; $htm .= '<div class="clear"></div>'; } } } $htm .= '</div>'; $x++; $added_item[] = $val['item_id']; /** fixed addon qty */ } $taxable_subtotal = 0; $tax_amt = 0; $tax = Yii::app()->functions->getOption('merchant_tax', $mid); //dump($tax); /*if transaction is pickup*/ /*if ($data['delivery_type']=="pickup"){ $tax=0; }*/ $tax_amt = $tax; $delivery_charges = Yii::app()->functions->getOption('merchant_delivery_charges', $mid); //shipping rates if (isset($_SESSION['shipping_fee'])) { if (is_numeric($_SESSION['shipping_fee'])) { $delivery_charges = $_SESSION['shipping_fee']; } } //if (isset($data['delivery_charge']) && $data['delivery_charge']>=1){ if (isset($data['delivery_charge'])) { $delivery_charges = $data['delivery_charge']; } //end shipping rates $merchant_packaging_charge = Yii::app()->functions->getOption('merchant_packaging_charge', $mid); //fixed packaging charge if (isset($data['packaging'])) { if ($data['packaging'] > 0) { $merchant_packaging_charge = $data['packaging']; } } if (!empty($delivery_charges)) { $delivery_charges = unPrettyPrice($delivery_charges); } else { $delivery_charges = 0; } /*if transaction is pickup*/ //dump($data); if ($data['delivery_type'] == "pickup") { $delivery_charges = 0; } /*VOUCHER*/ $has_voucher = false; $less_voucher = 0; $voucher_type = ""; if (isset($_SESSION['voucher_code'])) { if (is_array($_SESSION['voucher_code'])) { $has_voucher = true; //dump($_SESSION['voucher_code']); $_SESSION['voucher_code']['amount'] = unPrettyPrice($_SESSION['voucher_code']['amount']); if ($_SESSION['voucher_code']['voucher_type'] == "fixed amount") { $less_voucher = $_SESSION['voucher_code']['amount']; } else { $less_voucher = $subtotal * ($_SESSION['voucher_code']['amount'] / 100); $voucher_type = normalPrettyPrice($_SESSION['voucher_code']['amount']) . "%"; } $_SESSION['less_voucher'] = $less_voucher; } } if ($receipt == TRUE) { $order_ids = isset($data['order_id']) ? $data['order_id'] : ''; if (isset($_GET['id'])) { $order_ids = $_GET['id']; } $order_infos = $this->getOrderInfo($order_ids); //dump($order_infos); if (!empty($order_infos['voucher_code'])) { $has_voucher = true; if ($order_infos['voucher_type'] == "fixed amount") { $less_voucher = $order_infos['voucher_amount']; } else { $voucher_type = normalPrettyPrice((int) $order_infos['voucher_amount']) . "%"; $less_voucher = $subtotal * ($order_infos['voucher_amount'] / 100); } } } if ($less_voucher == TRUE) { $subtotal = $subtotal - $less_voucher; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $less_voucher; } } /*PROMO STARTS HERE*/ $show_discount = false; $discounted_amount = 0; $merchant_discount_amount = 0; if ($receipt == TRUE) { $_GET['id'] = isset($_GET['id']) ? $_GET['id'] : $new_order_id; if ($promo_res = $this->getOrderDiscount($_GET['id'])) { if ($promo_res['discounted_amount'] >= 0.1) { $show_discount = true; $merchant_discount_amount = number_format($promo_res['discount_percentage'], 0); $discounted_amount = $promo_res['discounted_amount']; $subtotal = $subtotal - $discounted_amount; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $discounted_amount; } } } } else { if ($promo_res = Yii::app()->functions->getMerchantOffersActive($mid)) { $merchant_spend_amount = $promo_res['offer_price']; $merchant_discount_amount = number_format($promo_res['offer_percentage'], 0); if ($subtotal >= $merchant_spend_amount) { $show_discount = true; $merchant_discount_amount1 = $merchant_discount_amount / 100; $discounted_amount = $subtotal * $merchant_discount_amount1; $subtotal = $subtotal - $discounted_amount; /** check if item is taxable*/ if ($food_taxable == false) { $subtotal_non = $subtotal_non - $discounted_amount; } } } } /**above sub total free delivery*/ $free_delivery = false; if ($data['delivery_type'] == "delivery") { $free_delivery_above_price = Yii::app()->functions->getOption("free_delivery_above_price", $mid); if (!empty($free_delivery_above_price)) { if ($subtotal >= $free_delivery_above_price) { $delivery_charges = 0; $free_delivery = true; } } } /**above sub total free delivery*/ /** packaging incremental*/ if (Yii::app()->functions->getOption("merchant_packaging_increment", $mid) == 2) { if (!isset($data['packaging'])) { $total_cart_item = 0; foreach ($cart_item as $cart_item_x) { $total_cart_item += $cart_item_x['qty']; } $merchant_packaging_charge = $total_cart_item * $merchant_packaging_charge; } } if (!empty($tax)) { $tax = $tax / 100; /** check if item is taxable*/ $temp_delivery_charges = $delivery_charges; if (Yii::app()->functions->getOption("merchant_tax_charges", $merchant_id) == 2) { $temp_delivery_charges = 0; } if ($receipt == true) { if (isset($data['donot_apply_tax_delivery'])) { if ($data['donot_apply_tax_delivery'] == 2) { $temp_delivery_charges = 0; } } } if ($subtotal_non >= 1) { $temp_subtotal = $subtotal - $subtotal_non; $taxable_subtotal = ($temp_subtotal + $temp_delivery_charges + $merchant_packaging_charge) * $tax; } else { $taxable_subtotal = ($subtotal + $delivery_charges + $merchant_packaging_charge) * $tax; } /*dump($subtotal); dump($subtotal_non); dump("taxable_subtotal=>".$taxable_subtotal);*/ } $total = $subtotal + $taxable_subtotal + $delivery_charges + $merchant_packaging_charge; $htm .= '<div class="summary-wrap">'; if ($has_voucher == TRUE) { if ($show_discount == true) { $htm .= '<div class="a">' . t("Discount") . " {$merchant_discount_amount}%" . ':</div>'; $htm .= '<div class="manage manage-ux">'; $htm .= '<div class="b">(' . displayPrice(baseCurrency(), prettyFormat($discounted_amount, $mid)) . ')</div>'; $htm .= '</div>'; } /*$cart_subtotal_raw=$subtotal+$less_voucher; $htm.="<span class=\"cart_subtotal_raw\" data-value=\"$cart_subtotal_raw\" ></span>";*/ $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b cart_subtotal">' . displayPrice(baseCurrency(), prettyFormat($subtotal + $less_voucher, $mid)) . '</div>'; $htm .= '</div>'; if ($receipt == TRUE) { $voucher_code = " - " . $order_infos['voucher_code'] . ""; } else { $voucher_code = ''; } $htm .= '<div class="a">' . Yii::t("default", "Less Voucher") . " " . $voucher_type . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">-' . displayPrice(baseCurrency(), prettyFormat($less_voucher, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($subtotal, $mid)) . '</div>'; $htm .= '</div>'; } else { if ($show_discount == true) { $htm .= '<div class="a">' . t("Discount") . " {$merchant_discount_amount}%" . ':</div>'; $htm .= '<div class="manage manage-ux">'; $htm .= '<div class="b">(' . displayPrice(baseCurrency(), prettyFormat($discounted_amount, $mid)) . ')</div>'; $htm .= '</div>'; } /*$cart_subtotal_raw=$subtotal; $htm.="<span class=\"cart_subtotal_raw\" data-value=\"$cart_subtotal_raw\" ></span>";*/ $htm .= '<div class="a">' . Yii::t("default", "Sub Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b cart_subtotal">' . displayPrice(baseCurrency(), prettyFormat($subtotal, $mid)) . '</div>'; $htm .= '</div>'; } if (!empty($delivery_charges)) { $htm .= '<div class="a">' . Yii::t("default", "Delivery Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($delivery_charges, $mid)) . '</div>'; $htm .= '</div>'; } if ($free_delivery == true) { $htm .= '<div class="a">' . Yii::t("default", "Delivery Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . t("Free") . '</div>'; $htm .= '</div>'; } if (!empty($merchant_packaging_charge)) { $htm .= '<div class="a">' . Yii::t("default", "Packaging") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($merchant_packaging_charge, $mid)) . '</div>'; $htm .= '</div>'; } if (!empty($tax)) { $htm .= '<div class="a">' . Yii::t("default", "Tax") . ' ' . $tax_amt . '% :</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($taxable_subtotal, $mid)) . '</div>'; $htm .= '</div>'; } if (isset($data['cart_tip_value'])) { if ($data['cart_tip_value'] >= 0.1) { $htm .= '<div class="a">' . Yii::t("default", "Tips") . ' ' . number_format($data['cart_tip_percentage'], 0) . '% :</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($data['cart_tip_value'], $mid)) . '</div>'; $htm .= '</div>'; $total += $data['cart_tip_value']; } } if (isset($data['card_fee'])) { if ($data['card_fee'] >= 0.1) { $htm .= '<div class="a">' . Yii::t("default", "Card Fee") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b">' . displayPrice(baseCurrency(), prettyFormat($data['card_fee'], $mid)) . '</div>'; $htm .= '</div>'; $total += $data['card_fee']; } } $htm .= '<div class="a bold cart_total_wrap">' . Yii::t("default", "Total") . ':</div>'; $htm .= '<div class="manage">'; $htm .= '<div class="b bold cart_total">' . displayPrice(baseCurrency(), prettyFormat($total, $mid)) . '</div>'; $htm .= '</div>'; $htm .= '<div class="clear"></div>'; $htm .= '</div>'; $htm .= CHtml::hiddenField("subtotal_order", unPrettyPrice($subtotal + $less_voucher)); $htm .= CHtml::hiddenField("subtotal_order2", unPrettyPrice($subtotal)); $htm .= CHtml::hiddenField("subtotal_extra_charge", unPrettyPrice($delivery_charges + $merchant_packaging_charge + $taxable_subtotal)); // array value $item_array_total = array('subtotal' => $subtotal, 'taxable_total' => $taxable_subtotal, 'delivery_charges' => $delivery_charges, 'total' => $total, 'tax' => $tax, 'tax_amt' => $tax_amt, 'curr' => baseCurrency(), 'mid' => $mid, 'discounted_amount' => $discounted_amount, 'merchant_discount_amount' => $merchant_discount_amount, 'merchant_packaging_charge' => $merchant_packaging_charge); /*dump($data); dump($htm);*/ $this->code = 1; $this->msg = "OK"; $this->details = array('item-count' => $x, 'html' => $htm, 'raw' => array('item' => $item_array, 'total' => $item_array_total)); } else { $this->msg = Yii::t("default", "No Item added yet!"); } } else { $this->msg = Yii::t("default", "No Item added yet!"); } }