/**
  * 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);
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TypeTools::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, 'name' => $this->name, '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', 'params', $this->params])->andFilterWhere(['like', 'units', $this->units]);
     return $dataProvider;
 }
예제 #3
0
?>
        </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 
echo Html::submitButton('Tampilkan', ['class' => 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
예제 #4
0
파일: Tools.php 프로젝트: hscstudio/psiaga
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTypeTools()
 {
     return $this->hasOne(TypeTools::className(), ['type_tools_id' => 'id']);
 }
예제 #5
0
파일: index.php 프로젝트: hscstudio/psiaga
?>
</h3>
     </div>
     <div class="panel-body">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('<span class=\'glyphicon glyphicon-plus-sign\'></span>  ' . Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'type_tools_id', 'format' => 'raw', 'value' => function ($data) {
    if ($data->type_tools_id > 0) {
        return \app\models\TypeTools::findOne($data->type_tools_id)->name;
    } else {
        return "-";
    }
}], 'name', 'sort', ['attribute' => 'updated_at', 'headerOptions' => ['style' => 'width:125px;', 'class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'filter' => false, 'format' => ['date', 'php:d/m/y H:i']], ['attribute' => 'updated_by', 'headerOptions' => ['style' => 'width:100px;', 'class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'filter' => false, 'value' => function ($data) {
    return @\app\models\User::findOne($data->updated_by)->username;
}], ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Actions', 'headerOptions' => ['style' => 'width:100px;', 'class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']]]]);
?>

    </div>
  </div>
</div>
예제 #6
0
 /**
  * Updates an existing HarvestTools 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);
     $typeTools = null;
     if ($model->tools_id > 0) {
         $tools = Tools::findOne($model->tools_id);
         $typeTools = TypeTools::findOne($tools->type_tools_id);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'typeTools' => $typeTools]);
     }
 }
예제 #7
0
 /**
  * Finds the TypeTools model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TypeTools the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TypeTools::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }