public function actionIndex() { $query = Country::find(); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('index', ['countries' => $countries, 'pagination' => $pagination]); }
public function search($params) { $query = Country::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->andFilterWhere([Country::tableName() . '.status' => '1']); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'status' => $this->status, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'countryCode', $this->countryCode]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Country::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(['country_id' => $this->country_id, 'status' => $this->status, 'ordering' => $this->ordering]); $query->andFilterWhere(['like', 'country_code', $this->country_code])->andFilterWhere(['like', 'country_code_2', $this->country_code_2])->andFilterWhere(['like', 'name_GB', $this->name_GB])->andFilterWhere(['like', 'name_RU', $this->name_RU]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Country::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, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'is_status' => $this->is_status]); $query->andFilterWhere(['like', 'country', $this->country]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Country::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'image', $this->image]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Country::find()->notDeleted(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'deleted' => $this->deleted]); $query->andFilterWhere(['like', 'iso2', $this->iso2])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'long_name', $this->long_name])->andFilterWhere(['like', 'iso3', $this->iso3])->andFilterWhere(['like', 'numcode', $this->numcode])->andFilterWhere(['like', 'un_member', $this->un_member])->andFilterWhere(['like', 'calling_code', $this->calling_code])->andFilterWhere(['like', 'cctld', $this->cctld]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CountryModel::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]); return $dataProvider; }
public function actionCountry() { $this->stdout('Request API: Countries.', Console::FG_GREEN); $data = TravelPayoutsApi::getCountries(); $_count = count($data); $this->stdout(' Get: ' . $_count . ' Countries.' . PHP_EOL, Console::FG_GREEN); Console::startProgress(0, $_count); $count = 0; $count_ = 0; foreach ($data as $value) { $name_translations = $value->name_translations; unset($value->name_translations); $country = Country::find()->where(['code' => $value->code])->one(); if (!$country) { $this->stdout($value->code . ' ', Console::FG_YELLOW); $country = new Country(); $country->attributes = (array) $value; $local = ['en-GB', 'en-AU', 'en-CA', 'en-NZ', 'en-IE', 'en-SG', 'en-IN']; foreach ($name_translations as $_key => $_name) { if (array_search($_key, $local) === false) { $country['name_' . $_key] = trim($_name); } } if (!$country->save()) { print_r($value); print_r($country->errors); return Controller::EXIT_CODE_ERROR; } $count++; } else { Console::updateProgress(++$count_, $_count); } } Console::endProgress(); $this->stdout(PHP_EOL . 'Added: ' . $count . ' Countries.' . PHP_EOL, Console::FG_BLUE); return Controller::EXIT_CODE_NORMAL; }
/** * [prepPayPalData description] * * Maps data from the two forms into the way the paypal component expects it. * * @version 0.5.1 * @since 0.5.1 * @param Purchase $param_data * @param CCFormat $cc_data * @return array */ private function prepPayPalData(Purchase $param_data, CCFormat $cc_data) { // todo This iteration is Paypal only. - DJE : 2015-04-11 // Process the CC transaction $return_data['Address'] = ['City' => $param_data->getAttribute('city'), 'CountryCode' => Country::find('value')->where(['id' => $param_data->getAttribute('country_id')])->one()->getAttribute('key'), 'Line1' => $param_data->getAttribute('street_1'), 'Line2' => $param_data->getAttribute('street_2'), 'PostalCode' => $param_data->getAttribute('postal'), 'State' => $param_data->getAttribute('prov')]; // Process the CC transaction $return_data['CreditCard'] = ['Cvv2' => $cc_data['cvv2'], 'FirstName' => $param_data->getAttribute('f_name'), 'LastName' => $param_data->getAttribute('l_name'), 'Month' => $cc_data['exp_month'], 'Number' => $cc_data['number'], 'Type' => $cc_data['type'], 'Year' => $cc_data['exp_year']]; $subtotal = []; $subtotal[0] = isset(\Yii::$app->request->post()['Purchase']['time_amount_id']) ? TimeAmountOptions::find('value')->where(['id' => \Yii::$app->request->post()['Purchase']['time_amount_id']])->one()->getAttribute('cost') : 0; $subtotal[1] = isset(\Yii::$app->request->post()['Purchase']['device_count_id']) ? DeviceCountOptions::find('value')->where(['id' => \Yii::$app->request->post()['Purchase']['device_count_id']])->one()->getAttribute('cost') : 0; $return_data['Details']['SubTotal'] = array_sum($subtotal); return $return_data; }
public function getCountries() { //$criteria = new CDbCriteria(); //$criteria->condition='status = 1'; //$criteria->order = 'countryName ASC'; $countryModel = Country::find()->where(['status' => 1])->orderBy(['countryName' => SORT_ASC])->all(); //model()->findAll($criteria); $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(Product::find()->all(), 'countryID', 'countryName')); if ($countryModel) { $countryList = ArrayHelper::map($countryModel, 'countryID', 'countryName'); // $countryList = Html::listData($countryModel, 'countryID', 'countryName'); return $countryList; } return false; }
echo $form->field($model, 'position')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'notes')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 200, 'plugins' => ['fullscreen', 'table', 'video', 'fontcolor']]]); ?> <?php echo $form->field($model, 'player_carrer')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 200, 'plugins' => ['fullscreen', 'table', 'video', 'fontcolor']]]); ?> <?php echo $form->field($model, 'coach_carrer')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 200, 'plugins' => ['fullscreen', 'table', 'video', 'fontcolor']]]); ?> <?php echo $form->field($model, 'country_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Country::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите страну...'], 'pluginOptions' => ['allowClear' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Изменить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<?php echo $form->field($purchase_mdl, 'street_1')->label(false)->textInput(['maxlength' => 45, 'placeholder' => 'Street 1']); ?> <?php echo $form->field($purchase_mdl, 'street_2')->label(false)->textInput(['maxlength' => 45, 'placeholder' => 'Street 2']); ?> <?php echo $form->field($purchase_mdl, 'city')->label(false)->textInput(['maxlength' => 45, 'placeholder' => 'City']); ?> <?php echo $form->field($purchase_mdl, 'prov')->label(false)->textInput(['maxlength' => 45, 'placeholder' => 'State / Prov.']); ?> <?php echo $form->field($purchase_mdl, 'postal')->label(false)->textInput(['maxlength' => 45, 'placeholder' => 'ZIP / Postal Code']); ?> <div class="form-group field-purchase-type required"> <div class="col-sm-6 col-sm-offset-3"> <?php echo Html::activeDropDownList($purchase_mdl, 'country_id', ArrayHelper::map(Country::find()->all(), 'id', 'value'), ['prompt' => '--Select Country--', 'class' => 'form-control']); ?> </div> </div> <?php echo $form->field($purchase_mdl, 'user_id')->label(false)->hiddenInput(['value' => Yii::$app->user->getIdentity()->getAttribute('id')]);