From aa60f8920261fdfe04232955cb1e4db1b170e816 Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Fri, 5 May 2023 17:47:23 +0300 Subject: minor changes; final alpha-version is almost ready --- public/app/controllers/Office.php | 51 +++--------------------------- public/app/controllers/Petition.php | 63 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 public/app/controllers/Petition.php (limited to 'public/app/controllers') diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index 44428af..6a55efe 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -120,8 +120,10 @@ class Office { /** (any) petition * - * check if user is authorized to view the content; - * if so, prepare and render the petition view + * Route method to specific petition; + * + * also... + * checks if user is authorized to view the content; * * @param $petition_type (string): [common|penalty] */ @@ -160,51 +162,6 @@ class Office { } - private static function render_common_petition($opts) - { - - } - - 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]); - - } - ## ------------------------------------------------------------------------- diff --git a/public/app/controllers/Petition.php b/public/app/controllers/Petition.php new file mode 100644 index 0000000..fa73cf0 --- /dev/null +++ b/public/app/controllers/Petition.php @@ -0,0 +1,63 @@ +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]); + + } + + + + +} -- cgit v1.2.3