Skip to content

Commit

Permalink
Update view
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaniot committed Oct 13, 2017
1 parent 23ff0f1 commit b9754d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
19 changes: 16 additions & 3 deletions controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use app\models\PrefecturesPreference;
use app\models\Choice;


/**
* ApplicationController implements the CRUD actions for Application model.
*/
Expand Down Expand Up @@ -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 "<pre>"; print_r($choicesArray); echo "</pre>"; die();

$provider = new \yii\data\ArrayDataProvider([
'allModels' => $choices,
'allModels' => $choicesArray,
'pagination' => [
'pageSize' => 100,
],
Expand All @@ -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();

Expand Down
8 changes: 5 additions & 3 deletions views/application/_myapplication_item.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<tr>
<td class="col-xs-2"><?= $model->order ?></td>
<td><strong><?= $model->choice->position ?></strong></td>
</div>
<td class="col-xs-2"><?= $model['order'] ?></td>
<td class="col-xs-2"><?= $model['Position'] ?></td>
<td class="col-xs-2"><?= $model['PrefectureName'] ?></td>
<td class="col-xs-2"><?= $model['RegionName'] ?></td>
</div>
4 changes: 3 additions & 1 deletion views/application/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
<h2><?= $user->identity ?> <small>Ταυτότητα</small></h2>
</div>
</div>

<?php //echo "<pre>"; var_dump($dataProvider); echo "</pre>"; ?>
<table class="table table-bordered table-hover table-striped">
<thead>
<th>Σειρά προτίμησης</th>
<th>Κενό προτίμησης</th>
<th>Νομός</th>
<th>Περιφέρεια</th>
</thead>
<tbody>
<?=
Expand Down

0 comments on commit b9754d2

Please sign in to comment.