Exemplo n.º 1
1
 public static function getCountryDefault($countryID)
 {
     if (!$countryID) {
         return false;
     }
     $sql = "SELECT *\n                FROM `taxes`\n                WHERE `country_id` = ?s\n                AND `state_code` IS NULL";
     $db = self::$_msql = SafeMySQL::getInstance();
     $result = $db->getRow($sql, $countryID);
     if ($result) {
         $tax = new Tax();
         $tax->fillFromArray($result);
         return $tax;
     }
     return false;
 }
Exemplo n.º 2
0
 function viewAction()
 {
     $clearArray = array();
     $this->filter($clearArray);
     $stateCode = AF::get($this->params, 'state_code', null);
     $countryID = AF::get($this->params, 'country_id', null);
     $defaultCheck = $countryID ? null : AF::get($this->params, 'searchdefaultCountryCheck', null);
     $stateModel = new State();
     if ($stateCode && !$countryID) {
         $stateModel->fillFromStateCode($stateCode);
         $countryID = $stateModel->country_id;
         $this->params['country_id'] = $countryID;
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     // pass in blank model with possible location info to be used in pre-selecting fields during tax creation on the modal form
     $model = new Tax();
     $model->state_code = $stateCode;
     $model->country_id = $countryID;
     $models = AFActiveDataProvider::models('Tax', $this->params, $pagination);
     $dataProvider = $defaultCheck ? $models->getDefaultCountries() : $models->getAll();
     $filterFields = $models->getoutFilterFields($clearArray);
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_table', array('application', 'views', 'taxes'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields));
         die;
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = State::model()->cache()->findAllInArray();
     $countryDefault = Taxs::getCountryDefault($countryID);
     Assets::js('jquery.form');
     Assets::js('ajax_table');
     Assets::js('af_input_field');
     $this->addToPageTitle('Taxes');
     $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'countries' => $countries, 'states' => $states, 'countryDefault' => $countryDefault, 'countryID' => $countryID, 'model' => $model, 'filterFields' => $filterFields));
 }