当前位置: 首页>>代码示例>>PHP>>正文


PHP AJson::decode方法代码示例

本文整理汇总了PHP中AJson::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP AJson::decode方法的具体用法?PHP AJson::decode怎么用?PHP AJson::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AJson的用法示例。


在下文中一共展示了AJson::decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/customer');
     $this->loadModel('sale/customer');
     $this->load->library('json');
     $approved = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'));
     $page = $this->request->post['page'];
     // get the requested page
     $limit = $this->request->post['rows'];
     // get how many rows we want to have into the grid
     $sidx = $this->request->post['sidx'];
     // get index row - i.e. user click to sort
     $sord = $this->request->post['sord'];
     // get the direction
     $data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit);
     if (has_value($this->request->get['customer_group'])) {
         $data['filter']['customer_group_id'] = $this->request->get['customer_group'];
     }
     if (has_value($this->request->get['status'])) {
         $data['filter']['status'] = $this->request->get['status'];
     }
     if (has_value($this->request->get['approved'])) {
         $data['filter']['approved'] = $this->request->get['approved'];
     }
     $allowedFields = array('name', 'email');
     if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') {
         $searchData = AJson::decode(htmlspecialchars_decode($this->request->post['filters']), true);
         foreach ($searchData['rules'] as $rule) {
             if (!in_array($rule['field'], $allowedFields)) {
                 continue;
             }
             $data['filter'][$rule['field']] = $rule['data'];
         }
     }
     $total = $this->model_sale_customer->getTotalCustomers($data);
     if ($total > 0) {
         $total_pages = ceil($total / $limit);
     } else {
         $total_pages = 0;
     }
     $response = new stdClass();
     $response->page = $page;
     $response->total = $total_pages;
     $response->records = $total;
     $results = $this->model_sale_customer->getCustomers($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['customer_id'];
         $response->rows[$i]['cell'] = array($result['name'], '<a href="' . $this->html->getSecureURL('sale/contact', '&email[]=' . $result['email']) . '">' . $result['email'] . '</a>', $result['customer_group'], $this->html->buildCheckbox(array('name' => 'status[' . $result['customer_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $this->html->buildSelectbox(array('name' => 'approved[' . $result['customer_id'] . ']', 'value' => $result['approved'], 'options' => $approved)), $result['orders_count'] > 0 ? $this->html->buildButton(array('name' => 'view orders', 'text' => $result['orders_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('sale/order', '&customer_id=' . $result['customer_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_history'), 'target' => '_blank')) : 0);
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->response->setOutput(AJson::encode($response));
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:57,代码来源:customer.php

示例2: _html_response

 private function _html_response()
 {
     $this->loadLanguage('catalog/download');
     $form_name = isset($this->request->get['form_name']) ? $this->request->get['form_name'] : 'SharedFrm';
     $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup';
     //remember selected rows for response
     if (isset($this->request->post['selected'])) {
         $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true);
     }
     $grid_settings = array('table_id' => 'download_grid_' . $multivalue_hidden_id, 'url' => $this->html->getSecureURL('catalog/download_listing', '&response_type=json&product_id=' . $this->request->get['product_id'] . (isset($this->request->get['shared_only']) ? '&shared_only=1' : '')), 'editurl' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'actions' => array(), 'multiselect_noselectbox' => true);
     $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name'));
     $grid_settings['colNames'][] = $this->language->get('column_action');
     $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'width' => 200), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false));
     $grid_settings['search_form'] = true;
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $listing_grid = $grid->dispatchGetOutput();
     unset($grid);
     // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid)
     $view = new AView($this->registry, 0);
     $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id'], 'listing_grid' => $listing_grid, 'filter_product' => $this->language->get('filter_product'), 'filter_price_max' => $this->language->get('filter_price_max')));
     $this->data['response'] = $view->fetch('responses/catalog/download_listing.tpl');
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:22,代码来源:download_listing.php

示例3: files

 public function files()
 {
     $this->data = array();
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     if (has_value($this->session->data['error'])) {
         $this->data['error']['warning'] = $this->session->data['error'];
         unset($this->session->data['error']);
     }
     if (isset($this->request->get['order_id'])) {
         $order_id = $this->request->get['order_id'];
     } else {
         $order_id = 0;
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) {
         if (has_value($this->request->post['downloads'])) {
             $data = $this->request->post['downloads'];
             $this->loadModel('catalog/download');
             foreach ($data as $order_download_id => $item) {
                 if (isset($item['expire_date'])) {
                     $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : '';
                 }
                 $this->model_catalog_download->editOrderDownload($order_download_id, $item);
             }
         }
         //add download to order
         if (has_value($this->request->post['push'])) {
             $this->load->library('json');
             foreach ($this->request->post['push'] as $order_product_id => $items) {
                 $items = AJson::decode(html_entity_decode($items), true);
                 if ($items) {
                     foreach ($items as $download_id => $info) {
                         $download_info = $this->download->getDownloadInfo($download_id);
                         $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id));
                         $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info);
                     }
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']));
     }
     $order_info = $this->model_sale_order->getOrder($order_id);
     $this->data['order_info'] = $order_info;
     //set content language to order language ID.
     if ($this->language->getContentLanguageID() != $order_info['language_id']) {
         //reset content language
         $this->language->setCurrentContentLanguage($order_info['language_id']);
     }
     if (empty($order_info)) {
         $this->session->data['error'] = $this->language->get('error_order_load');
         $this->redirect($this->html->getSecureURL('sale/order'));
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: '));
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id'];
     $this->data['token'] = $this->session->data['token'];
     $this->data['invoice'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']);
     $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice'), 'style' => 'button3'));
     $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate');
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update');
     $this->data['order_id'] = $this->request->get['order_id'];
     $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']);
     $this->data['cancel'] = $this->html->getSecureURL('sale/order');
     $this->_initTabs('files');
     $this->loadModel('localisation/order_status');
     $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']);
     if ($status) {
         $this->data['order_status'] = $status['name'];
     } else {
         $this->data['order_status'] = '';
     }
     $this->loadModel('sale/customer_group');
     $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']);
     if ($customer_group_info) {
         $this->data['customer_group'] = $customer_group_info['name'];
     } else {
         $this->data['customer_group'] = '';
     }
     $this->data['form_title'] = $this->language->get('edit_title_files');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']);
     $form = new AForm('HS');
     $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'orderFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl');
     /** ORDER DOWNLOADS */
     $this->data['downloads'] = array();
     $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']);
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:order.php

示例4: transactions

 public function transactions()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('report/customer');
     //Prepare filter config
     $filter_params = array('date_start', 'date_end');
     $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
     $filter_grid = new AFilter(array('method' => 'post'));
     $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData());
     //add filters for custom processing
     $allowedFields = array('customer');
     if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') {
         $searchData = AJson::decode(htmlspecialchars_decode($this->request->post['filters']), true);
         foreach ($searchData['rules'] as $rule) {
             if (!in_array($rule['field'], $allowedFields)) {
                 continue;
             }
             $data['filter'][$rule['field']] = $rule['data'];
         }
     }
     $total = $this->model_report_customer->getTotalCustomerTransactions($data);
     $response = new stdClass();
     $response->page = $filter_grid->getParam('page');
     $response->total = $filter_grid->calcTotalPages($total);
     $response->records = $total;
     $results = $this->model_report_customer->getCustomerTransactions($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['customer_transaction_id'];
         //mark inactive customers.
         if ($result['status'] != 1) {
             $response->userdata->classes[$result['customer_transaction_id']] = 'attention';
         }
         $response->rows[$i]['cell'] = array($result['date_added'], $result['customer'], $this->currency->format($result['debit'], $this->config->get('config_currency')), $this->currency->format($result['credit'], $this->config->get('config_currency')), $result['transaction_type'], $result['created_by']);
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->setOutput(AJson::encode($response));
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:42,代码来源:report_customer.php

示例5: post


//.........这里部分代码省略.........
         //No products in the cart.
         $this->rest->sendResponse(200, array('status' => 2, 'error' => 'Nothing in the cart!'));
         return null;
     }
     if (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         //No stock for products in the cart if tracked.
         $this->rest->sendResponse(200, array('status' => 3, 'error' => 'No stock for product!'));
         return null;
     }
     if ($this->cart->hasShipping()) {
         if (!isset($this->session->data['shipping_address_id']) || !$this->session->data['shipping_address_id']) {
             //Problem. Missing shipping address
             $this->rest->sendResponse(200, array('status' => 4, 'error' => 'Missing shipping address!'));
             return null;
         }
         if (!isset($this->session->data['shipping_method'])) {
             //Problem. Missing shipping address
             $this->rest->sendResponse(200, array('status' => 5, 'error' => 'Missing shipping method!'));
             return null;
         }
     } else {
         unset($this->session->data['shipping_address_id']);
         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
         $this->tax->setZone($this->session->data['country_id'], $this->session->data['zone_id']);
     }
     if (!isset($this->session->data['payment_address_id']) || !$this->session->data['payment_address_id']) {
         $this->rest->sendResponse(200, array('status' => 6, 'error' => 'Missing payment (billing) address!'));
         return null;
     }
     if (!isset($this->session->data['payment_method'])) {
         $this->rest->sendResponse(200, array('status' => 5, 'error' => 'Missing payment (billing) method!'));
         return null;
     }
     //build order and pre-save
     $order = new AOrder($this->registry);
     $this->data = $order->buildOrderData($this->session->data);
     $this->session->data['order_id'] = $order->saveOrder();
     //build confirmation data
     $this->loadModel('account/address');
     $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
     if ($this->cart->hasShipping()) {
         $this->data['shipping_address'] = $this->customer->getFormattedAddress($shipping_address, $shipping_address['address_format']);
     } else {
         $this->data['shipping_address'] = '';
     }
     $this->data['shipping_method'] = $this->session->data['shipping_method']['title'];
     $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
     if ($payment_address) {
         $this->data['payment_address'] = $this->customer->getFormattedAddress($payment_address, $payment_address['address_format']);
     } else {
         $this->data['payment_address'] = '';
     }
     if ($this->session->data['payment_method']['id'] != 'no_payment_required') {
         $this->data['payment_method'] = $this->session->data['payment_method']['title'];
     } else {
         $this->data['payment_method'] = '';
     }
     $this->loadModel('tool/seo_url');
     $this->loadModel('tool/image');
     $product_ids = array();
     foreach ($this->data['products'] as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
     //Format product data specific for confirmation response
     for ($i = 0; $i < sizeof($this->data['products']); $i++) {
         $product_id = $this->data['products'][$i]['product_id'];
         $thumbnail = $thumbnails[$product_id];
         $tax = $this->tax->calcTotalTaxAmount($this->data['products'][$i]['total'], $this->data['products'][$i]['tax_class_id']);
         $this->data['products'][$i] = array_merge($this->data['products'][$i], array('thumb' => $thumbnail['thumb_url'], 'tax' => $this->currency->format($tax), 'price' => $this->currency->format($this->data['products'][$i]['price']), 'total' => $this->currency->format($this->data['products'][$i]['total'])));
     }
     if ($this->config->get('config_checkout_id')) {
         $this->loadModel('catalog/content');
         $content_info = $this->model_catalog_content->getContent($this->config->get('config_checkout_id'));
         if ($content_info) {
             $this->data['text_accept_agree'] = sprintf($this->language->get('text_accept_agree'), '', $content_info['title']);
         } else {
             $this->data['text_accept_agree'] = '';
         }
     } else {
         $this->data['text_accept_agree'] = '';
     }
     // Load selected paymnet required data from payment extension
     if ($this->session->data['payment_method']['id'] != 'no_payment_required') {
         $payment_controller = $this->dispatch('responses/extension/' . $this->session->data['payment_method']['id'] . '/api');
     } else {
         $payment_controller = $this->dispatch('responses/checkout/no_payment/api');
     }
     $this->load->library('json');
     $this->data['payment'] = AJson::decode($payment_controller->dispatchGetOutput(), TRUE);
     //set process_rt for process step to run the payment
     $this->session->data['process_rt'] = $this->data['payment']['process_rt'];
     //mark confirmation viewed
     $this->session->data['confirmed'] = TRUE;
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData($this->data);
     $this->rest->sendResponse(200);
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:101,代码来源:confirm.php

示例6: getListing

 public function getListing()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->library('json');
     $form_name = 'BannerBlockFrm';
     $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup';
     $this->loadLanguage('banner_manager/banner_manager');
     //remember selected rows for response
     if (isset($this->request->post['selected'])) {
         $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true);
     }
     $grid_settings = array('table_id' => 'banner_grid', 'url' => $this->html->getSecureURL('listing_grid/banner_manager/getBannerListData'), 'editurl' => '', 'update_field' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'columns_search' => true, 'actions' => array(), 'multiselect_noselectbox' => true);
     $form = new AForm();
     $form->setForm(array('form_name' => 'banner_grid_search'));
     $grid_search_form = array();
     $grid_search_form['id'] = 'banner_grid_search';
     $grid_search_form['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'banner_grid_search', 'action' => ''));
     $grid_search_form['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
     $grid_search_form['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset'), 'style' => 'button2'));
     $grid_settings['colNames'] = array('', $this->language->get('column_banner_name'), $this->language->get('column_banner_group'), $this->language->get('column_banner_type'), $this->language->get('column_action'));
     $grid_settings['colModel'] = array(array('name' => 'banner_icon', 'index' => 'icon', 'width' => 40, 'align' => 'center', 'search' => false), array('name' => 'banner_name', 'index' => 'name', 'width' => 100, 'align' => 'left'), array('name' => 'banner_group', 'index' => 'banner_group_name', 'width' => 80, 'align' => 'left'), array('name' => 'banner_type', 'index' => 'banner_type', 'width' => 60, 'align' => 'center', 'search' => false), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'sortable' => false, 'search' => false));
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $this->data['listing_grid'] = $grid->dispatchGetOutput();
     $this->data['search_form'] = $grid_search_form;
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $listing_grid = $grid->dispatchGetOutput();
     unset($grid);
     // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid)
     $view = new AView($this->registry, 0);
     $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id'], 'listing_grid' => $listing_grid, 'heading_title' => $this->language->get('text_select_banners')));
     $this->data['response'] = $view->fetch('responses/extension/banner_listing.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->response->setOutput($this->data['response']);
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:36,代码来源:banner_manager.php

示例7: buildListingGridForSelect

 public function buildListingGridForSelect()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->load->library('json');
     $custom_block_id = (int) $this->request->get['custom_block_id'];
     $form_name = has_value($this->request->get['form_name']) ? $this->request->get['form_name'] : 'BlockFrm';
     $lm = new AListingManager($custom_block_id);
     $this->data['data_sources'] = $lm->getListingDataSources();
     $listing_datasource = $this->request->post_or_get('listing_datasource');
     $this->loadLanguage($this->data['data_sources'][$listing_datasource]['language']);
     //remember selected rows for response
     if (isset($this->request->post['selected'])) {
         $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true);
     }
     $grid_settings = array('table_id' => 'product_grid', 'url' => $this->html->getSecureURL('listing_grid/blocks_grid/getCustomListListingGridData', '&custom_block_id=' . $custom_block_id . '&listing_datasource=' . $listing_datasource), 'editurl' => '', 'sortname' => 'name', 'actions' => array(), 'multiselect_noselectbox' => true);
     $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name'));
     if (strpos($listing_datasource, 'product') !== FALSE) {
         $grid_settings['colNames'][] = $this->language->get('column_model');
     }
     $grid_settings['colNames'][] = $this->language->get('column_action');
     $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'width' => 200));
     if (strpos($listing_datasource, 'product') !== FALSE) {
         $grid_settings['colModel'][] = array('name' => 'model', 'index' => 'model', 'align' => 'center', 'width' => 60, 'sortable' => true);
     }
     $grid_settings['colModel'][] = array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false);
     $grid_settings['search_form'] = true;
     $grid = $this->dispatch('common/listing_grid', array($grid_settings));
     $this->data['response'] = $grid->dispatchGetOutput();
     $view = new AView($this->registry, 0);
     $view->batchAssign(array('form_name' => $form_name, 'table_id' => $grid_settings['table_id']));
     //add scripts
     $this->data['response'] .= $view->fetch('responses/design/block_custom_listing_js.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->response->setOutput($this->data['response']);
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:37,代码来源:blocks_grid.php

示例8: main

 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/product');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('catalog/product');
     if (!$this->registry->has('jqgrid_script')) {
         $locale = $this->session->data['language'];
         if (!file_exists(DIR_ROOT . '/' . RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js')) {
             $locale = 'en';
         }
         $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js');
         $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.jqGrid.min.js');
         $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/plugins/jquery.grid.fluid.js');
         $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.ba-bbq.min.js');
         $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/grid.history.js');
         //set flag to not include scripts/css twice
         $this->registry->set('jqgrid_script', true);
     }
     if (isset($this->request->get['product_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
         if (!$product_info) {
             $this->session->data['warning'] = $this->language->get('error_product_not_found');
             $this->redirect($this->html->getSecureURL('catalog/product'));
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $this->load->library('json');
         $this->request->post['selected'][0] = AJson::decode(html_entity_decode($this->request->post['selected'][0]), true);
         $this->request->post['selected'][1] = AJson::decode(html_entity_decode($this->request->post['selected'][1]), true);
         if ($this->request->post['selected']) {
             $related = array();
             foreach ($this->request->post['selected'][1] as $id => $related_product) {
                 if ($related_product['status']) {
                     $related[] = $id;
                 }
             }
             $product_category = array();
             foreach ($this->request->post['selected'][0] as $id => $category) {
                 if ($category['status']) {
                     $product_category[] = $id;
                 }
             }
             unset($this->request->post['selected']);
             $this->request->post['product_related'] = $related;
             $this->request->post['product_category'] = $product_category;
         }
         $this->model_catalog_product->updateProductLinks($this->request->get['product_id'], $this->request->post);
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id']));
     }
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
     $this->view->assign('error_warning', $this->error['warning']);
     $this->view->assign('success', $this->session->data['success']);
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'], 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('tab_relations'), 'separator' => ' :: '));
     $this->loadModel('catalog/category');
     $this->data['categories'] = array();
     $results = $this->model_catalog_category->getCategories(0);
     foreach ($results as $r) {
         $this->data['categories'][$r['category_id']] = $r['name'];
     }
     $this->loadModel('setting/store');
     $this->data['stores'] = array(0 => $this->language->get('text_default'));
     $results = $this->model_setting_store->getStores();
     foreach ($results as $r) {
         $this->data['stores'][$r['store_id']] = $r['name'];
     }
     $this->data['product_category'] = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
     $this->data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']);
     $this->data['product_related'] = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
     $this->data['active'] = 'relations';
     //load tabs controller
     $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
     $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
     unset($tabs_obj);
     $this->data['category_products'] = $this->html->getSecureURL('product/product/category');
     $this->data['related_products'] = $this->html->getSecureURL('product/product/related');
     $this->data['action'] = $this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id']);
     $this->data['form_title'] = $this->language->get('text_edit') . '&nbsp;' . $this->language->get('text_product');
     $this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_relations_field', '&id=' . $this->request->get['product_id']);
     $form = new AForm('HS');
     $form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'productFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'confirm-exit="true"'));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->data['form']['fields']['product_store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_store[]', 'value' => $this->data['product_store'], 'options' => $this->data['stores'], 'scrollbox' => true));
     $this->load->library('json');
     $listing_data = array();
     if ($this->data['product_related']) {
         foreach ($this->data['product_related'] as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             $listing_data[$product_id] = array('id' => $product_id, 'name' => html_entity_decode($product_info['name'] . ' (' . $product_info['model'] . ')'), 'status' => 1);
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:product_relations.php

示例9: main

 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/customer');
     $this->loadModel('sale/customer_transaction');
     $this->load->library('json');
     $page = $this->request->post['page'];
     // get the requested page
     $limit = $this->request->post['rows'];
     // get how many rows we want to have into the grid
     $sidx = $this->request->post['sidx'];
     // get index row - i.e. user click to sort
     $sord = $this->request->post['sord'];
     // get the direction
     $data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit, 'customer_id' => (int) $this->request->get['customer_id']);
     if (has_value($this->request->get['user'])) {
         $data['filter']['user'] = $this->request->get['user'];
     }
     if (has_value($this->request->get['credit'])) {
         $data['filter']['credit'] = $this->request->get['credit'];
     }
     if (has_value($this->request->get['debit'])) {
         $data['filter']['debit'] = $this->request->get['debit'];
     }
     if (has_value($this->request->get['transaction_type'])) {
         $data['filter']['transaction_type'] = $this->request->get['transaction_type'];
     }
     if (has_value($this->request->get['date_start'])) {
         $data['filter']['date_start'] = dateDisplay2ISO($this->request->get['date_start']);
     }
     if (has_value($this->request->get['date_end'])) {
         $data['filter']['date_end'] = dateDisplay2ISO($this->request->get['date_end']);
     }
     $allowedFields = array('user', 'credit', 'debit', 'transaction_type', 'date_start', 'date_end');
     if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') {
         $searchData = AJson::decode(htmlspecialchars_decode($this->request->post['filters']), true);
         foreach ($searchData['rules'] as $rule) {
             if (!in_array($rule['field'], $allowedFields)) {
                 continue;
             }
             $data['filter'][$rule['field']] = $rule['data'];
         }
     }
     $total = $this->model_sale_customer_transaction->getTotalCustomerTransactions($data);
     if ($total > 0) {
         $total_pages = ceil($total / $limit);
     } else {
         $total_pages = 0;
     }
     $response = new stdClass();
     $response->page = $page;
     $response->total = $total_pages;
     $response->records = $total;
     $results = $this->model_sale_customer_transaction->getCustomerTransactions($data);
     $i = 0;
     foreach ($results as $result) {
         $response->rows[$i]['id'] = $result['customer_transaction_id'];
         $response->rows[$i]['cell'] = array($result['date_added'], $result['user'], $result['debit'], $result['credit'], $result['transaction_type']);
         $i++;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode($response));
 }
开发者ID:vglide,项目名称:abantecart-src,代码行数:66,代码来源:customer_transaction.php

示例10: getPublisherId

 public function getPublisherId()
 {
     // if checkbox unchecked - remove publisher_id
     $this->loadModel('setting/setting');
     $store_id = has_value($this->request->get['store_id']) ? $this->request->get['store_id'] : 0;
     if ($this->request->get['disable']) {
         $this->model_setting_setting->editSetting('default_pp_express', array('default_pp_express_billmelater_publisher_id' => '', 'default_pp_express_billmelater_agree' => 0), $store_id);
         $response = '{}';
     } else {
         $this->loadLanguage('default_pp_express/default_pp_express');
         $this->load->library('json');
         $ch = curl_init('https://api.financing.paypal.com/finapi/v1/publishers/');
         curl_setopt($ch, CURLOPT_PORT, 443);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $timestamp = floor(microtime(true) * 1000);
         curl_setopt($ch, CURLOPT_HTTPHEADER, $arr = array('Accept: application/json', 'Content-Type: application/json', 'Authorization: FPA c5e5282897456bc5cc6ba33d3a9084d6a6993e5c:' . sha1('1be35fe3f6f296e5b991c3d39d01a3863bffa792' . $timestamp) . ':' . $timestamp));
         curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
         curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, AJson::encode(array("emailAddress" => $this->request->get['email'], "sellerName" => "AbanteCart", "bnCode" => "DLP3CT4UCNTPE")));
         $response = curl_exec($ch);
         $json = AJson::decode($response, true);
         if ($json['publisherId']) {
             $this->model_setting_setting->editSetting('default_pp_express', array('default_pp_express_billmelater_publisher_id' => $json['publisherId'], 'default_pp_express_billmelater_agree' => 1), $store_id);
             $response = AJson::encode(array('publisherId' => $json['publisherId']));
         }
     }
     $this->response->setOutput($response);
 }
开发者ID:nelkihel,项目名称:abantecart-src,代码行数:29,代码来源:default_pp_express.php

示例11: Main

    public function Main()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->load->library('json');
        $response_type = $this->request->get['response_type'];
        $form_name = isset($this->request->get['form_name']) ? $this->request->get['form_name'] : 'productFrm';
        $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup';
        if ($response_type != 'json') {
            $this->loadLanguage('catalog/product');
            //remember selected rows for response
            if (isset($this->request->post['selected'])) {
                $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true);
            }
            $grid_settings = array('table_id' => 'product_grid', 'url' => $this->html->getSecureURL('catalog/product_listing', '&response_type=json'), 'editurl' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'actions' => array(), 'multiselect_noselectbox' => true);
            $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name'));
            $grid_settings['colNames'][] = $this->language->get('column_model');
            $grid_settings['colNames'][] = $this->language->get('column_action');
            $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'width' => 200), array('name' => 'model', 'index' => 'model', 'align' => 'center', 'width' => 60, 'sortable' => false), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false));
            $form = new AForm();
            $form->setForm(array('form_name' => 'product_listing_search'));
            $grid_search_form = array();
            $grid_search_form['id'] = 'product_listing_search';
            $grid_search_form['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product_grid_search', 'action' => ''));
            $grid_search_form['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_go'), 'style' => 'button1'));
            $grid_search_form['reset'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'text' => $this->language->get('button_reset'), 'style' => 'button2'));
            $grid_search_form['fields']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => ''));
            $grid_search_form['fields']['match'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'match', 'options' => array('any' => $this->language->get('filter_any_word'), 'all' => $this->language->get('filter_all_words'), 'exact' => $this->language->get('filter_exact_match'))));
            $grid_search_form['fields']['pfrom'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'pfrom', 'value' => ''));
            $grid_search_form['fields']['pto'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'pto', 'value' => ''));
            $this->loadModel('catalog/category');
            $categories = array('' => $this->language->get('text_select_category'));
            $results = $this->model_catalog_category->getCategories(0);
            foreach ($results as $r) {
                $categories[$r['category_id']] = $r['name'];
            }
            $grid_search_form['fields']['category'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'category', 'options' => $categories, 'style' => 'medium-field'));
            $grid_settings['search_form'] = true;
            $grid = $this->dispatch('common/listing_grid', array($grid_settings));
            $listing_grid = $grid->dispatchGetOutput();
            unset($grid);
            // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid)
            $view = new AView($this->registry, 0);
            $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id'], 'search_form' => $grid_search_form, 'listing_grid' => $listing_grid, 'filter_product' => $this->language->get('filter_product'), 'filter_price_max' => $this->language->get('filter_price_max')));
            $this->data['response'] = $view->fetch('responses/catalog/product_listing.tpl');
        } else {
            // json-response for jqgrid
            $this->loadLanguage('catalog/product');
            $this->loadModel('catalog/product');
            $this->loadModel('tool/image');
            //Prepare filter config
            //Clean up parametres if needed
            if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_product')) {
                unset($this->request->get['keyword']);
            }
            if (isset($this->request->get['pfrom']) && $this->request->get['pfrom'] == 0) {
                unset($this->request->get['pfrom']);
            }
            if (isset($this->request->get['pto']) && $this->request->get['pto'] == $this->language->get('filter_price_max')) {
                unset($this->request->get['pto']);
            }
            //Prepare filter config
            $filter_params = array('category', 'status', 'keyword', 'match', 'pfrom', 'pto');
            $grid_filter_params = array('name', 'sort_order', 'model');
            $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params));
            $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
            $total = $this->model_catalog_product->getTotalProducts(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
            $response = new stdClass();
            $response->page = $filter_grid->getParam('page');
            $response->total = $filter_grid->calcTotalPages($total);
            $response->records = $total;
            $results = $this->model_catalog_product->getProducts(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()));
            $i = 0;
            $resource = new AResource('image');
            $response->userdata = (object) array('page' => $page);
            $data_type = 'product_id';
            $list = $this->session->data['listing_selected'];
            $id_list = array();
            foreach ($list as $id => $row) {
                if ($id == $this->session->data['multivalue_excludes']['product_id']) {
                    continue;
                }
                if ($row['status']) {
                    $id_list[] = $id;
                }
            }
            if ($results) {
                foreach ($results as $result) {
                    if ($result[$data_type] == $this->session->data['multivalue_excludes']['product_id']) {
                        continue;
                    }
                    if (in_array($result[$data_type], $id_list)) {
                        $response->userdata->selId[] = $result[$data_type];
                    }
                    $thumbnail = $resource->getMainThumb('products', $result[$data_type], 27, 27, true);
                    $response->rows[$i]['id'] = $result[$data_type];
                    $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], $result['model'], '<a class="btn_action" href="JavaScript:void(0);"
							onclick="showPopup(\'' . $this->html->getSecureURL('catalog/product/update', '&' . $data_type . '=' . $result[$data_type]) . '\')" title="' . $this->language->get('text_view') . '">' . '<img height="27" src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>');
                    $i++;
                }
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:product_listing.php

