Example #1
0
 public function run()
 {
     $country = Country::model()->findAll(['order' => 'country_order']);
     $region = Regions::model()->findAllByAttributes(['id_country' => $this->model['countries']]);
     $city = City::model()->findAllByAttributes(['id_region' => $this->model['region']]);
     $this->render('main', ['model' => $this->model, 'title' => $this->title, 'prefix_name' => $this->prefixName, 'country' => $country, 'region' => $region, 'city' => $city]);
 }
Example #2
0
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'mode' => array('type' => 'dropdownlist', 'items' => array('UPS' => 'Domestic US UPS Mode', 'IUPS' => 'IUPS International UPS Mode')), 'username' => array('type' => 'text', 'maxlength' => 64), 'password' => array('type' => 'text', 'maxlength' => 64), 'accesskey' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => ups::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'package' => array('type' => 'dropdownlist', 'items' => ups::$package_types), 'ratecode' => array('type' => 'dropdownlist', 'items' => ups::$rate_types), 'customerclassification' => array('type' => 'dropdownlist', 'items' => array('04' => 'Retail', '03' => 'Occasional', '01' => 'Wholesale')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Example #3
0
 /**
  * 
  */
 public function beforeSave()
 {
     if ($this->getIsNewRecord()) {
         // Assign the user_id 1 if is a guest
         ///TODO:add userid. Issue, cant make use of user component while other request is open(subject/fetch)		$this->user_id=(Yii::app()->user->getId()) ? Yii::app()->user->getId() : 1;
         $this->user_id = 0;
         //$this->time = SiteLibrary::utc_time();
         $this->user_ip = $_SERVER['REMOTE_ADDR'];
         $country_id = 1;
         $country_code = 'WW';
         if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
             Yii::import('ext.EGeoIP');
             $geoIp = new EGeoIP();
             $geoIp->locate($_SERVER['REMOTE_ADDR']);
             //http://www.iso.org/iso/english_country_names_and_code_elements
             $country = Country::model()->find('code=:code', array(':code' => $geoIp->countryCode));
             if ($country) {
                 $country_id = $country->id;
                 $country_code = $country->code;
             }
         }
         $this->country_id = $country_id;
         $this->time = SiteLibrary::utc_time();
         $this->user_id = Yii::app()->user->id;
     }
     return true;
 }
Example #4
0
 public function actionAdd()
 {
     global $arr_response;
     $model = new Subject();
     $model->scenario = 'add';
     $_REQUEST['content_type_id'] = ContentType::model()->find('name=:name', array(':name' => $_REQUEST['content_type']))->id;
     $_REQUEST['country_id'] = Country::model()->find('code=:code', array(':code' => $_REQUEST['country_code']))->id;
     $_REQUEST['priority_id'] = Priority::model()->find('name=:name', array(':name' => $_REQUEST['priority']))->id;
     if ($_REQUEST['time']) {
         if (date("l", $_REQUEST['time'])) {
             //if its a valid timestamp
             $_REQUEST['user_position_ymd'] = date("Y", $_REQUEST['time']) . "/" . date("m", $_REQUEST['time']) . "/" . date("d", $_REQUEST['time']);
             $_REQUEST['user_position_hour'] = date("H", $_REQUEST['time']);
             $_REQUEST['user_position_minute'] = date("i", $_REQUEST['time']);
         }
     } else {
         $_REQUEST['user_position_anydatetime'] = 1;
     }
     $model->attributes = $_REQUEST;
     //NOTICE that we are creating a new record, so model its not loaded, ($model->content_type its juest the received $_REQUEST parameter)
     //print_r($model);
     //$model->content_type_id = $content_type->id;
     if ($model->save()) {
         $arr_response['response_message'] = Yii::t('subject', 'Subject successfully saved.');
     } else {
         $arr_response['response_code'] = 409;
         $arr_response['response_message'] = Yii::t('subject', 'Subject could not be saved.');
         $arr_response['response_details'] = $model->getErrors();
     }
 }
