Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application edit #30

Merged
merged 2 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function actionMyApplication()
]);
}


/**
* Creates a new Application model.
* If creation is successful, the browser will be redirected to the 'view' page.
Expand All @@ -137,27 +138,35 @@ public function actionApply()
return $this->redirect(['site/index']);
}

$prefectrs_choices_model = Choice::classname();

// one application per user only; forward to delete confirmation page
if ($user->applications) {
Yii::$app->session->addFlash('warning', "Μόνο μία αίτηση μπορεί να καταχωρηθεί. Φαίνεται πως έχετε ήδη καταχωρήσει αίτηση. <strong>Εάν θέλετε να καταχωρήσετε νέα, πρέπει πρώτα να διαγράψετε την ήδη καταχωρημένη αίτηση.</strong>");
return $this->redirect(['delete-my-application']);
}

$prefectrs_choices_model = Choice::classname();
$models = [];
$prefectures_choices = [];

$counter = 1;
foreach ($prefectrs_prefrnc_model as $preference) {
$choices = Choice::getChoices($preference->prefect_id, $user->specialty);
$prefectures_choices[$preference->getPrefectureName()] = $preference->prefect_id;
foreach ($choices as $choice) {
$models[$preference->getPrefectureName()][$counter] = new Application();
$helper = $models[$preference->getPrefectureName()][$counter];
$helper->applicant_id = $user->id;
$helper->deleted = 0;
$counter++;
$counter = 1;

if($user->applications){
foreach ($prefectrs_prefrnc_model as $preference) {
$userChoices = $user->getApplications()->all();
$prefectures_choices[$preference->getPrefectureName()] = $preference->prefect_id;
foreach ($userChoices as $userChoice) {
$choice = Choice::findOne($userChoice->choice_id);
if($choice->prefecture_id === $preference->prefect_id){
$models[$preference->getPrefectureName()][$counter] = $userChoice;
$counter++;
}
}
}
}
else{
foreach ($prefectrs_prefrnc_model as $preference) {
$choices = Choice::getChoices($preference->prefect_id, $user->specialty);
$prefectures_choices[$preference->getPrefectureName()] = $preference->prefect_id;
foreach ($choices as $choice) {
$models[$preference->getPrefectureName()][$counter] = new Application();
$helper = $models[$preference->getPrefectureName()][$counter];
$helper->applicant_id = $user->id;
$helper->deleted = 0;
$counter++;
}
}
}

Expand Down
22 changes: 11 additions & 11 deletions views/application/view.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

use yii\helpers\Html;
use yii\widgets\ListView;

Expand All @@ -17,16 +16,17 @@
<?php endif; ?>

<h1><?= Html::encode($this->title) ?></h1>

<div class="row item">
<div class="col-sm-4">
<h2><?= $user->specialty ?> <small>Ειδικότητα</small></h2>
</div>
<div class="col-sm-4">
<h2><?= $user->vat ?> <small>Α.Φ.Μ.</small></h2>
</div>
<div class="col-sm-4">
<h2><?= $user->identity ?> <small>Ταυτότητα</small></h2>
<div class="well well-sm">
<div class="row item">
<div class="col-sm-4">
<h2><?= $user->specialty ?> <small>(Ειδικότητα)</small></h2>
</div>
<div class="col-sm-4">
<h2><?= $user->vat ?> <small>(Α.Φ.Μ.)</small></h2>
</div>
<div class="col-sm-4">
<h2><?= $user->identity ?> <small>(Ταυτότητα)</small></h2>
</div>
</div>
</div>
<?php //echo "<pre>"; var_dump($dataProvider); echo "</pre>"; ?>
Expand Down
5 changes: 4 additions & 1 deletion views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

<div class="wrap">
<?php
$specialty = '';
if(!Yii::$app->user->isGuest && !Yii::$app->user->identity->isAdmin())
$specialty = ' - ' . Yii::$app->user->identity->specialty;
NavBar::begin([
'brandLabel' => Yii::$app->params['companyName'],
'brandUrl' => Yii::$app->homeUrl,
Expand All @@ -45,7 +48,7 @@
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Αποσύνδεση (' . Yii::$app->user->identity->vat . ' - ' . Yii::$app->user->identity->specialty . ')', ['class' => 'btn btn-link logout']
'Αποσύνδεση (' . Yii::$app->user->identity->vat . $specialty . ')', ['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
Expand Down
35 changes: 25 additions & 10 deletions views/site/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use yii\bootstrap\Html;
use yii\helpers\Url;
use app\models\Applicant;

/* @var $this yii\web\View */

Expand All @@ -17,16 +18,30 @@

<div class="row">
<?php if (Yii::$app->user->isGuest || (!Yii::$app->user->isGuest && !Yii::$app->user->identity->isAdmin())) : ?>
<div class="col-lg-4">
<h2>Καταχώρηση</h2>
<p>Υποβάλλετε την αίτησή σας εδώ.</p>
<?php if ($enable_applications === true) : ?>
<p><?= Html::a('Υποβολή', Url::to(['application/apply']), ['class' => 'btn btn-success']) ?></p>
<?php else: ?>
<p><?= Html::a('Υποβολή', '#', ['class' => 'btn btn-success disabled', 'disabled' => 'disabled']) ?></p>
<p class="text-danger">Η υποβολή αιτήσεων δεν είναι διαθέσιμη.</p>
<?php endif; ?>
</div>
<?php $user = Applicant::findOne(['vat' => \Yii::$app->user->getIdentity()->vat, 'specialty' => \Yii::$app->user->getIdentity()->specialty]);
if($user->applications): ?>
<div class="col-lg-4">
<h2>Επεξεργασία</h2>
<p>Επεξεργαστείτε την αίτηση που έχετε υποβάλλει</p>
<?php if ($enable_applications === true) : ?>
<p><?= Html::a('Επεξεργασία', Url::to(['application/apply']), ['class' => 'btn btn-success']) ?></p>
<?php else: ?>
<p><?= Html::a('Επεξεργασία', '#', ['class' => 'btn btn-success disabled', 'disabled' => 'disabled']) ?></p>
<p class="text-danger">Η υποβολή αιτήσεων δεν είναι διαθέσιμη.</p>
<?php endif; ?>
</div>
<?php else: ?>
<div class="col-lg-4">
<h2>Καταχώρηση</h2>
<p>Υποβάλλετε την αίτησή σας εδώ.</p>
<?php if ($enable_applications === true) : ?>
<p><?= Html::a('Υποβολή', Url::to(['application/apply']), ['class' => 'btn btn-success']) ?></p>
<?php else: ?>
<p><?= Html::a('Υποβολή', '#', ['class' => 'btn btn-success disabled', 'disabled' => 'disabled']) ?></p>
<p class="text-danger">Η υποβολή αιτήσεων δεν είναι διαθέσιμη.</p>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="col-lg-4">
<h2>Προβολή</h2>
<p>Προβάλλετε την αίτηση σας εδώ.</p>
Expand Down