public function pjActionGetExtra() { $this->setAjax(true); if ($this->isXHR()) { $pjExtraModel = pjExtraModel::factory()->join('pjMultiLang', "t2.foreign_id = t1.id AND t2.model = 'pjExtra' AND t2.locale = '" . $this->getLocaleId() . "' AND t2.field = 'name'", 'left')->where('user_id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjExtraModel->where('t2.content LIKE', "%{$q}%"); } $column = 'name'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjExtraModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 20; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = $pjExtraModel->select('t1.*, t2.content AS name, (SELECT COUNT(t3.product_id) FROM `' . pjProductExtraModel::factory()->getTable() . '` AS t3 WHERE t3.extra_id=t1.id) as products')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { $v['price'] = pjUtil::formatCurrencySign($v['price'], $this->option_arr['o_currency']); $data[$k] = $v; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function pjActionGetProduct() { $this->setAjax(true); if ($this->isXHR()) { $pjProductModel = pjProductModel::factory()->join('pjMultiLang', "t2.foreign_id = t1.id AND t2.model = 'pjProduct' AND t2.locale = '" . $this->getLocaleId() . "' AND t2.field = 'name'", 'left')->where('user_id = ' . $_SESSION['admin_user']['id']); if (isset($_GET['status']) && !empty($_GET['status'])) { $pjProductModel->where('t1.status', $_GET['status']); } if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjProductModel->where("(t2.content LIKE '%{$q}%')"); } if (isset($_GET['category_id']) && (int) $_GET['category_id'] > 0) { $pjProductModel->where("(t1.id IN (SELECT TPC.product_id FROM `" . pjProductCategoryModel::factory()->getTable() . "` AS TPC WHERE TPC.category_id='" . $_GET['category_id'] . "'))"); } $column = 'is_featured'; $direction = 'DESC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjProductModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $pjProductPriceModel = pjProductPriceModel::factory(); $data = $pjProductModel->select("t1.*, t2.content AS name")->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { if ($v['set_different_sizes'] == 'T') { $_arr = $pjProductPriceModel->reset()->join('pjMultiLang', "t2.foreign_id = t1.id AND t2.model = 'pjProductPrice' AND t2.locale = '" . $this->getLocaleId() . "' AND t2.field = 'price_name'", 'left')->select('t1.*, t2.content as price_name')->where('product_id', $v['id'])->findAll()->getData(); $price_arr = array(); foreach ($_arr as $price) { $price_arr[] = $price['price_name'] . ': ' . pjUtil::formatCurrencySign($price['price'], $this->option_arr['o_currency']); } $v['price'] = join("<br/>", $price_arr); } else { $v['price'] = pjUtil::formatCurrencySign($v['price'], $this->option_arr['o_currency']); } $data[$k] = $v; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
<?php $i++; } } } } $controller->_set('price', $price); ?> <tr class="fdProductRow"> <td><span class="fdCartSubtotal"><?php __('front_price'); ?> :</span></td> <td> </td> <td class="fdPriceCol"><span class="fdCartSubtotal"><?php echo pjUtil::formatCurrencySign(number_format($price, 2), $tpl['option_arr']['o_currency']); ?> </span></td> <td> </td> </tr> </tbody> </table> <div class="fdCartButton"> <a href="#" class="fdButton fdOrangeButton fdButtonCheckout" data-logged="<?php echo $controller->isFrontLogged() ? 'yes' : 'no'; ?> "><?php __('front_button_checkout'); ?> </a> </div>
public function pjActionGetOrder() { $this->setAjax(true); if ($this->isXHR()) { $pjOrderModel = pjOrderModel::factory()->join('pjClient', "t2.id=t1.client_id", 'left outer')->where('t1.user_id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjOrderModel->where("(t1.id = '{$q}' OR t1.uuid = '{$q}' OR t1.c_name LIKE '%{$q}%' OR t1.c_email LIKE '%{$q}%')"); } $lc_arr = explode(',', $_GET['location_id']); if (empty($_GET['fromDate']) && empty($_GET['toDate'])) { if (isset($_GET['status']) && !empty($_GET['status']) && in_array($_GET['status'], array('confirmed', 'cancelled', 'pending'))) { $pjOrderModel->where('t1.status', $_GET['status']); } if (isset($_GET['client_id']) && (int) $_GET['client_id'] > 0) { $pjOrderModel->where('t1.client_id', $_GET['client_id']); } if (isset($_GET['type']) && !empty($_GET['type'])) { $pjOrderModel->where('t1.type', $_GET['type']); } if (isset($_GET['location_id']) && !empty($_GET['location_id'])) { $condition = ''; foreach ($lc_arr as $row) { $condition .= 't1.location_id=' . $row . ' OR '; } $condition = substr($condition, 0, strlen($condition) - 4); $pjOrderModel->where($condition); } } else { $formDate = date('Y-m-d', strtotime($_GET['fromDate'])); $toDate = date('Y-m-d', strtotime($_GET['toDate'])); if (isset($_GET['status']) && !empty($_GET['status'])) { $pjOrderModel->where('t1.status', $_GET['status']); $pjOrderModel->where("date(t1.p_dt) BETWEEN '" . $formDate . "' AND '" . $toDate . "'"); } if (isset($_GET['client_id']) && (int) $_GET['client_id'] > 0) { $pjOrderModel->where('t1.client_id', $_GET['client_id']); $pjOrderModel->where("date(t1.p_dt) BETWEEN '" . $formDate . "' AND '" . $toDate . "'"); } if (isset($_GET['type']) && !empty($_GET['type'])) { $pjOrderModel->where('t1.type', $_GET['type']); $pjOrderModel->where("date(t1.p_dt) BETWEEN '" . $formDate . "' AND '" . $toDate . "'"); } if (isset($_GET['location_id']) && !empty($_GET['location_id'])) { $condition = ''; foreach ($lc_arr as $row) { $condition .= 't1.location_id=' . $row . ' OR '; } $condition = substr($condition, 0, strlen($condition) - 4); $pjOrderModel->where($condition); $pjOrderModel->where("date(t1.p_dt) BETWEEN '" . $formDate . "' AND '" . $toDate . "'"); } } $column = 'created'; $direction = 'DESC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjOrderModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjOrderModel->select('t1.*, t2.c_name as client_name')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { $data[$k]['total'] = pjUtil::formatCurrencySign($v['total'], $this->option_arr['o_currency']); if ($v['type'] == 'delivery') { $data[$k]['datetime'] = pjUtil::formatDate(date("Y-m-d", strtotime($v['d_dt'])), "Y-m-d", $this->option_arr['o_date_format']) . ', ' . pjUtil::formatTime(date("H:i:s", strtotime($v['d_dt'])), "H:i:s", $this->option_arr['o_time_format']); } else { if ($v['type'] == 'pickup') { $data[$k]['datetime'] = pjUtil::formatDate(date("Y-m-d", strtotime($v['p_dt'])), "Y-m-d", $this->option_arr['o_date_format']) . ', ' . pjUtil::formatTime(date("H:i:s", strtotime($v['p_dt'])), "H:i:s", $this->option_arr['o_time_format']); } } } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
public function pjActionGetVoucher() { $this->setAjax(true); if ($this->isXHR()) { $pjVoucherModel = pjVoucherModel::factory()->where('user_id', $_SESSION['admin_user']['id']); if (isset($_GET['q']) && !empty($_GET['q'])) { $q = pjObject::escapeString($_GET['q']); $pjVoucherModel->where('t1.code LIKE', "%{$q}%"); } $column = 'code'; $direction = 'ASC'; if (isset($_GET['direction']) && isset($_GET['column']) && in_array(strtoupper($_GET['direction']), array('ASC', 'DESC'))) { $column = $_GET['column']; $direction = strtoupper($_GET['direction']); } $total = $pjVoucherModel->findCount()->getData(); $rowCount = isset($_GET['rowCount']) && (int) $_GET['rowCount'] > 0 ? (int) $_GET['rowCount'] : 10; $pages = ceil($total / $rowCount); $page = isset($_GET['page']) && (int) $_GET['page'] > 0 ? intval($_GET['page']) : 1; $offset = ((int) $page - 1) * $rowCount; if ($page > $pages) { $page = $pages; } $data = array(); $data = $pjVoucherModel->select('t1.*')->orderBy("{$column} {$direction}")->limit($rowCount, $offset)->findAll()->getData(); foreach ($data as $k => $v) { if ($v['type'] == 'percent') { $v['discount'] = $v['discount'] . '%'; } else { $v['discount'] = pjUtil::formatCurrencySign($v['discount'], $this->option_arr['o_currency']); } $v['datetime_valid'] = ''; switch ($v['valid']) { case 'fixed': $v['datetime_valid'] = date($this->option_arr['o_date_format'], strtotime($v['date_from'])) . ' ' . __('lblFrom', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_to'])); break; case 'period': $v['datetime_valid'] = __('lblFrom', true) . ' ' . date($this->option_arr['o_date_format'], strtotime($v['date_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_date_format'], strtotime($v['date_to'])); break; case 'recurring': $days = __('voucher_days', true, false); $v['datetime_valid'] = __('lblEvery', true) . ' ' . $days[$v['every']] . ' ' . __('lblFrom', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_from'])) . ' ' . __('lblTo', true) . ' ' . date($this->option_arr['o_time_format'], strtotime($v['time_to'])); break; } $data[$k] = $v; } pjAppController::jsonResponse(compact('data', 'total', 'pages', 'page', 'rowCount', 'column', 'direction')); } exit; }
:</span> <?php echo $order_statuses[$v['status']]; ?> </label> <label><span><?php __('lblDateTime'); ?> :</span> <?php echo date($tpl['option_arr']['o_date_format'], strtotime($v['p_dt'])) . ', ' . date($tpl['option_arr']['o_time_format'], strtotime($v['p_dt'])); ?> </label> <label><span><?php __('lblTotal'); ?> :</span> <?php echo pjUtil::formatCurrencySign($v['total'], $tpl['option_arr']['o_currency']); ?> </label> </div> <?php } } else { ?> <div class="dashboard_row"> <label><span><?php __('lblDashNoOrder'); ?> </span></label> </div> <?php }
echo $v; ?> </option><?php } ?> </select> </span> </p> <p> <label class="title"><?php __('lblDiscount'); ?> </label> <span class="pj-form-field-custom pj-form-field-custom-before"> <span class="pj-form-field-before"><abbr id="icon_type" class="pj-form-field-icon-text"><?php echo pjUtil::formatCurrencySign(NULL, $tpl['option_arr']['o_currency'], ""); ?> </abbr></span> <input type="text" id="discount" name="discount" class="pj-form-field number w80"/> </span> </p> <p> <label class="title"><?php __('lblValid'); ?> </label> <span class="inline_block"> <select name="valid" id="valid" class="pj-form-field w150 required"> <option value="">-- <?php __('lblChoose'); ?>
echo $v; ?> </option><?php } ?> </select> </span> </p> <p> <label class="title"><?php __('lblDiscount'); ?> </label> <span class="pj-form-field-custom pj-form-field-custom-before"> <span class="pj-form-field-before"><abbr id="icon_type" class="pj-form-field-icon-text" ><?php echo $tpl['arr']['type'] == 'amount' ? pjUtil::formatCurrencySign(NULL, $tpl['option_arr']['o_currency'], "") : '%'; ?> </abbr></span> <input type="text" id="discount" name="discount" class="pj-form-field number w80" value="<?php echo (double) $tpl['arr']['discount']; ?> "/> </span> </p> <p> <label class="title"><?php __('lblValid'); ?> </label> <span class="inline_block"> <select name="valid" id="valid" class="pj-form-field w150 required">
?> --</option> <?php foreach ($tpl['price_arr'] as $v) { ?> <option value="<?php echo $v['id']; ?> " data-price="<?php echo $v['price']; ?> "><?php echo pjSanitize::clean($v['price_name']); ?> : <?php echo pjUtil::formatCurrencySign(round($v['price'], 2), $tpl['option_arr']['o_currency']); ?> </option><?php } ?> </select> <?php } } else { ?> <select id="fdPrice_<?php echo $_GET['index']; ?> " name="price_id[<?php echo $_GET['index']; ?>
--</option> <?php if (isset($tpl['extra_arr'])) { foreach ($tpl['extra_arr'] as $e) { ?> <option value="<?php echo $e['id']; ?> " data-price="<?php echo $e['price']; ?> "><?php echo stripslashes($e['name']); ?> : <?php echo pjUtil::formatCurrencySign($e['price'], $tpl['option_arr']['o_currency']); ?> </option><?php } } ?> </select> </td> <td class="w70"><input type="text" id="fdExtraQty_<?php echo $_GET['index']; ?> _<?php echo $index; ?> " name="extra_cnt[<?php echo $_GET['index'];
<td><?php __('front_tax'); ?> </td> <td><?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['arr']['tax']), 2), $tpl['option_arr']['o_currency'], " "); ?> </td> </tr> <tr> <td><?php __('front_total'); ?> </td> <td><?php echo pjUtil::formatCurrencySign(number_format(floatval($tpl['arr']['total']), 2), $tpl['option_arr']['o_currency'], " "); ?> </td> </tr> <tr> <td><?php __('front_order_created'); ?> </td> <td><?php echo date($tpl['option_arr']['o_date_format'], strtotime($tpl['arr']['created'])) . ' ' . date($tpl['option_arr']['o_time_format'], strtotime($tpl['arr']['created'])); ?> </td> </tr> <?php if ($tpl['arr']['payment_method'] == 'paypal') {
public function getTokens($option_arr, $data, $salt, $locale_id) { $c_country = NULL; $d_country = NULL; if (isset($data['c_country']) && !empty($data['c_country'])) { $pjCountryModel = pjCountryModel::factory(); $country_arr = pjCountryModel::factory()->select('t1.id, t2.content AS country_title')->join('pjMultiLang', "t2.model='pjCountry' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='" . $locale_id . "'", 'left outer')->find($data['c_country'])->getData(); if (!empty($country_arr)) { $c_country = $country_arr['country_title']; } $country_arr = pjCountryModel::factory()->reset()->select('t1.id, t2.content AS country_title')->join('pjMultiLang', "t2.model='pjCountry' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='" . $locale_id . "'", 'left outer')->find($data['d_country_id'])->getData(); if (!empty($country_arr)) { $d_country = $country_arr['country_title']; } } $row = array(); if (isset($data['product_arr'])) { foreach ($data['product_arr'] as $v) { $extra = array(); foreach ($v['extra_arr'] as $e) { $extra[] = stripslashes(sprintf("%u x %s", $e['cnt'], $e['name'])); } $row[] = stripslashes(sprintf("%u x %s", $v['cnt'], $v['name'])) . (count($extra) > 0 ? sprintf(" (%s)", join("; ", $extra)) : NULL); } } $order_data = count($row) > 0 ? join("\n", $row) : NULL; $discount = NULL; if (!empty($data['voucher_code'])) { $voucher_arr = pjVoucherModel::factory()->where('t1.code', $data['voucher_code'])->limit(1)->findAll()->getData(); if (!empty($voucher_arr)) { $voucher_arr = $voucher_arr[0]; switch ($voucher_arr['type']) { case "amount": $discount = pjUtil::formatCurrencySign($voucher_arr['discount'], $option_arr['o_currency']); break; case "percent": $discount = $voucher_arr['discount'] . '%'; break; } } } $subtotal = pjUtil::formatCurrencySign($data['subtotal'], $option_arr['o_currency']); $price_delivery = pjUtil::formatCurrencySign($data['price_delivery'], $option_arr['o_currency']); $total = pjUtil::formatCurrencySign($data['total'], $option_arr['o_currency']); $cancelURL = PJ_INSTALL_URL . 'index.php?controller=pjFront&action=pjActionCancel&id=' . @$data['id'] . '&hash=' . sha1(@$data['id'] . @$data['created'] . $salt); $search = array('{Country}', '{City}', '{State}', '{Notes}', '{Zip}', '{Address1}', '{Address2}', '{Name}', '{Email}', '{Phone}', '{dCountry}', '{dCity}', '{dState}', '{dZip}', '{dAddress1}', '{dAddress2}', '{CCType}', '{CCNum}', '{CCExp}', '{CCSec}', '{PaymentMethod}', '{DateTime}', '{Subtotal}', '{Delivery}', '{Discount}', '{Total}', '{dNotes}', '{Location}', '{OrderID}', '{CancelURL}', '{OrderDetails}'); $replace = array($c_country, @$data['c_city'], @$data['c_state'], @$data['c_notes'], @$data['c_zip'], @$data['c_address_1'], @$data['c_address_2'], @$data['c_name'], @$data['c_email'], @$data['c_phone'], $d_country, @$data['d_city'], $data['d_state'], @$data['d_zip'], @$data['d_address_1'], @$data['d_address_2'], @$data['cc_type'], @$data['cc_num'], @$data['payment_method'] == 'creditcard' ? @$data['cc_exp'] : NULL, @$data['cc_code'], @$data['payment_method'], date($option_arr['o_datetime_format'], strtotime(@$data['type'] == 'pickup' ? @$data['p_dt'] : @$data['d_dt'])), $subtotal, $price_delivery, @$discount, $total, @$data['d_notes'], @$data['location'], @$data['uuid'], $cancelURL, $order_data); return compact('search', 'replace'); }