summaryrefslogtreecommitdiff
path: root/public/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/controllers')
-rw-r--r--public/app/controllers/Auth.php15
-rw-r--r--public/app/controllers/JsonToForm.php4
-rw-r--r--public/app/controllers/Office.php24
3 files changed, 26 insertions, 17 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php
index e191c53..d52b6c9 100644
--- a/public/app/controllers/Auth.php
+++ b/public/app/controllers/Auth.php
@@ -163,18 +163,9 @@ class Auth {
// prepare gendered options to position field
$positions = ($user->prefix != 'η')
- ? [
- 'Διευθυντής',
- 'Υποδιευθυντής',
- 'Μόνιμος Καθηγητής',
- 'Αναπληρωτής Καθηγητής'
- ]
- : [
- 'Διευθύντρια',
- 'Υποδιευθύντρια',
- 'Μόνιμη Καθηγήτρια',
- 'Αναπληρώτρια Καθηγήτρια'
- ];
+ ? GENDERED_POSITIONS['he']
+ : GENDERED_POSITIONS['she'];
+
$gendered_position = json_decode( json_encode( $positions, JSON_UNESCAPED_UNICODE ));
// attach gendered options
diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php
index 1e0b99b..5e16472 100644
--- a/public/app/controllers/JsonToForm.php
+++ b/public/app/controllers/JsonToForm.php
@@ -119,12 +119,12 @@ class JsonToForm
* construct a form (html, javasctipt)
* from a json designer
*
- * @param stdClass $formJson : form descriptor
+ * @param stdClass $formJson : form descriptor
*
* @param array $require_identity : array of properties and values;
* they identify the record; injected into form as hidden fields
*
- * @return array [ html=>(string), init_js=>(string), values_js=>String ]
+ * @return array [ html=>(string), init_js=>(string), values_js=>String ]
* -------------------------------------------------------------------------
*/
public static function json_form($formJson, $require_identity = [])
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php
index 9eb2a4c..5038200 100644
--- a/public/app/controllers/Office.php
+++ b/public/app/controllers/Office.php
@@ -160,6 +160,9 @@ class Office {
}
+ /** render application form
+ *
+ */
private static function render_application_form($opts)
{
// #1: user-id ---------------------------------------------------------
@@ -170,15 +173,30 @@ class Office {
// #3: inject default values -------------------------------------------
+ $userData = Auth::user_data();
+
// #3.1: inject user data
$form_setup->defaults = json_decode( json_encode(
- Auth::user_data(), JSON_UNESCAPED_UNICODE
+ $userData, JSON_UNESCAPED_UNICODE
));
+
// #3.2 inject `sector` and `position` <option>s
+ for($i=0; $i < sizeof($form_setup->form) ; $i++) { // get key-IDs
+ if (isset($form_setup->form[$i]->name)) {
+ if ($form_setup->form[$i]->name == 'sector') { $keySector = $i; }
+ if ($form_setup->form[$i]->name == 'position') { $keyPosition = $i; }
+ }
+ }
+ $form_setup->form[$keySector]->options = TEACHER_SECTORS;
+ $form_setup->form[$keyPosition]->options = ($userData['prefix'] == 'η')
+ ? GENDERED_POSITIONS['she']
+ : GENDERED_POSITIONS['he'];
+
+
// #4: get Form's HTML and Javascript ----------------------------------
$form = JsonToForm::json_form($form_setup, [
- ['name' => 'user_id', 'value' => $user_id] // pass user identity
+ ['name' => 'user_id', 'value' => $user_id] // pass user identity
]);
// #5: render the view -------------------------------------------------
@@ -209,7 +227,7 @@ class Office {
$teachers[] = $person['TeacherName'];
}
- // #3.2: get $key of rapporteur, president and members <select>s
+ // #3.2: get $key of `rapporteur`, `president` and `members` <select>s
for($i=0; $i < sizeof($form_setup->form) ; $i++) {
if (isset($form_setup->form[$i]->name)) {
if ($form_setup->form[$i]->name == 'rapporteur') { $keyRapporteur = $i; }