From d21f6ba14c8e15a5d0d44f82bea35c9e89eabbb9 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Wed, 31 May 2023 03:39:24 +0300 Subject: manage petitions; in progress --- public/app/controllers/Office.php | 32 +++++++--- public/app/models/Content_model.php | 17 ++++- public/app/routes/user.php | 19 ++++-- public/app/views/components/own_petitions.php | 89 +++++++++++++++++++++++++++ public/app/views/user/panel.php | 67 ++++++++++++++++++-- 5 files changed, 202 insertions(+), 22 deletions(-) create mode 100644 public/app/views/components/own_petitions.php (limited to 'public/app') diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index a876f6c..83135de 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -112,7 +112,6 @@ class Office { - ## ------------------------------------------------------------------------- ## PETITION FORMS ## secretarial support / serve forms for teachers' requests and applications ## ------------------------------------------------------------------------- @@ -265,11 +264,8 @@ class Office { - ## ------------------------------------------------------------------------- - ## - ## PETITION SUBMITS + ## PETITION SUBMIT ## handle submits of forms - ## ## ------------------------------------------------------------------------- @@ -309,11 +305,30 @@ class Office { + + ## LIST PETITIONS ## ------------------------------------------------------------------------- - ## + + + public static function user_petitions() + { + $manager = new App_manager(); // use APP Manager + // to get the requester's user_id + + $list = Content_model::user_petitions( + $manager->getUserToken()->getUser()->getID() // user-id + ); + + Render::json([ + 'success' => true, + 'data' => $list + ]); + } + + + ## TICKET METHODS (create, remove) ## tickets eliminate CSRF attacks - ## ## ------------------------------------------------------------------------- /** create_ticket @@ -369,10 +384,7 @@ class Office { - ## ------------------------------------------------------------------------- - ## ## ADMIN METHODS (insert, updated etc.) - ## ## ------------------------------------------------------------------------- diff --git a/public/app/models/Content_model.php b/public/app/models/Content_model.php index ea19165..2a79159 100644 --- a/public/app/models/Content_model.php +++ b/public/app/models/Content_model.php @@ -53,17 +53,30 @@ class Content_model { /** user petitions * - * get all petitions of a user + * get all petitions of a user; * * @param int $uid: user id * @return array petition records */ public static function user_petitions($uid) { - return Registry::use('database')->runQuery( + $list = Registry::use('database')->runQuery( "SELECT * FROM petition WHERE user_id = :uid", [ ':uid' => $uid ] ); + + $results = []; // re-format results + foreach($list as $key => $rec) { + $results[] = [ + 'id' => $rec['id'], + 'type_id' => $rec['type_id'], + 'subject' => $rec['subject'], + 'signature' => $rec['signature'], + 'protocol' => $rec['protocol'] ?? '', + 'form_structure' => unserialize($rec['form_structure']) + ]; + } + return $results; } diff --git a/public/app/routes/user.php b/public/app/routes/user.php index 12ca7d2..4a09801 100644 --- a/public/app/routes/user.php +++ b/public/app/routes/user.php @@ -88,19 +88,30 @@ if (Auth::is_connected()) { ]); }); - // file of petitions + // request PAGE list-my-petitions // --- -- -- - - - Route::add('/user/petitions', function() { - Render::view('admin/invite'); + Render::view('user/panel',[ + 'is_admin' => Auth::in_admin_group(), + 'content' => 'own_petitions', + 'user' => json_decode(json_encode( + Auth::user_data(), JSON_UNESCAPED_UNICODE + )) + ]); + }); + + // requst RESULTS list my petitions + Route::add('/user/get/petitions', function() { + Office::user_petitions(); }); - // request New petition form + // request NEW petition FORM // --- -- -- - - - Route::add('/petition/([0-9a-z\-_]*)', function($tag) { Office::request_petition($tag); }); - // request existing petition + // request EXISTING PETITION // --- -- -- - - - Route::add('/petition/signature/([0-9a-f]*)', function($signature) { Office::filter_request_petition($signature); diff --git a/public/app/views/components/own_petitions.php b/public/app/views/components/own_petitions.php new file mode 100644 index 0000000..8ea0f23 --- /dev/null +++ b/public/app/views/components/own_petitions.php @@ -0,0 +1,89 @@ + +
+
Διαχείριση Αιτήσεων και Δοικητικών Εγγράφων
+
+ + +   Νέο Μάθημα + +
+
+ +
+
+
+ +
+ + + + + + + + + + +
ΤίτλοςΑρ.ΠρωτόκολλουSignatureΗμερ. Καταχώρισης
+ +
+ +
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/public/app/views/user/panel.php b/public/app/views/user/panel.php index 01a3777..80f4071 100644 --- a/public/app/views/user/panel.php +++ b/public/app/views/user/panel.php @@ -55,13 +55,68 @@ - - + + + + + + + + - if admin: - * modal + give protocol-number ---> -- cgit v1.2.3