Esempio n. 1
0
 public function index($id = 0, $params = array())
 {
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     if (!empty($id)) {
         $data = fn_get_tax($id, $lang_code);
         if (empty($data)) {
             $status = Response::STATUS_NOT_FOUND;
         } else {
             $status = Response::STATUS_OK;
         }
     } else {
         $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_elements_per_page'));
         $page = $this->safeGet($params, 'page', 1);
         $data = fn_get_taxes($lang_code);
         $data = array_values($data);
         if ($items_per_page) {
             $data = array_slice($data, ($page - 1) * $items_per_page, $items_per_page);
         }
         $data = array('taxes' => $data, 'params' => array('items_per_page' => $items_per_page, 'page' => $page, 'total_items' => count($data)));
         $status = Response::STATUS_OK;
     }
     return array('status' => $status, 'data' => $data);
 }
Esempio n. 2
0
            }
        }
        $suffix = '.manage';
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['tax_id'])) {
            fn_delete_taxes($_REQUEST['tax_id']);
        }
        $suffix = '.manage';
    }
    return array(CONTROLLER_STATUS_OK, 'taxes' . $suffix);
}
// ---------------------- GET routines ---------------------------------------
// Edit tax rates
if ($mode == 'update') {
    $tax = fn_get_tax($_REQUEST['tax_id'], DESCR_SL);
    if (empty($tax)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $destinations = fn_get_destinations();
    Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'tax_rates' => array('title' => __('tax_rates'), 'js' => true)));
    Tygh::$app['view']->assign('tax', $tax);
    Tygh::$app['view']->assign('rates', db_get_hash_array("SELECT * FROM ?:tax_rates WHERE tax_id = ?i", 'destination_id', $_REQUEST['tax_id']));
    Tygh::$app['view']->assign('destinations', $destinations);
    // Add tax
} elseif ($mode == 'add') {
    Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true), 'tax_rates' => array('title' => __('tax_rates'), 'js' => true)));
    Tygh::$app['view']->assign('destinations', fn_get_destinations());
    // Edit taxes
} elseif ($mode == 'manage') {
    Tygh::$app['view']->assign('taxes', fn_get_taxes(DESCR_SL));