/** * Lists all HarvestPlant models. * @return mixed */ public function actionIndex() { $harvestToolsReportSearch = new HarvestToolsReportSearch(); $harvestToolsReportSearch->yearStart = date('Y'); $harvestToolsReportSearch->yearEnd = $harvestToolsReportSearch->yearStart; $harvestToolsReportSearch->quarterStart = 1; if (date('m') >= 9) { $harvestToolsReportSearch->quarterEnd = 4; } else { if (date('m') >= 6) { $harvestToolsReportSearch->quarterEnd = 3; } else { if (date('m') >= 3) { $harvestToolsReportSearch->quarterEnd = 2; } else { $harvestToolsReportSearch->quarterEnd = 1; } } } $typeToolses = TypeTools::find()->all(); $stateCount = State::find()->count(); $years = []; $quarters = []; $states = State::find()->select('name')->column(); $typeToolses2 = TypeTools::find()->select('name')->column(); $stateIds = []; if ($harvestToolsReportSearch->load(Yii::$app->request->post())) { $stateIds = $harvestToolsReportSearch->stateIds; if (!empty($stateIds)) { $stateCount = State::find()->where(['id' => $stateIds])->count(); $states = State::find()->select('name')->where(['id' => $stateIds])->column(); } $typeToolsIds = $harvestToolsReportSearch->typeToolsIds; if (!empty($typeToolsIds)) { $typeToolses = TypeTools::find()->where(['id' => $typeToolsIds])->all(); $typeToolses2 = TypeTools::find()->select('name')->where(['id' => $typeToolsIds])->column(); } $yearStart = $harvestToolsReportSearch->yearStart; $yearEnd = $harvestToolsReportSearch->yearEnd; for ($i = $yearStart; $i <= $yearEnd; $i++) { $years[] = $i; } $quarterStart = $harvestToolsReportSearch->quarterStart; $quarterEnd = $harvestToolsReportSearch->quarterEnd; for ($i = $quarterStart; $i <= $quarterEnd; $i++) { $quarters[] = $i; } } $renders['typeToolses'] = $typeToolses; $renders['stateCount'] = $stateCount; $renders['stateIds'] = $stateIds; $renders['years'] = $years; $renders['quarters'] = $quarters; $renders['states'] = $states; $renders['typeToolses2'] = $typeToolses2; $session = Yii::$app->session; $session->set('renderHarvestToolsReport', $renders); $renders['harvestToolsReportSearch'] = $harvestToolsReportSearch; return $this->render('index', $renders); }
public function actionGetorgstate($id) { $rows = \app\models\State::find()->where(['country_id' => $id, 'is_status' => 0])->ALL(); echo Html::tag('option', Html::encode(Yii::t('app', '--- Select State ---')), ['value' => '']); foreach ($rows as $row) { echo Html::tag('option', Html::encode($row->state_name), ['value' => $row->state_id]); } }
private function getStates() { $statesResult = State::find()->all(); $states = array(); foreach ($statesResult as $state) { $states[$state['id']] = $state['name']; } return $states; }
public function getCity(Request $req) { $state = State::find($req->id); $city = City::where('state_code', $state->code)->get(); $html = '<option value="" selected>Choose Option</option>'; foreach ($city as $cities) { $html .= '<option value="' . $cities->id . '">' . $cities->name . '</option>'; } echo $html; }
public function actionEditUserBlock($id) { $userModel = $this->findUserBlock($id); $model = Block::find()->with('links')->where(['id' => $userModel->block_id])->one(); $states = State::find()->all(); $test = Link::find()->where(['id' => 2])->one(); if ($userModel->load(Yii::$app->request->post()) && $userModel->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('app', '{model} SUCCESS_UPDATED', ['model' => $model->title])); } return $this->render('userSettings', ['userModel' => $userModel, 'model' => $model, 'states' => $states, 'test' => $test]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = State::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100]], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]); $params = $this->processParams($params); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'country_id' => $this->country_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
public function actionEmp_p_state($id) { $rows = \app\models\State::find()->where(['state_country_id' => $id, 'is_status' => 0])->all(); echo "<option value=''>---Select State---</option>"; if (count($rows) > 0) { foreach ($rows as $row) { echo "<option value='{$row->state_id}'>{$row->state_name}</option>"; } } else { echo ""; } }
public static function customJs() { $translates = []; $langs = ['No items selected']; foreach ($langs as $lang) { $translates[$lang] = __($lang); } $hash_states = []; $states = State::find()->orderBy('name asc')->asArray()->all(); foreach ($states as $state) { $hash_states[$state['country_id']][] = ['id' => $state['id'], 'name' => $state['name']]; } return "window.yii.app = " . Json::encode(['states' => $hash_states, 'langs' => $translates]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = State::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, 'active' => $this->active]); $query->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'category', $this->category]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = State::find()->where(['is_status' => 0]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['state_id' => SORT_DESC]]]); $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(['state_id' => $this->state_id, 'state_country_id' => $this->state_country_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'is_status' => $this->is_status]); $query->andFilterWhere(['like', 'state_name', $this->state_name]); unset($_SESSION['exportData']); $_SESSION['exportData'] = $dataProvider; return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = State::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(['id' => $this->id, 'sort' => $this->sort, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'name', $this->name]); $query->andFilterWhere(['like', 'coords', $this->name]); return $dataProvider; }
public function actionState() { $states = State::find()->all(); return $this->render('state', ['model' => $states]); }
</div> <div class="col-xs-12 col-sm-12 col-lg-12 no-padding"> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($address, 'stu_padd_country')->dropDownList(ArrayHelper::map(\app\models\Country::find()->where(['is_status' => 0])->all(), 'country_id', 'country_name'), ['prompt' => Yii::t('stu', '--- Select Country ---'), 'onchange' => ' $.get( "' . Url::toRoute('dependent/ustud_p_state') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($address, 'stu_padd_state') . '" ).html( data ); } );']); ?> </div> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($address, 'stu_padd_state')->dropDownList(ArrayHelper::map(\app\models\State::find()->where(['state_country_id' => $address->stu_padd_country, 'is_status' => 0])->all(), 'state_id', 'state_name'), ['prompt' => Yii::t('stu', '--- Select State ---'), 'onchange' => ' $.get( "' . Url::toRoute('dependent/ustud_p_city') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($address, 'stu_padd_city') . '" ).html( data ); } );']); ?> </div> </div> <div class="col-xs-12 col-sm-12 col-lg-12 no-padding"> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($address, 'stu_padd_city')->dropDownList(ArrayHelper::map(\app\models\City::find()->where(['city_state_id' => $address->stu_padd_state, 'is_status' => 0])->all(), 'city_id', 'city_name'), ['prompt' => Yii::t('stu', '--- Select City ---')]); ?> </div> <div class="col-xs-12 col-sm-6 col-lg-6">
<div class="form-group text-center"> <label class="control-label"><hr></label> s/d </div> </div> <div class="col-xs-5 col-sm-3 col-md-2"> <?php echo $form->field($model, 'quarterEnd')->dropDownList(['1' => 'I', '2' => 'II', '3' => 'III', '4' => 'IV']); ?> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-5"> <?php $data = ArrayHelper::map(State::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name'); echo $form->field($model, 'stateIds')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih Kecamatan ...'], 'pluginOptions' => ['allowClear' => true, 'multiple' => true]])->label('Kecamatan'); ?> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-5"> <?php $data = ArrayHelper::map(TypeTools::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name'); echo $form->field($model, 'typeToolsIds')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih Jenis Alat ...'], 'pluginOptions' => ['allowClear' => true, 'multiple' => true]])->label('Jenis Alat'); ?> </div> </div> <div class="form-group"> <?php
<div class="bs-callout bs-callout-label-4"><h5> Permanent Address </h5></div> <?php echo $form->field($model, 'emp_padd')->textArea(['maxlength' => 255]); ?> <?php echo $form->field($model, 'emp_padd_country')->dropDownList(ArrayHelper::map(\app\models\Country::find()->all(), 'country_id', 'country_name'), ['prompt' => '---Select Country---', 'onchange' => ' $.get( "' . Url::toRoute('dependent/emp_p_state') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($model, 'emp_padd_state') . '" ).html( data ); } );']); ?> <?php echo $form->field($model, 'emp_padd_state')->dropDownList(ArrayHelper::map(\app\models\State::find()->all(), 'state_id', 'state_name'), ['prompt' => '---Select State---', 'onchange' => ' $.get( "' . Url::toRoute('dependent/emp_p_city') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($model, 'emp_padd_city') . '" ).html( data ); } );']); ?> <?php echo $form->field($model, 'emp_padd_city')->dropDownList(ArrayHelper::map(\app\models\City::findAll(['city_state_id' => $model->emp_padd_state]), 'city_id', 'city_name'), ['prompt' => '---Select City---']); ?> <?php echo $form->field($model, 'emp_padd_pincode')->textInput(); ?>
public function actionUpdateRegion() { /** * check if the user is already logged in * if so, do nothing and return them to the home screen */ if (\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new UpdateRegionForm(); $stateList = State::find()->all(); $countyList = County::find()->orderBy('name')->all(); if ($model->load(Yii::$app->request->post())) { $subHead = 'You must select a region.'; if ($model->validate()) { $subHead = 'Region Successfully Changed'; $post = Yii::$app->db->createCommand()->delete('access', ['user_id' => Yii::$app->user->getId()])->execute(); foreach ($model->access as $county => $id) { if ($id != "multiselect-all") { $post = Yii::$app->db->createCommand()->insert('access', ['county_id' => $id, 'user_id' => Yii::$app->user->getId()])->execute(); } } } $access = Access::findAll(['user_id' => Yii::$app->user->getId()]); $access = ArrayHelper::getColumn($access, 'county_id'); return $this->render('update-region', ['access' => $access, 'model' => $model, 'stateList' => $stateList, 'countyList' => $countyList, 'subHead' => $subHead]); } $access = Access::findAll(['user_id' => Yii::$app->user->getId()]); $access = ArrayHelper::getColumn($access, 'county_id'); return $this->render('update-region', ['access' => $access, 'model' => $model, 'stateList' => $stateList, 'countyList' => $countyList, 'subHead' => '']); }
public function getSubCatList($con_id) { $states = \app\models\State::find()->where(['status' => 'Active', 'country_id' => $con_id])->all(); $out = []; $sarray = []; foreach ($states as $state) { $sarray['id'] = $state->id; $sarray['name'] = $state->name; $out[] = $sarray; } return $out; }
?> <?php echo $form->field($model, 'username')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'status')->widget(SwitchInput::classname(), ['pluginOptions' => ['onText' => 'Aktif', 'offText' => 'Banned']]); ?> <?php $data = \yii\helpers\ArrayHelper::map(\app\models\State::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name'); echo $form->field($model, 'state_id')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih State ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php if (!$model->isNewRecord) { ?> <strong> Biarkan kosong jika tidak ingin mengubah password</strong> <div class="ui divider"></div> <?php echo $form->field($model, 'new_password'); ?> <?php echo $form->field($model, 'repeat_password'); ?> <?php
public function actionMapDetail($id) { $model = State::find()->where(['id' => $id])->one(); $html = ' <h3>Informasi Detail</h3> <table class="table table-striped"> <tr> <td>ID</td> <td>' . $model->id . '</td> </tr> <tr> <td>Kecamatan</td> <td>' . $model->name . '</td> </tr> <tr> <td>Coordinates</td> <td>' . $model->coords . '</td> </tr> </table> '; return $html; }
<?php echo $form->field($model, 'city_country_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList(ArrayHelper::map(\app\models\Country::find()->all(), 'country_id', 'country_name'), ['prompt' => '---Select Country---', 'onchange' => ' $.get( "' . Url::toRoute('dependent/getstate') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($model, 'city_state_id') . '" ).html( data ); } );'])->label(false); ?> </div> <div class="col-sm-4"> <?php if (isset($model->city_state_id)) { ?> <?php echo $form->field($model, 'city_state_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList(ArrayHelper::map(\app\models\State::find()->all(), 'state_id', 'state_name'), ['prompt' => '---Select State---'])->label(false); ?> <?php } else { ?> <?php echo $form->field($model, 'city_state_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList(['prompt' => '---Select State---'])->label(false); ?> <?php } ?> </div> <div class="col-sm-4"> <?php echo $form->field($model, 'city_name', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'City/Town Name']])->textInput(['maxlength' => 35])->label(false); ?>
?> <?php echo $form->field($model, 'password')->passwordInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'lastupdate')->textInput(); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(Type::find()->where(["category" => "user"])->all(), 'id', 'type')); ?> <?php echo $form->field($model, 'state_id')->dropDownList(ArrayHelper::map(State::find()->where(["category" => "user"])->all(), 'id', 'state')); ?> <?php echo $form->field($model, 'sex')->radioList(['M' => 'Male', 'F' => 'Female']); ?> <?php echo $form->field($model, 'profile_id')->dropDownList(ArrayHelper::map(Profile::find()->where(["category" => "app"])->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'authKey')->textInput(['maxlength' => true]); ?> <?php
/** * actionRegister * * the Register action contains most of the logic behind user registration. * When it is called it checks to see if any data can be loaded into the * RegistrationForm model. If not then that means the user has not yet been * taken to the registration page, so it collects the data need to render * the registration page/form (all of the states and counties needed to fill * in the dropdowns, etc.) and renders view/site/registration. If however * data is able to be loaded into the RegistrationForm model, then that * means that the user has already submitted a filled out form, so it calls * model->validate() to make sure that all of the input is good and to make * sure that the entered username and email address have not already been * taken. If that does not return any errors then newUser(), a member * function of SiteController, is called and the RegistrationForm model is * passed in. After that, registration-confirm is rendered. */ public function actionRegister() { /** * check if the user is already logged in * if so, do nothing and return them to the home screen */ if (!\Yii::$app->user->isGuest) { return $this->goHome(); } /** * loads model that will store all data entered into the ActiveForm * on register.php and contains all front-end validation rules */ $model = new RegistrationForm(); /* Used to populate 'select state' dropdown and 'select region' section */ $stateList = State::find()->all(); /* Used to populate the 'select region' multiselects */ $countyList = County::find()->orderBy('name')->all(); /** * if the user has made a 'post' request AND registration form model * is able to succesfully register the user based on the inputted information */ if ($model->load(Yii::$app->request->post()) && $model->validate()) { /* Calls member function newUser() and passes in a populated model */ $this->newUser($model); /* registration was successful, go back to registration-confirm view */ return $this->render('registration-confirm', ['model' => $model]); } else { /** * The user has not yet been taken to the registration form so * render the registration view and pass in an empty RegistrationForm * model that is stored in $model */ return $this->render('register', ['model' => $model, 'stateList' => $stateList, 'countyList' => $countyList]); } }
/* @var $model app\models\Link */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="well"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => 32]); ?> <?php echo $form->field($model, 'state')->dropDownList(ArrayHelper::map(State::find()->all(), 'name', 'name')); ?> <div class="row"> <div class="col-md-6"> <?php echo $form->field($model, 'column')->dropDownList($model::getColumnsArray()); ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'order')->textInput(['maxlength' => 5, 'type' => 'number']); ?> </div> </div>