Example #5
0
 function updateAction()
 {
     $model = new Address();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') {
         if (isset($_POST['AFID_ALL']) || isset($_POST['AFID']) && !$_POST['AFID']) {
             $_POST['AFID'] = NULL;
         }
         $model->fillFromArray($_POST, FALSE);
         $model->user_id_updated = $this->user->user_id;
         $model->updated = 'NOW():sql';
         $model->model_uset_id = $this->user->user_id;
         if ($model->save()) {
             Message::echoJsonSuccess(__('address_updated'));
         } else {
             Message::echoJsonError(__('address_not_updated'));
         }
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = $model->country_id ? State::model()->getStatesByCID($model->country_id) : array();
     $this->addToPageTitle('Update address');
     Assets::js('jquery.form');
     $this->render('update', array('model' => $model, 'countries' => $countries, 'states' => $states));
 }
Example #6
0
 function viewAction()
 {
     $clearArray = array('campaign_id', 'aff_id');
     $this->filter($clearArray);
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('Prospect', $this->params, $pagination);
     $dataProvider = $models->getAll();
     $filterFields = $models->getoutFilterFields($clearArray);
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_table', array('application', 'views', 'prospects'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'ajax' => true));
         die;
     }
     /*
     $prospects = $models->getAll();
     $countries = $models->getCountries();
     $campaignsFilter = $models->getCampaignsCountProspects();
     $afids = $models->getAfids();
     */
     $affiliates = Affiliate::model()->cache()->findAllInArray();
     $countries = Country::model()->cache()->findAllInArray();
     $campaigns = Campaign::model()->cache()->findAllInArray();
     Assets::js('ajax_table');
     Assets::js('af_input_field');
     $this->addToPageTitle('Prospects');
     $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'affiliates' => $affiliates, 'countries' => $countries, 'campaigns' => $campaigns));
 }
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'accnumber' => array('type' => 'text', 'maxlength' => 64), 'meternumber' => array('type' => 'text', 'maxlength' => 64), 'securitycode' => array('type' => 'text', 'maxlength' => 64), 'authkey' => array('type' => 'text', 'maxlength' => 64), 'originadde' => array('type' => 'text', 'maxlength' => 64), 'origincity' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => fedex::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'packaging' => array('type' => 'dropdownlist', 'items' => array('YOUR_PACKAGING' => 'Your packaging', 'FEDEX_BOX' => 'FedEx Box', 'FEDEX_PAK' => 'FedEx Pak', 'FEDEX_TUBE' => 'FedEx Tube')), 'ratetype' => array('type' => 'dropdownlist', 'items' => array('RATED_LIST' => 'List Rates', 'RATED_ACCOUNT' => 'Negotiated rates')), 'customs' => array('type' => 'dropdownlist', 'items' => array('CLEARANCEFEE' => 'FedEx Handles Customs Clearance', 'NOCHARGE' => 'My store handles Customs Clearance')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Example #8
0
 public function actionUpdate($id)
 {
     $model = new SettingsForm();
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromStore($id);
     }
     $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
     $themes = array();
     foreach ($directories as $directory) {
         $themes[] = basename($directory);
     }
     $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
     $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
     $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
     $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
     $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
     $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
     $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
     $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
     $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
     // TODO: localisation
     $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
     // TODO: localisation
     $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
     $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
     $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
 }
Example #9
0
 public static function DropDown()
 {
     $res = array();
     foreach (Country::model()->findAll("visible = :visible", array(":visible" => 1)) as $record) {
         $res[$record->idCountry] = $record->CountryName;
     }
     return $res;
 }
Example #10
0
 private function mapCountry(\Address $address)
 {
     $country = null;
     if ($code = $this->getAssignedProperty('Country')) {
         if (!($country = \Country::model()->findByAttributes(array('code' => $code)))) {
             $this->addWarning('Unrecognised country code ' . $code);
         }
     }
     $address->country_id = $country ? $country->id : null;
 }
Example #11
0
 public function actionDelete($ids)
 {
     $ids = explode(',', $ids);
     if (count($ids) > 0) {
         foreach ($ids as $id) {
             $country = Country::model()->findByPk($id);
             $country->delete();
         }
     }
     $this->redirect(array('index'));
 }
Example #12
0
 /**
  * Get the list of countries
  */
 public function actionGetcountries()
 {
     global $arr_response;
     $countries = Country::model()->findAll();
     foreach ($countries as $country) {
         $i++;
         $arr_countries[$i]['code'] = $country['code'];
         $arr_countries[$i]['name'] = $country['name'];
     }
     $arr_response['countries'] = $arr_countries;
 }
Example #13
0
 public static function getNameById($id)
 {
     if (!$id) {
         return '';
     }
     if (empty(self::$nameById[$id])) {
         $c = Country::model()->findByPk($id);
         if ($c) {
             self::$nameById[$id] = $c->name;
         }
     }
     return self::$nameById[$id];
 }
Example #14
0
 public static function check($_cpt, $_shrt)
 {
     $country = Country::model()->find('short=:shrt', array(':shrt' => $_shrt));
     if ($country !== null) {
         return $country->getPrimaryKey();
     }
     $country = new Country();
     $country->attributes = array('caption' => $_cpt, 'short' => $_shrt);
     if ($country->save()) {
         return $country->getPrimaryKey();
     }
     return 1;
     //false;
 }
Example #15
0
 /**
  * Get city info by zip
  *
  */
 public function actionGetCityInfoByZip($zipCode)
 {
     $city = USCity::model()->find('city_zip=:zipcode', array(':zipcode' => $zipCode));
     if (!$city) {
         echoJson(array('error' => at('Sorry, That zip code does not exists.')));
     }
     // Get state id
     $state = USState::model()->find('short=LOWER(:short)', array(':short' => strtolower($city->city_state)));
     // Get us country
     $country = Country::model()->find('short=LOWER(:short)', array(':short' => 'us'));
     $info = array('city_name' => $city->city_name, 'city_zip' => $city->city_zip, 'city_state' => $state ? $state->id : 0, 'country' => $country ? $country->id : 0);
     $text = at("Zip Code Exists.\nCity Name: {cityname}, State: {state}", array('{cityname}' => $city->city_name, '{state}' => $city->city_state));
     echoJson(array('info' => $info, 'text' => $text));
 }
Example #16
0
 public function toModel(\Address $address)
 {
     $address->address1 = $this->line1;
     $address->address2 = $this->line2;
     $address->city = $this->city;
     $address->county = $this->state;
     $address->postcode = $this->zip;
     $crit = new \CDbCriteria();
     $crit->addColumnCondition(array('code' => $this->country, 'name' => $this->country), 'OR');
     $country = \Country::model()->find($crit);
     if (!$country) {
         $country = \Country::model()->findByAttributes(array('code' => 'GB'));
     }
     $address->country_id = $country->id;
 }
Example #17
0
 public function toModel(\Address $address)
 {
     $address->address1 = $this->line1;
     $address->address2 = $this->line2;
     $address->city = $this->city;
     $address->county = $this->state;
     $address->postcode = $this->zip;
     $crit = new \CDbCriteria();
     $crit->addColumnCondition(array('code' => $this->country, 'name' => $this->country), 'OR');
     $country = \Country::model()->find($crit);
     if (!$country) {
         throw new InvalidValue("Unrecognised country: '{$this->country}'");
     }
     $address->country_id = $country->id;
 }
 /**
  * @param string|null $cityName
  * @param string|null $countryName
  */
 public function actionGetInfoForByCityName($cityName = null, $countryName = null)
 {
     $criteria = new CDbCriteria();
     if ($cityName) {
         $criteria->join = 'RIGHT JOIN ' . Country::tableName() . ' country ON country.id_country=t.id_country';
         $criteria->condition = 't.city_name_ru = :city AND country.country_name_ru = :country';
         $criteria->params = array(':city' => $cityName, ':country' => $countryName);
         $model = City::model()->find($criteria);
         echo json_encode(array('id_country' => $model->id_country, 'id_region' => $model->id_region, 'id_city' => $model->id_city));
     } else {
         if ($countryName) {
             $criteria->condition = 'country_name_ru = :country';
             $criteria->params = array(':country' => $countryName);
             $model = Country::model()->find($criteria);
             echo json_encode(array('id_country' => $model->id_country, 'id_region' => 0, 'id_city' => 0));
         }
     }
 }
 public function actionCitiesWithAnyInCountry($cid)
 {
     if (!Yii::app()->user->isGuest && Yii::app()->request->isAjaxRequest) {
         if ($cid > 0) {
             $country = ' (' . Country::model()->find(array('select' => 'name', 'condition' => 'country_id=:cid', 'params' => array(':cid' => $cid)))->name . ')';
             $base_cities = City::model()->findAll(array('select' => 'name, city_id', 'condition' => 'country_id=:cid', 'params' => array(':cid' => $cid)));
         } elseif ($cid == -1) {
             $country = '';
             $base_cities = array();
         } else {
             throw new CException('Not Found', 404);
         }
         $any_city = new City();
         $any_city->name = 'любой город' . $country;
         $any_city->city_id = -$cid;
         $cities = array_merge(array($any_city), $base_cities);
         $data = CHtml::listData($cities, 'city_id', 'name');
         echo CJSON::encode($data);
         Yii::app()->end();
     }
     throw new CException('Not Found', 404);
 }
Example #20
0
 /**
  * Show users table
  */
 public function index()
 {
     $clang = Yii::app()->lang;
     if (!Permission::model()->hasGlobalPermission('Regions', 'create')) {
         Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . "jquery.dataTables.css");
     App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'jquery.dataTables.min.js');
     $aData['row'] = 0;
     $country = Country::model()->findAll();
     $countrylist = CHtml::listData($country, 'country_id', 'country_name');
     $firstcountry = array_keys($countrylist);
     if (count($firstcountry)) {
         $fc = $firstcountry[0];
     } else {
         $fc = 0;
     }
     if (isset(Yii::app()->request->cookies['Country'])) {
         if (isset($_POST['country_name'])) {
             $country_id = (int) $_POST['country_name'];
         } else {
             $country_id = Yii::app()->request->cookies['Country']->value;
         }
     } else {
         if (isset($_POST['country_name'])) {
             $country_id = (int) $_POST['country_name'];
         } else {
             $country_id = $fc;
         }
     }
     Yii::app()->request->cookies['Country'] = new CHttpCookie('Country', $country_id);
     $userlist = getCitylistcountry($country_id);
     $aData['usr_arr'] = $userlist;
     $aData['country_id'] = $country_id;
     $aData['imageurl'] = Yii::app()->getConfig("adminimageurl");
     $this->_renderWrappedTemplate('region/city', 'view_addcity', $aData);
 }
 /**
  * Only validate the zip / postal code for countries
  * that have a defined postcode pattern matching rule
  * in the db
  * @param $attribute The attribute name.
  * @param $params Additional parameters defined in the rules.
  * @return void
  */
 public function validatePostal($attribute, $params)
 {
     $validate = false;
     $objCountries = Country::model()->withpostal()->findAll();
     if ($attribute == 'shippingPostal') {
         $country = $this->shippingCountry;
     }
     if ($attribute == 'billingPostal') {
         $country = $this->billingCountry;
     }
     if (empty($country)) {
         return;
     }
     foreach ($objCountries as $objCountry) {
         if ($country === $objCountry->id) {
             $validate = true;
             break;
         }
     }
     if ($validate === true) {
         parent::validatePostal($attribute, $params);
     }
     return;
 }
 public function run($args)
 {
     $this->pcu = new PostCodeUtility();
     $this->country_id = Country::model()->findByAttributes(array('code' => 'GB'))->id;
     $this->cbt_id = CommissioningBodyType::model()->findByAttributes(array('shortname' => 'CCG'))->id;
     foreach (self::$files as $type => $params) {
         $f = $this->downloadAndOpen($params['url']);
         while ($row = fgetcsv($f)) {
             print "{$type} {$row[0]}\n";
             $data = array_combine(array_pad($params['fields'], count($row), ""), $row);
             $tx = Yii::app()->db->beginTransaction();
             try {
                 $this->{"import{$type}"}($data);
                 $tx->commit();
             } catch (Exception $e) {
                 $message = "Error processing {$type} row:\n" . CVarDumper::dumpAsString($row) . "\n{$e}";
                 Yii::log($message, CLogger::LEVEL_ERROR);
                 print "{$message}\n";
                 $tx->rollback();
             }
         }
         fclose($f);
     }
 }
Example #23
0
 public function behaviors()
 {
     $bs = array('AdminBehavior' => array('class' => 'application.admin.components.behaviours.AdminBehavior', 'fields' => array(array('name' => 'Город', 'attribute' => 'name', 'type' => 'text'), array('name' => 'Регион', 'attribute' => 'regionId', 'type' => 'autocomplete', 'source' => Yii::app()->createUrl('site/region'), 'valueField' => 'regionId', 'textField' => 'name', 'value' => $this->region->name), array('name' => 'Страна', 'attribute' => 'countryId', 'type' => 'dropdown', 'data' => array('model' => Country::model()->findAll(), 'valueField' => 'countryId', 'textField' => 'name'))), 'columns' => array('cityId', 'name')));
     return CMap::mergeArray(parent::behaviors(), $bs);
 }
 /**
  * Modify User POST
  */
 function modcountry()
 {
     $clang = Yii::app()->lang;
     $countries_id = (int) Yii::app()->request->getPost("country_id");
     $countries_name = flattenText(Yii::app()->request->getPost("country_name"));
     $continent_name = flattenText(Yii::app()->request->getPost("continent_name"));
     $IsActive = flattenText(Yii::app()->request->getPost("IsActive"));
     $c_name = flattenText(Yii::app()->request->getPost("c_name"));
     $addsummary = '';
     $aViewUrls = array();
     $is_Active = 0;
     if ($IsActive) {
         $is_Active = 1;
     }
     $sresult = Country::model()->findAllByAttributes(array('country_id' => $countries_id));
     $sresultcount = count($sresult);
     if (Permission::model()->hasGlobalPermission('superadmin', 'read') || $sresultcount > 0 && Permission::model()->hasGlobalPermission('Regions', 'update')) {
         if ($c_name == '') {
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing country"), $clang->gT("Could not modify country."), "warningheader", $clang->gT("Country  name not be empty."), $this->getController()->createUrl('admin/country/modifycountry'), $clang->gT("Back"), array('country_id' => $countries_id));
         } elseif (Country::model()->findByAttributes(array('country_name' => $c_name, 'continent' => $continent_name, 'IsActive' => $is_Active))) {
             $aViewUrls['message'] = array('title' => $clang->gT("Failed to add Contry"), 'message' => $clang->gT("The Country already exists."), 'class' => 'warningheader');
         } else {
             $oRecord = Country::model()->findByPk($countries_id);
             $oRecord->country_name = $this->escape($c_name);
             $oRecord->continent = $this->escape($continent_name);
             $oRecord->IsActive = $this->escape($is_Active);
             $uresult = $oRecord->save();
             // store result of save in uresult
             if ($uresult) {
                 // When saved successfully
                 Yii::app()->setFlashMessage($clang->gT("Country updated successfully"));
                 $this->getController()->redirect(array("admin/country/index"));
             } else {
                 //Saving the user failed for some reason, message about email is not helpful here
                 // Username and/or email adress already exists.
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing country"), $clang->gT("Could not modify country."), 'warningheader');
             }
         }
     } else {
         Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     $this->_renderWrappedTemplate('region/country', $aViewUrls);
 }
Example #25
0
?>
	<div class="row">
		<?php 
echo $form->label($model, 'name');
?>
                <?php 
echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'country_id');
?>
		<?php 
$data = Country::model()->GetCountriesICanEdit();
echo CHtml::activeDropDownList($model, 'country_id', CHtml::listData($data, 'id', 'country'), array('empty' => Yii::t('app', 'choose')));
?>
	</div>

	<div class="row buttons">
        <br /><?php 