示例12: post

 public function post()
 {
     $request = $this->rest->getRequestParams();
     if (!$this->customer->isLoggedWithToken($request['token'])) {
         $this->rest->sendResponse(401, array('error' => 'Not logged in or Login attempt failed!'));
         return;
     }
     //Check if confirmation details were reviewed.
     if (!$this->session->data['confirmed']) {
         $this->rest->sendResponse(400, array('status' => 0, 'error' => 'Need to review confirmation details first!'));
         return;
     }
     $this->session->data['confirmed'] = FALSE;
     //Check if order is created and process payment
     if (!isset($this->session->data['order_id'])) {
         $this->rest->sendResponse(500, array('status' => 2, 'error' => 'Not order data available!'));
         return;
     }
     $order = new AOrder($this->registry);
     $order_data = $order->loadOrderData($this->session->data['order_id'], 'any');
     //Check if order is present and not processed yet
     if (!isset($order_data)) {
         $this->rest->sendResponse(500, array('status' => 3, 'error' => 'No order available. Something went wrong!'));
         return;
     }
     if ($order_data['order_status_id'] > 0) {
         $this->rest->sendResponse(200, array('status' => 4, 'error' => 'Order was already processed!'));
         return;
     }
     //Dispatch the payment send controller process and capture the result
     if (!$this->session->data['process_rt']) {
         $this->rest->sendResponse(500, array('status' => 5, 'error' => 'Something went wrong. Incomplete request!'));
         return;
     }
     //we process only responce type payment extensions
     $payment_controller = $this->dispatch('responses/extension/' . $this->session->data['process_rt']);
     $this->load->library('json');
     $this->data = AJson::decode($payment_controller->dispatchGetOutput(), TRUE);
     if ($this->data['error']) {
         $this->data['status'] = 6;
         $this->rest->sendResponse(200, $this->data);
         return;
     } else {
         if ($this->data['success']) {
             $this->data['status'] = 1;
             //order completed clean up
             if (isset($this->session->data['order_id'])) {
                 $this->cart->clear();
                 unset($this->session->data['shipping_method']);
                 unset($this->session->data['shipping_methods']);
                 unset($this->session->data['payment_method']);
                 unset($this->session->data['payment_methods']);
                 unset($this->session->data['guest']);
                 unset($this->session->data['comment']);
                 unset($this->session->data['order_id']);
                 unset($this->session->data['coupon']);
             }
             $this->rest->setResponseData($this->data);
             $this->rest->sendResponse(200);
         } else {
             $this->data['status'] = 0;
             $this->data['error'] = "Unexpected Error";
             $this->rest->sendResponse(500, $this->data);
         }
     }
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:66,代码来源:process.php

示例13: _getForm


//.........这里部分代码省略.........
     }
     if (!is_array($this->data['coupon_description'])) {
         if (isset($this->request->get['coupon_id'])) {
             $this->data['coupon_description'] = $this->model_sale_coupon->getCouponDescriptions($this->request->get['coupon_id']);
         } else {
             $this->data['coupon_description'] = array();
         }
     }
     if (!is_array($this->data['coupon_product'])) {
         if (isset($coupon_info)) {
             $this->data['coupon_product'] = $this->model_sale_coupon->getCouponProducts($this->request->get['coupon_id']);
         } else {
             $this->data['coupon_product'] = array();
         }
     }
     if (isset($this->request->post['date_start'])) {
         $this->data['date_start'] = dateDisplay2ISO($this->request->post['date_start'], $this->language->get('date_format_short'));
     } elseif (isset($coupon_info)) {
         $this->data['date_start'] = date('Y-m-d', strtotime($coupon_info['date_start']));
     } else {
         $this->data['date_start'] = date('Y-m-d', time());
     }
     if (isset($this->request->post['date_end'])) {
         $this->data['date_end'] = dateDisplay2ISO($this->request->post['date_end'], $this->language->get('date_format_short'));
     } elseif (isset($coupon_info)) {
         $this->data['date_end'] = date('Y-m-d', strtotime($coupon_info['date_end']));
     } else {
         $this->data['date_end'] = '';
     }
     if (isset($this->data['uses_total']) && $this->data['uses_total'] == -1) {
         $this->data['uses_total'] = '';
     } elseif (isset($this->data['uses_total']) && $this->data['uses_total'] == '') {
         $this->data['uses_total'] = 1;
     }
     if (isset($this->data['uses_customer']) && $this->data['uses_customer'] == -1) {
         $this->data['uses_customer'] = '';
     } elseif (isset($this->data['uses_customer']) && $this->data['uses_customer'] == '') {
         $this->data['uses_customer'] = 1;
     }
     if (isset($this->data['status']) && $this->data['status'] == '') {
         $this->data['status'] = 1;
     }
     //check if coupon is active based on dates and update status
     $now = time();
     if (dateISO2Int($this->data['date_start']) > $now || dateISO2Int($this->data['date_end']) < $now) {
         $this->data['status'] = 0;
     }
     if (!isset($this->request->get['coupon_id'])) {
         $this->data['action'] = $this->html->getSecureURL('sale/coupon/insert');
         $this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('text_coupon');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('sale/coupon/update', '&coupon_id=' . $this->request->get['coupon_id']);
         $this->data['heading_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_coupon') . ' - ' . $this->data['coupon_description'][$this->session->data['content_language_id']]['name'];
         $this->data['update'] = $this->html->getSecureURL('listing_grid/coupon/update_field', '&id=' . $this->request->get['coupon_id']);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'couponFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'couponFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'couponFrm', 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
     $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
     $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
     $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'coupon_description[' . $this->session->data['content_language_id'] . '][name]', 'value' => $this->data['coupon_description'][$this->session->data['content_language_id']]['name'], 'required' => true, 'style' => 'large-field'));
     $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'coupon_description[' . $this->session->data['content_language_id'] . '][description]', 'value' => $this->data['coupon_description'][$this->session->data['content_language_id']]['description'], 'required' => true, 'style' => 'large-field'));
     $this->data['form']['fields']['code'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'code', 'value' => $this->data['code'], 'required' => true));
     $this->data['form']['fields']['type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'type', 'value' => $this->data['type'], 'options' => array('P' => $this->language->get('text_percent'), 'F' => $this->language->get('text_amount'))));
     $this->data['form']['fields']['discount'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'discount', 'value' => moneyDisplayFormat($this->data['discount'])));
     $this->data['form']['fields']['total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'total', 'value' => moneyDisplayFormat($this->data['total'])));
     $this->data['form']['fields']['logged'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'logged', 'value' => $this->data['logged'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'))));
     $this->data['form']['fields']['shipping'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'shipping', 'value' => $this->data['shipping'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no'))));
     $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_start', 'value' => dateISO2Display($this->data['date_start']), 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'required' => true, 'style' => 'medium-field'));
     $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_end', 'value' => dateISO2Display($this->data['date_end']), 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'pased', 'required' => true, 'style' => 'medium-field'));
     $this->data['form']['fields']['uses_total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_total', 'value' => $this->data['uses_total']));
     $this->data['form']['fields']['uses_customer'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_customer', 'value' => $this->data['uses_customer']));
     if ($this->request->get['coupon_id']) {
         $this->loadModel('sale/order');
         $total = $this->model_sale_order->getTotalOrders(array('filter_coupon_id' => $this->request->get['coupon_id']));
         $this->data['form']['fields']['total_coupon_usage'] = (int) $total;
     }
     $this->load->library('json');
     $listing_data = array();
     if ($this->data['coupon_product']) {
         $this->loadModel('catalog/product');
         foreach ($this->data['coupon_product'] as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             $listing_data[$product_id] = array('id' => $product_id, 'name' => html_entity_decode($product_info['name'] . ' (' . $product_info['model'] . ')'), 'status' => 1);
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $listing_data = AJson::decode(html_entity_decode($this->request->post['selected'][0]), true);
     }
     $this->data['form']['fields']['product'] = $form->getFieldHtml(array('id' => 'coupon_products_list', 'type' => 'multivaluelist', 'name' => 'coupon_products', 'content_url' => $this->html->getSecureUrl('listing_grid/coupon/products'), 'edit_url' => '', 'multivalue_hidden_id' => 'popup', 'values' => $listing_data, 'return_to' => 'couponFrm_popup_item_count', 'text' => array('delete' => $this->language->get('button_delete'), 'delete_confirm' => $this->language->get('text_delete_confirm'))));
     $this->data['form']['fields']['list'] = $form->getFieldHtml(array('id' => 'popup', 'type' => 'multivalue', 'name' => 'popup', 'title' => $this->language->get('text_select_from_list'), 'selected' => $listing_data ? AJson::encode($listing_data) : "{}", 'content_url' => $this->html->getSecureUrl('catalog/product_listing', '&form_name=couponFrm&multivalue_hidden_id=popup'), 'postvars' => '', 'return_to' => '', 'popup_height' => 708, 'js' => array('apply' => "couponFrm_coupon_products_buildList();", 'cancel' => 'couponFrm_coupon_products_buildList();'), 'text' => array('selected' => $this->language->get('text_count_selected'), 'edit' => $this->language->get('text_save_edit'), 'apply' => $this->language->get('text_apply'), 'save' => $this->language->get('button_save'), 'reset' => $this->language->get('button_reset'))));
     $this->view->assign('help_url', $this->gen_help_url('coupon_edit'));
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/sale/coupon_form.tpl');
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:coupon.php

示例14: Main

    public function Main()
    {
        //init controller data
        $this->extensions->hk_InitData($this, __FUNCTION__);
        $this->load->library('json');
        $response_type = $this->request->get['response_type'];
        $form_name = isset($this->request->get['form_name']) ? $this->request->get['form_name'] : 'productFrm';
        $multivalue_hidden_id = isset($this->request->get['multivalue_hidden_id']) ? $this->request->get['multivalue_hidden_id'] : 'popup';
        if ($response_type != 'json') {
            $this->loadLanguage('catalog/category');
            //remember selected rows for response
            if (isset($this->request->post['selected'])) {
                $this->session->data['listing_selected'] = AJson::decode(html_entity_decode($this->request->post['selected']), true);
            }
            $grid_settings = array('table_id' => 'category_grid', 'url' => $this->html->getSecureURL('catalog/category_listing', '&response_type=json'), 'editurl' => '', 'sortname' => 'name', 'sortorder' => 'asc', 'actions' => array(), 'multiselect_noselectbox' => true);
            $grid_settings['colNames'] = array($this->language->get('column_image'), $this->language->get('column_name'));
            $grid_settings['colNames'][] = $this->language->get('column_action');
            $grid_settings['colModel'] = array(array('name' => 'image', 'index' => 'image', 'align' => 'center', 'width' => 50, 'sortable' => false, 'search' => false), array('name' => 'name', 'index' => 'name', 'align' => 'left', 'sortable' => false, 'width' => 200), array('name' => 'action', 'index' => 'action', 'align' => 'center', 'width' => 30, 'sortable' => false, 'search' => false));
            $grid_settings['search_form'] = true;
            $grid = $this->dispatch('common/listing_grid', array($grid_settings));
            $this->data['response'] = $grid->dispatchGetOutput();
            unset($grid);
            // add js-scripts for grid rows selecting (redeclare onSelectRow event for grid)
            $view = new AView($this->registry, 0);
            $view->batchAssign(array('id' => $multivalue_hidden_id, 'form_name' => $form_name . '_' . $multivalue_hidden_id, 'table_id' => $grid_settings['table_id']));
            $this->data['response'] .= $view->fetch('responses/catalog/category_listing.tpl');
        } else {
            // json-response for jqgrid
            $this->loadLanguage('catalog/category');
            $this->loadModel('catalog/category');
            $this->loadModel('tool/image');
            //Prepare filter config
            $grid_filter_params = array('name');
            $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params));
            $filter_data = $filter->getFilterData();
            //Add custom params
            if (!$filter_data['subsql_filter']) {
                // without search
                $parent_id = isset($this->request->get['parent_id']) ? $this->request->get['parent_id'] : 0;
                $results = $this->model_catalog_category->getCategories($parent_id);
                $total = sizeof($results);
                $results = array_slice($results, $filter_data['start'], $filter_data['limit']);
            } else {
                $total = $this->model_catalog_category->getTotalCategories($filter_data);
                $results = $this->model_catalog_category->getCategoriesData($filter_data);
            }
            $response = new stdClass();
            $response->page = $filter->getParam('page');
            $response->total = $filter->calcTotalPages($total);
            $response->records = $total;
            $resource = new AResource('image');
            $i = 0;
            $response->userdata = (object) array('page' => $this->request->post['page']);
            $data_type = 'category_id';
            $list = $this->session->data['listing_selected'];
            $id_list = array();
            foreach ($list as $id => $row) {
                if ($row['status']) {
                    $id_list[] = $id;
                }
            }
            if ($results) {
                foreach ($results as $result) {
                    if (in_array($result[$data_type], $id_list)) {
                        $response->userdata->selId[] = $result[$data_type];
                    }
                    $thumbnail = $resource->getMainThumb('categories', $result[$data_type], 36, 36, true);
                    $response->rows[$i]['id'] = $result[$data_type];
                    $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], '<a class="btn_action" href="JavaScript:void(0);"
							onclick="showPopup(\'' . $this->html->getSecureURL('catalog/category/update', '&' . $data_type . '=' . $result[$data_type]) . '\')" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>');
                    $i++;
                }
            }
            $this->data['response'] = $response;
        }
        //update controller data
        $this->extensions->hk_UpdateData($this, __FUNCTION__);
        if ($response_type == 'json') {
            $this->data['response'] = AJson::encode($this->data['response']);
        }
        $this->response->setOutput($this->data['response']);
    }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:82,代码来源:category_listing.php

示例15: filter

 /**
  * @param string $adv_filter_str
  * @param array $allowedFields
  * @return string
  */
 public function filter($adv_filter_str, $allowedFields)
 {
     $allowedOperations = array('AND', 'OR');
     $search_param = array();
     if (isset($this->search) && $this->search == 'true') {
         $this->load->library('json');
         $searchData = AJson::decode(htmlspecialchars_decode($this->filters), true);
         $op = $searchData['groupOp'];
         if (!in_array($op, $allowedOperations)) {
             $op = $allowedOperations[0];
         }
         if ($searchData['rules']) {
             foreach ($searchData['rules'] as $rule) {
                 // $allowedFields can be simple or key based array
                 $field_name = '';
                 if (is_assoc($allowedFields)) {
                     if (!array_key_exists($rule['field'], $allowedFields)) {
                         continue;
                     }
                     $field_name = $allowedFields[$rule['field']];
                 } else {
                     if (!in_array($rule['field'], $allowedFields)) {
                         continue;
                     }
                     $field_name = $rule['field'];
                 }
                 //support table name extension in fields
                 if (strpos($field_name, '.')) {
                     $parts = explode('.', $field_name);
                     $str = $parts[0] . '.`' . $parts[1] . '`';
                 } else {
                     $str = '`' . $field_name . '`';
                 }
                 switch ($rule['op']) {
                     case 'eq':
                         $str .= " = '" . $this->db->escape($rule['data']) . "' ";
                         break;
                     case 'ne':
                         $str .= " != '" . $this->db->escape($rule['data']) . "' ";
                         break;
                     case 'bw':
                         $str = "LOWER(" . $str . ")";
                         $rule['data'] = mb_strtolower($rule['data']);
                         $str .= " LIKE '" . $this->db->escape($rule['data']) . "%' ";
                         break;
                     case 'cn':
                         $str = "LOWER(" . $str . ")";
                         $rule['data'] = mb_strtolower($rule['data']);
                         $str .= " LIKE '%" . $this->db->escape($rule['data']) . "%' ";
                         break;
                     default:
                         $str .= " = '" . $this->db->escape($rule['data']) . "' ";
                 }
                 $search_param[] = $str;
             }
         }
     }
     if (!empty($search_param)) {
         $adv_filter_str .= (!empty($adv_filter_str) ? ' AND ' : '') . implode(" {$op} ", $search_param);
     }
     return $adv_filter_str;
 }
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:67,代码来源:filter.php


注:本文中的AJson::decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。