diff --git a/controllers/ApplicationController.php b/controllers/ApplicationController.php index 98022b5..3ffd62a 100644 --- a/controllers/ApplicationController.php +++ b/controllers/ApplicationController.php @@ -14,6 +14,7 @@ use app\models\PrefecturesPreference; use app\models\Choice; + /** * ApplicationController implements the CRUD actions for Application model. */ @@ -90,15 +91,28 @@ public function actionMyApplication() { $user = Applicant::findOne(['vat' => \Yii::$app->user->getIdentity()->vat, 'specialty' => \Yii::$app->user->getIdentity()->specialty]); $choices = $user->applications; - + //$prefectrs_prefrnc_model = PrefecturesPreference::find()->where(['applicant_id' => $user->id])->orderBy('order')->all(); + //$prefectrs_choices_model = Choice::classname(); + // if no application exists, forward to create if (count($choices) == 0) { Yii::$app->session->addFlash('info', "Δεν υπάρχει αποθηκευμένη αίτηση. Μπορείτε να υποβάλλετε νέα αίτηση."); return $this->redirect(['apply']); } + + $choicesArray = \yii\helpers\ArrayHelper::toArray($choices); + + for($i = 0; $i < count($choicesArray); $i++){ + $choiceActRec = Choice::findOne(['id' => $choicesArray[$i]['choice_id']]); + $prefectureId = $choiceActRec->prefecture_id; + $choicesArray[$i]['Position'] = $choiceActRec->position; + $choicesArray[$i]['PrefectureName'] = Prefecture::findOne(['id' => $prefectureId])->prefecture; + $choicesArray[$i]['RegionName'] = Prefecture::findOne(['id' => $prefectureId])->region; + } + //echo "
"; print_r($choicesArray); echo "
"; die(); $provider = new \yii\data\ArrayDataProvider([ - 'allModels' => $choices, + 'allModels' => $choicesArray, 'pagination' => [ 'pageSize' => 100, ], @@ -120,7 +134,6 @@ public function actionMyApplication() public function actionApply() { $user = Applicant::findOne(['vat' => \Yii::$app->user->getIdentity()->vat, 'specialty' =>\Yii::$app->user->getIdentity()->specialty]); - //$prefectrs_model = Prefecture::find()->all(); $prefectrs_choices_model = Choice::classname(); $prefectrs_prefrnc_model = PrefecturesPreference::find()->where(['applicant_id' => $user->id])->orderBy('order')->all(); diff --git a/views/application/_myapplication_item.php b/views/application/_myapplication_item.php index a50c424..ad41d48 100644 --- a/views/application/_myapplication_item.php +++ b/views/application/_myapplication_item.php @@ -1,4 +1,6 @@ - order ?> - choice->position ?> - \ No newline at end of file + + + + + diff --git a/views/application/view.php b/views/application/view.php index 2c520bb..355baeb 100644 --- a/views/application/view.php +++ b/views/application/view.php @@ -29,11 +29,13 @@

identity ?> Ταυτότητα

- + "; var_dump($dataProvider); echo ""; ?> + +
Σειρά προτίμησης Κενό προτίμησηςΝομόςΠεριφέρεια