$this->widget('zii.widgets.jui.CJuiButton', array('name' => 'button', 'caption' => Yii::t('app', 'search'), 'value' => Yii::t('app', 'search')));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- search-form -->
Example #26
0
 function updateAction()
 {
     $model = new Tax();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['model']) && $_POST['model'] == 'Tax') {
         if (isset($_POST['ajax'])) {
             $model->fillFromArray($_POST, FALSE);
             $model->user_id_updated = $this->user->user_id;
             $model->updated = 'NOW():sql';
             $model->model_uset_id = $this->user->user_id;
             if ($model->save(true, null, false)) {
                 Message::echoJsonSuccess(__('tax_updated'));
             } else {
                 Message::echoJsonError(__('tax_no_updated'));
             }
             die;
         }
         $model->save();
         $this->redirect();
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->fillFromDbPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = State::model()->getStates($model->country_id);
     Assets::js('jquery.form');
     $this->addToPageTitle('Update Tax');
     $this->render('update', array('model' => $model, 'states' => $states, 'countries' => $countries));
 }
	public function findcountry($id)
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.
		$name = Country::model()->findByPk($id);
		return $name->name;
		
	}
Example #28
0
<tr>	
	<td class="label">House No</td><td colspan="3"><?php echo $StudentAddress->student_c_house_no;?></td>
</tr>
<tr>
<td class="label" colspan="4" align="center"><b>Permanent Address</b></td>
</tr>
<tr>	
	<td class="label">Street 1</td><td colspan="3"><?php echo $StudentAddress->student_address_p_line1;?></td>
</tr>
<tr>	
	<td class="label">Street 2</td><td colspan="3"><?php echo $StudentAddress->student_address_p_line2;?></td>
</tr>
<tr>	
	<td class="label">Country</td><td><?php 
		if($StudentAddress->student_address_p_country!=0)
		echo  Country::model()->findByPk($StudentAddress->student_address_p_country)->name;
		else
		echo "";
		?></td>
	<td class="label">State</td><td><?php 
		if($StudentAddress->student_address_p_state !=0)
		echo State::model()->findByPk($StudentAddress->student_address_p_state)->state_name;
		else
		echo "";
		?></td>
</tr>
<tr>	
	<td class="label">Town</td><td><?php echo $StudentAddress->student_address_p_city;?></td>
	<td class="label">Postcode</td><td><?php echo $StudentAddress->student_address_p_pin;?></td>
</tr>
<tr>	
Example #29
0
 public function behaviors()
 {
     $bs = array('AdminBehavior' => array('class' => 'application.admin.components.behaviours.AdminBehavior', 'fields' => array(array('name' => 'Регион', 'attribute' => 'name', 'type' => 'text'), array('name' => 'Страна', 'attribute' => 'countryId', 'type' => 'dropdown', 'data' => array('model' => Country::model()->findAll(), 'valueField' => 'countryId', 'textField' => 'name'))), 'columns' => array('regionId', 'name')));
     return CMap::mergeArray(parent::behaviors(), $bs);
 }
?>	
<div class="certificate_main">
	<div id="printid1" class="header" style="border-bottom:2px solid">
      		     <div class="logo" >
 			    <?php $org_data = Organization::model()->findAll();
				echo CHtml::image(Yii::app()->controller->createUrl('/site/loadImage', array('id'=>$org_data[0]->organization_id)),'No Image',array('width'=>80,'height'=>55));
    ?>
 	            </div>

    		    <div class="address" style="font-size:12px;">
			    <?php
				
				echo $org_data[0]->organization_name."</br>";
				echo $org_data[0]->address_line1." ";
				echo $org_data[0]->address_line2."</br>";
				echo City::model()->findBypk($org_data[0]->city)->city_name.", ".State::model()->findBypk($org_data[0]->state)->state_name.", ".Country::model()->findBypk($org_data[0]->country)->name.".";
				?>   
    		   </div>
 		</div>
  
	<div class="certificate_content">
		
		<div>
			<div class="content">
			<div class="watermark-area">
			</div><!--Watermark Div end-->
			  
			 <?php
		
		//$updated_cont = str_replace('{name}','Name',$content);
		echo  $content;//Certificate::model()->findByPk($certificate_type)->certificate_content; ?>