/** * Updates an existing Brands model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $countries = Countries::find()->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'countries' => $countries]); } }
static function loadCountries() { $countries = \app\models\Countries::find()->asArray()->all(); /*for($i=0;$i<=count($categories)-1;$i++){ if($categories[$i]['parent']!=0){ $categories[$i]['name']=$categories[$i]['name']."(".\app\models\Category::findOne(['id'=>$categories[$i]['parent']])->name.")"; } }*/ $countries = ArrayHelper::map($countries, 'country_id', 'name'); return $countries; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Countries::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Countries::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['defaultOrder' => ['name' => SORT_ASC]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'area' => $this->area, 'population' => $this->population]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'capital', $this->capital]); return $dataProvider; }
public function getCountryName() { $currency = Countries::find()->select('name as country_name')->filterWhere(['code' => $this->countryid == '' ? '-' : $this->countryid])->asArray()->all(); return $currency[0]['country_name']; }
<div class="jackpot-details-form<?php echo $model->continent; ?> "> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php $continentData = ArrayHelper::map($continents, 'code', 'name'); $countryData = Countries::find()->select('countries.name as name, countries.code as code, countries.currency_code as currency')->innerJoinWith('countryListCode', false)->filterWhere(['continent_code' => $model->continent == '' ? '-' : $model->continent])->asArray()->all(); $currency = Countries::find()->select('countries.currency_code as currency')->filterWhere(['code' => $model->countryid == '' ? '-' : $model->countryid])->asArray()->all(); $currency[0]["currency"] = empty($currency) ? "" : $currency[0]["currency"]; // echo Yii::$app->customFun->prx($currency); $countryData = ArrayHelper::map($countryData, 'code', 'name'); echo $form->field($model, 'continent')->dropDownList($continentData, ['code' => 'name', 'prompt' => 'Select Continent', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl(["jackpot-section/continent_country"]) . '&code="+$(this).val(), function( data ) { var json = $.parseJSON(data); $( "#jackpotdetails-countryid" ).html( json.country ); $( ".currency_code" ).html( json.currency ); }); '])->label('Continent'); ?> <?php echo $form->field($model, 'countryid')->dropDownList($countryData, ['prompt' => 'Select Country', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl(["jackpot-section/country_currency"]) . '&code="+$(this).val(), function( data ) {
</div> <div class="row"> <div class="col-sm-4 col-md-4"> <?php echo $form->field($model, 'zip_code')->widget(\yii\widgets\MaskedInput::classname(), ['mask' => '99999']); ?> </div> <div class="col-sm-4 col-md-4"> <?php echo $form->field($model, 'countries')->widget(Select2::classname(), ['language' => 'de', 'data' => ArrayHelper::map(Countries::find()->all(), 'country_code', 'country_name'), 'options' => ['placeholder' => 'เลือกประเทศ ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-4 col-md-4"> <?php echo $form->field($model, 'mobile_phone')->widget(\yii\widgets\MaskedInput::classname(), ['mask' => '99-9999-9999']); ?> </div> </div> <div class="row"> <div class="col-sm-6 col-md-6"> <?php echo $form->field($model, 'email')->textInput(['maxlength' => 150]);
public function actionContinent_country($param = '') { $countries = Countries::find()->filterWhere(['countries.continent_code' => $_REQUEST["code"]])->asArray()->all(); if (count($countries) > 0) { foreach ($countries as $country) { echo "<option value='" . $country['code'] . "'>" . $country['name'] . "</option>"; } } else { echo "<option>-</option>"; } }
public function actionCountry_currency($param = '') { if ($_REQUEST["code"] != "") { $countries = Countries::find()->filterWhere(['countries.code' => $_REQUEST["code"]])->asArray()->all(); return $countries[0]['currency_code']; } else { return ''; } }
<?php use app\models\Countries; // print_r($detail['lastconnected']['ISO']); $response = file_get_contents("http://ip-api.com/json/{$_SERVER['REMOTE_ADDR']}", false, $context); // $response = file_get_contents("http://ip-api.com/json/14.192.159.252",false, $context); $IPResponse = json_decode($response); // print_r($IPResponse); global $cannotRegister, $userCountry, $userState; $GLOBALS['cannotRegister'] = "false"; $GLOBALS['userCountry'] = $IPResponse->countryCode; // var_dump($cannotRegister,$userCountry,$userState); $banned = Countries::find('first', array('conditions' => array('ISO2' => $GLOBALS['userCountry']))); // print_r($GLOBALS['userCountry']); // print_r($banned['Country']); // var_dump($banned['ISO2']); if ($banned['banned'] == true) { $GLOBALS['cannotRegister'] = "true"; }
/** * Lists all Countries models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Countries::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function companyid($id = null) { $function = new Functions(); $company = Companies::find('first', array('conditions' => array('hash' => $id))); if (count($company) == 0) { return $this->redirect('kyc::index'); } if ($this->request->data) { // if(stristr( $_SERVER['HTTP_REFERER'],COMPANY_URL)===FALSE){return $this->redirect('/kyc');exit;} $conditions = array('email' => $company['email'], 'kyc_id' => $company['kyc_id']); $save = Companies::update($this->request->data, $conditions); } $company = Companies::find('first', array('conditions' => array('hash' => $id))); $countries = Countries::find('all', array('order' => array('order' => 1))); return compact('company', 'countries'); }