function listProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $osC_Tax = new osC_Tax_Admin();
     $Qtc = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title');
     $Qtc->bindTable(':table_tax_class', TABLE_TAX_CLASS);
     $Qtc->execute();
     $tax_class_array = array();
     while ($Qtc->next()) {
         $tax_class_array[$Qtc->valueInt('tax_class_id')] = $osC_Tax->getTaxRate($Qtc->valueInt('tax_class_id'));
     }
     $Qproducts = $osC_Database->query('select p.products_id, pd.products_name, p.products_tax_class_id from :table_products p, :table_products_description pd where p.products_id = pd.products_id and pd.language_id = :language_id and p.products_type <> :products_type');
     $Qproducts->appendQuery(' order by pd.products_name');
     $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
     $Qproducts->bindInt(':language_id', $osC_Language->getID());
     $Qproducts->bindInt(':products_type', PRODUCT_TYPE_GIFT_CERTIFICATE);
     $Qproducts->setExtBatchLimit($start, $limit);
     $Qproducts->execute();
     $records = array();
     while ($Qproducts->next()) {
         $rate = $Qproducts->valueInt('products_tax_class_id') == 0 ? 0 : $tax_class_array[$Qproducts->valueInt('products_tax_class_id')];
         $records[] = array('products_id' => $Qproducts->value('products_id'), 'products_name' => $Qproducts->value('products_name'), 'rate' => $rate);
     }
     $response = array(EXT_JSON_READER_TOTAL => $Qproducts->getBatchSize(), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Пример #2
0
 function getTaxClasses()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     require_once 'includes/classes/tax.php';
     $osC_Tax = new osC_Tax_Admin();
     $Qtc = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title');
     $Qtc->bindTable(':table_tax_class', TABLE_TAX_CLASS);
     $Qtc->execute();
     $tax_class_array = array(array('id' => '0', 'rate' => '0', 'text' => $osC_Language->get('none')));
     while ($Qtc->next()) {
         $tax_class_array[] = array('id' => $Qtc->valueInt('tax_class_id'), 'rate' => $osC_Tax->getTaxRate($Qtc->valueInt('tax_class_id')), 'text' => $Qtc->value('tax_class_title'));
     }
     $response = array(EXT_JSON_READER_ROOT => $tax_class_array);
     echo $toC_Json->encode($response);
 }
Пример #3
0
 function listProducts()
 {
     global $toC_Json, $osC_Database, $osC_Language;
     $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
     $limit = empty($_REQUEST['limit']) ? MAX_DISPLAY_SEARCH_RESULTS : $_REQUEST['limit'];
     $variants = isset($_POST['variants']) ? $_POST['variants'] : 0;
     $osC_Tax = new osC_Tax_Admin();
     $Qtc = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title');
     $Qtc->bindTable(':table_tax_class', TABLE_TAX_CLASS);
     $Qtc->execute();
     $tax_class_array = array();
     while ($Qtc->next()) {
         $tax_class_array[$Qtc->valueInt('tax_class_id')] = $osC_Tax->getTaxRate($Qtc->valueInt('tax_class_id'));
     }
     //get the variants products
     if ($variants == 1) {
         $result = osC_Specials_Admin::getVariantsProducts($start, $limit);
         //get the general products
     } else {
         $result = osC_Specials_Admin::getProducts($start, $limit);
     }
     $records = array();
     if (count($result['products']) > 0) {
         foreach ($result['products'] as $product) {
             $rate = $product['products_tax_class_id'] == 0 ? 0 : $tax_class_array[$product['products_tax_class_id']];
             $records[] = array('products_id' => $product['products_id'], 'products_name' => $product['products_name'], 'rate' => $rate);
         }
     }
     $response = array(EXT_JSON_READER_TOTAL => $result['total'], EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }