summaryrefslogtreecommitdiff
path: root/public/app/controllers
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-08 01:09:54 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-08 01:09:54 +0300
commit7e22b5bc5328652ae7e91ad799b48820474660ed (patch)
tree514edc25661f5ebc3516854d888ab34af95cf648 /public/app/controllers
parent57cc5b73b5e37ebaf4db2bff32f6203afceba0c8 (diff)
downloadgyraf1gov-7e22b5bc5328652ae7e91ad799b48820474660ed.tar.gz
gyraf1gov-7e22b5bc5328652ae7e91ad799b48820474660ed.tar.bz2
gyraf1gov-7e22b5bc5328652ae7e91ad799b48820474660ed.zip
the common-form (init)
Diffstat (limited to 'public/app/controllers')
-rw-r--r--public/app/controllers/Office.php60
1 files changed, 56 insertions, 4 deletions
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php
index 6a55efe..5e8af75 100644
--- a/public/app/controllers/Office.php
+++ b/public/app/controllers/Office.php
@@ -120,10 +120,8 @@ class Office {
/** (any) petition
*
- * Route method to specific petition;
- *
- * also...
- * checks if user is authorized to view the content;
+ * check if user is authorized to view the content;
+ * if so, prepare and render the petition view
*
* @param $petition_type (string): [common|penalty]
*/
@@ -162,6 +160,60 @@ class Office {
}
+ private static function render_common_petition($opts)
+ {
+ $user_id = $opts['user']->getID();
+
+ $form_setup = json_decode(json_encode(COMMON_REQUEST_FORM, JSON_UNESCAPED_UNICODE));
+
+ // get Form's HTML and Jsvascript
+ $form = JsonToForm::json_form($form_setup, [
+ ['name' => 'user_id', 'value' => $user_id] // pass user identity
+ ]);
+
+ Render::view('templates/common-form', ['form' => $form]);
+ }
+
+ private static function render_penalty_form($opts)
+ {
+ $user_id = $opts['user']->getID();
+
+ $form_setup = json_decode(json_encode(PENALTY_FORM, JSON_UNESCAPED_UNICODE));
+
+ // get all teachers
+ $teachers_array = Registry::use('database')->runQuery(
+ "SELECT concat(last_name, ' ', first_name) as TeacherName
+ FROM user ORDER BY TeacherName", []
+ );
+ $teachers = []; // constuct teacher names as a simple array
+ foreach($teachers_array as $key => $person) {
+ $teachers[] = $person['TeacherName'];
+ }
+ // print_r( $teachers); die();
+
+ // get $key of rapporteur, president and members inside the form_setup->form array
+ 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; }
+ if ($form_setup->form[$i]->name == 'president') { $keyPresident = $i; }
+ if ($form_setup->form[$i]->name == 'members') { $keyMembers = $i; }
+ }
+ }
+
+ // set option sources for rapporteur, president and members
+ $form_setup->form[$keyRapporteur]->options = $teachers;
+ $form_setup->form[$keyPresident]->options = $teachers;
+ $form_setup->form[$keyMembers]->options = $teachers;
+
+ // get Form's HTML and Jsvascript
+ $form = JsonToForm::json_form($form_setup, [
+ ['name' => 'user_id', 'value' => $user_id] // pass user identity
+ ]);
+
+ Render::view('templates/penalty', ['form' => $form]);
+
+ }
+
## -------------------------------------------------------------------------