From 2b4ed611e7e001ad8ea93ef3e8cdce35bc56dc07 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Mon, 1 May 2023 04:33:06 +0300 Subject: form designer; setup main forms of the application --- public/app/config/app_constants.php | 355 ++++++++++++++++++++++++++++--- public/app/controllers/JsonToForm.php | 92 ++++---- public/app/extends/App_manager.php | 106 +++++++++ public/app/extends/App_user.php | 121 +++++++++++ public/app/extends/Classroom_manager.php | 106 --------- public/app/extends/Classroom_user.php | 121 ----------- public/app/models/Access_model.php | 28 +-- public/app/models/_info.md | 15 ++ public/app/routes/backend.php | 52 ----- public/app/routes/frontend.php | 4 +- public/app/routes/user.php | 15 +- public/app/views/templates/penalty.php | 127 +++++++++++ public/app/views/user/registration.php | 67 +++--- public/app/views/welcome.php | 211 ++---------------- public/assets/css/overides.css | 13 +- tests/code/eval.php | 111 ++++++++++ 16 files changed, 924 insertions(+), 620 deletions(-) create mode 100644 public/app/extends/App_manager.php create mode 100644 public/app/extends/App_user.php delete mode 100644 public/app/extends/Classroom_manager.php delete mode 100644 public/app/extends/Classroom_user.php create mode 100644 public/app/views/templates/penalty.php create mode 100755 tests/code/eval.php diff --git a/public/app/config/app_constants.php b/public/app/config/app_constants.php index b46bc51..fedba90 100644 --- a/public/app/config/app_constants.php +++ b/public/app/config/app_constants.php @@ -61,9 +61,9 @@ define('DEFAULT_PRIVILEGES', [ // User Roles // --- -- -- - - - -define('READER', 1); -define('EDITOR', 2); -define('ADMIN', 3); +define('Admin', 1); +define('Secretary', 2); +define('Teacher', 3); // ACCESS HISTORY ////////////////////////////////////////////////////////////// @@ -72,14 +72,14 @@ define('ADMIN', 3); define('TRACK_LOGIN', 1); // login / logout define('TRACK_ACCOUNT', 2); // create user / activate account / modidy profile -define('TRACK_PAYMENTS', 3); // order / payment / refund etc... +define('TRACK_REQUESTS', 4); // order / payment / refund etc... // access type strings // --- define('USER_ACCESS_TYPE', [ 1 => 'Login', 2 => 'Account', - 3 => 'Payment' + 3 => 'Request' ]); @@ -99,16 +99,7 @@ define('EMPTY_REQUIRED_FIELDS', 'Δεν έχουν συμπληρωθεί όλα // JAVASCRIPT LIBRARY PATHS // ----------------------------------------------------------------------------- define('JS_DIR', '/content/'); // path to contruct link -define('JS_LIBRARIES', array( // path after to the actual file - 'jquery' => 'lib/jquery/dist/jquery.min.js', - 'require/files' => 'lib/require/require.files.js', - 'require/slim' => 'lib/require/require.slim.js', - - 'plugins' => 'lib/plugins/plugins.min.js', - 'plugins/setup' => 'lib/plugins/plugins.setup.js' - ) -); // CSS ASSET PATHS @@ -122,19 +113,6 @@ define('CSS_FILES', array( // path after to the actual file ); -// FONTS -// ----------------------------------------------------------------------------- -define('FONTS_DIR', '/content/fonts/'); -define('FONT_FILES', array( - 'iconfont' => 'iconfont.woff2', - 'CFAstyStdBold' => 'CFAstyStd-Bold.woff2', - 'CFAstyStdBook' => 'CFAstyStd-Book.woff2', - 'CFAstyStdMedium' => 'CFAstyStd-Medium.woff2' - ) -); - - - // Mesagges //////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- @@ -163,9 +141,322 @@ define ('REGISTRATION_USER_EXISTS', "

Αποτυχία Εγγραφής

// activation // --- define('ACCOUNT_ACTIVATED_TITLE', 'Ο λογαριασμός σας έχει ενεργοποιηθεί'); -define('ACCOUNT_ACTIVATED_MESSAGE', 'Τώρα μπορείτε να κάνετε - Είσοδο στο σύστημα - για να δείτε περισσότερο περιεχόμενο'); +define('ACCOUNT_ACTIVATED_MESSAGE', 'Τώρα μπορείτε να + συνδεθείτε στο σύστημα.'); define('NOT_VALID_ACTIVATION_TITLE', 'Σφάλμα!'); -define('NOT_VALID_ACTIVATION_MESSAGE', 'Ο κωδικός ενεργοποίησης δεν είναι σωστός. - Μήπως τον έχετε ενεργοποιήσει στο παρελθόν;'); \ No newline at end of file + + + +define('REGISTRATION_FORM', [ + 'defaults' => [ + 'outer_class' => 'col-12', + 'inner_class' => 'form-control', + 'type' => 'text' + ], + 'form' => [ + [ + 'name' => 'first_name', + 'label' => 'Όνομα', + 'attributes' => ['required'] + ], + [ + 'name' => 'last_name', + 'label' => 'Επίθετο', + 'attributes' => ['required'] + ], + [ + 'name' => 'email', + 'label' => 'e-mail', + 'type' => 'email', + 'attributes' => ['required'] + ], + [ + 'name' => 'father_name', + 'label' => 'Πατρώνυμο', + 'attributes' => ['required'] + ], + [ + 'name' => 'registration_number', + 'label' => 'Αριθμός μητρώου', + 'class' => 'col-8', + 'attributes' => ['required'] + ], + [ + 'name' => 'sector', + 'label' => 'Κλάδος / Ειδικότητα', + 'type' => 'select', + // 'source' => 'sectors', + 'attributes' => ['required'], + 'options' => [ + 'Π01.00 Θεολόγοι', + 'Π02.00 Φιλόλογοι', + 'Π04.01 Φυσικοί', + 'Π04.02 Χημικοί' + ] + ], + [ + 'name' => 'belonging_school', + 'label' => 'Σχολείο τοποθέτησης', + 'attributes' => ['required'] + ], + [ + 'name' => 'working_school', + 'label' => 'Σχολείο εργασίας', + 'attributes' => ['required'] + ], + [ + 'name' => 'position', + 'label' => 'Θέση', + 'type' => 'select', + 'attributes' => ['required'], + 'options' => [ + 'Διευθυν-τής/τρια', + 'Υποδιευθυν-τής/τρια', + 'Μόνιμ-ος/η Καθηγη-τής/τρια', + 'Αναπληρω-τής/τρια', + ] + ], + [ + 'name' => 'phone', + 'label' => 'Τηλέφωνο', + 'class' => 'col-8', + 'attributes' => ['required'] + ], + [ + 'name' => 'password', + 'label' => 'Κωδικός πρόσβασης', + 'type' => 'password', + 'class' => 'col-8', + 'attributes' => ['required'] + ], + [ + 'name' => 'confirm_password', + 'label' => 'Επαλήθευση κωδικού πρόσβασης', + 'type' => 'password', + 'class' => 'col-8', + 'attributes' => ['required'] + ] + ] +]); + + +define('COMMON_REQUEST_FORM', [ + 'defaults' => [ + 'outer_class' => 'col-12', + 'inner_class' => 'form-control', + 'type' => 'text', + 'source' => 'user' + ], + 'form' => [ + [ + 'name' => 'first_name', + 'label' => 'Όνομα', + 'attributes' => ['auto'] + ], + [ + 'name' => 'last_name', + 'label' => 'Επίθετο', + 'attributes' => ['auto'] + ], + [ + 'name' => 'email', + 'label' => 'e-mail', + 'type' => 'email', + 'attributes' => ['auto'] + ], + [ + 'name' => 'father_name', + 'label' => 'Πατρώνυμο', + 'attributes' => ['auto'] + ], + [ + 'name' => 'registration_number', + 'label' => 'Αριθμός μητρώου', + 'class' => 'col-5', + 'attributes' => ['auto'] + ], + [ + 'name' => 'sector', + 'label' => 'Κλάδος / Ειδικότητα', + 'attributes' => ['auto'] + ], + [ + 'name' => 'belonging_school', + 'label' => 'Σχολείο τοποθέτησης', + 'attributes' => ['required'] + ], + [ + 'name' => 'working_school', + 'label' => 'Σχολείο εργασίας', + 'attributes' => ['required'] + ], + [ + 'name' => 'position', + 'label' => 'Θέση', + 'type' => 'select', + 'source' => 'positions', + 'attributes' => ['required'] + ], + [ + 'name' => 'phone', + 'label' => 'Τηλέφωνο', + 'attributes' => ['required'] + ], + [ + 'name' => 'request', + 'label' => 'Αίτημα (πχ, Παρακαλώ να μου χορηγήσετε ...)', + 'type' => 'textarea', + 'attributes' => ['required'] + ], + [ + 'name' => 'date', + 'label' => 'Ημερομηνία αίτησης', + 'type' => 'date', + 'attributes' => ['required'] + ] + ] +]); + + +define('PENALTY_FORM', [ + 'defaults' => [ + 'outer_class' => 'col-12', + 'inner_class' => 'form-control', + 'type' => 'text', + 'source' => 'user' + ], + 'form' => [ + [ + 'label' => 'Πειθαρχική υπόθεση', + 'type' => 'label' + ], + [ + 'name' => 'of_student', + 'label' => 'τ.. μαθητ...', + 'attributes' => ['required'] + ], + [ + 'name' => 'of_department', + 'label' => 'του τμήματος...', + 'attributes' => ['required'] + ], + [ + 'name' => 'date', + 'label' => 'Ημερομηνία', + 'type' => 'date', + 'class' => 'col-5', + 'attributes' => ['required'] + ], + [ + 'name' => 'time', + 'label' => 'Ώρα', + 'class' => 'col-4', + 'attributes' => ['required'] + ], + [ + 'name' => 'place', + 'label' => 'Τόπος', + 'attributes' => ['required'] + ], + [ + 'name' => 'rapporteur', + 'label' => 'εισηγητής', + 'attributes' => ['required'] + ], + [ + 'name' => 'charge', + 'label' => 'κατηγορία', + 'attributes' => ['required'] + ], + [ + 'name' => 'apology', + 'label' => 'Απολογία', // + of_student + 'type' => 'textarea', + 'attributes' => [] + ], + [ + 'name' => 'decision_reasoning', + 'label' => 'Αιτιολογία απόφασης (πχ. Επειδή...)', + 'type' => 'textarea', + 'attributes' => ['required'] + ], + [ + 'label' => 'Το Πειθαρχικό Συμβούλιο' + ], + [ + 'name' => 'decision', + 'label' => 'Αποφασίζει', + 'type' => 'select', + 'options' => [ + 'προφορική επίπληψη', + 'ωριαία αποβολή', + 'ημερήσια αποβολή' + ], + 'attributes' => [] + ], + [ + 'name' => 'decision_more', + 'label' => '(μη τυποποιημένo κείμενο απόφασης)', + 'attributes' => [] + ], + [ + 'name' => 'president', + 'label' => 'Ημερομηνία αίτησης', + 'type' => 'text', + 'attributes' => ['required'] + ], + [ + 'name' => 'members', + 'label' => 'Μέλη', + 'type' => 'select', + 'attributes' => ['required', 'multiple'], + 'source' => 'teachers', + 'options' => [ + 'Μαρία Χαλκιαδάκη', + 'Σπαγκοβαγγελοδημήτρης Νικόλαος', + 'Χατζηχριστοδούλου Παναγιώτης', + 'Μαρία Χαλκιά', + 'Σπανοβαγγελοδημήτρης Νικόλαος', + 'Χριστοδούλου Παναγιώτης', + 'Μαρίκα Χαλκιαδάκη', + 'Σπανακοβαγγελοδημήτρης Νικόλαος', + 'Χατζηχριστοδούλου Χριστόδουλος', + 'Αννέτα Καββαδία', + 'Γιώργος Καΐσας', + 'Διονύσης - Χαράλαμπος Καλαματιανός', + 'Ηλίας Καματερός', + 'Μαρία Κανελλοπούλου', + 'Ιωάννης Καραγιάννης', + 'Χρήστος Καραγιαννίδης', + 'Ευαγγελία Καρακώστα', + 'Απόστολος Καραναστάσης', + 'Ευφροσύνη Καρασαρλίδου', + 'Νίνα Κασιμάτη', + 'Αστέριος Καστόρης', + 'Βασιλική Κατριβάνου', + 'Γιώργος Κατρούγκαλος', + 'Χρυσούλα Κατσαβριά-Σιωροπούλου', + 'Μάριος Κάτσης', + 'Χαρά Καφαντάρη', + 'Σίμος Α. Κεδίκογλου', + 'Παναγιώτα Κοζομπόλη-Αμανατίδη', + 'Βασίλης Κόκκαλης', + 'Σταύρος Κοντονής', + 'Περικλής Κοροβέσης', + 'Νίκος Κοτζιάς', + 'Φώτης Κουβέλης', + 'Τάσος Κουράκης', + 'Παναγιώτης Κουρουμπλής', + 'Μιχαήλ Κριτσωτάκης', + 'Βασίλης Κυριακάκης', + 'Αγλαΐα Κυρίτση', + 'Γιώργος Κυρίτσης', + 'Πέτρος Κωνσταντινέας', + 'Ζωή Κωνσταντοπούλου', + 'Ηλίας Κωστοπαναγιώτου' + ] + ] + ] +]); + + diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php index fe08d5c..5a60891 100644 --- a/public/app/controllers/JsonToForm.php +++ b/public/app/controllers/JsonToForm.php @@ -142,8 +142,15 @@ class JsonToForm } - public static function make_a_form($formJson) + public static function make_a_form($form) { + $formJson = json_decode(json_encode($form)); + + $default_outer = $form->defaults->outer_class ?? ''; + $default_inner = $form->defaults->inner_class ?? ''; + $default_type = $form->defaults->type ?? 'text'; + + // TODO handle $form->defaults->source; // Script Workflow: // --------------------------------------------------------------------------- @@ -174,26 +181,22 @@ class JsonToForm - $html = ' -
-

Εισαγωγή Εγγραφής

'; + $html = ''; - foreach ($formJson as $key => $field) { + foreach ($formJson->form as $key => $field) { + $attributes = $field->attributes ?? []; // attributes array + $type = $field->type ?? $default_type; + $class = $field->class ?? ""; + $label = $field->label; + $name = $field->name ?? "$field->label"; - // get attributes + // TODO: auto value - if (isset($field->atr)) { - $atrs = explode('|', $field->atr); // attributes array - } else { - $atrs = []; - } - $appendKey = in_array('append-key', $atrs) ? true : false; // append key (for selects) - $required = in_array('required', $atrs) ? 'required' : ''; // required - $asterisk = in_array('required', $atrs) ? '*' : ''; // asterisk in label if required - $class = (isset($field->len)) ? ' col-md-'.$field->len : 'col-md-12'; // column class (for width) - $name = $field->nam; - $label = $field->lab; + $appendKey = in_array('append-key', $attributes) ? true : false; // append key (for selects) + $required = in_array('required', $attributes) ? 'required' : ''; // required + $asterisk = in_array('required', $attributes) ? '*' : ''; // asterisk in label if required + $html .= " @@ -201,19 +204,19 @@ class JsonToForm "; - switch ($field->typ) { + switch ($type) { case 'select': - if (in_array('multiple', $atrs)) { // if select is multiple + if (in_array('multiple', $attributes)) { // if select is multiple $html .=" - "; // prepare initialization of select2 (multiple) $initSelectsJS .= " var {$name} = $('#{$name}'); - {$name}.select2({ width: '100%' });"; + {$name}.select2({ width: '100%', placeholde: '{$label}' });"; // prepare check if empty field $checkFilledJS .= " @@ -224,13 +227,13 @@ class JsonToForm } else { // select is single; draw select + add empty option $html .=" - + "; - // prepare initialization of select2 (single) - $initSelectsJS .= " - var {$name} = $('#{$name}'); - {$name}.select2({ allowClear: true });"; + // // prepare initialization of select2 (single) + // $initSelectsJS .= " + // var {$name} = $('#{$name}'); + // {$name}.select2({ allowClear: true });"; // prepare check if empty field $checkFilledJS .= " @@ -240,10 +243,11 @@ class JsonToForm } // inject options - foreach ($field->opt as $key => $val) { + if (isset($field->options)) { + foreach ($field->options as $key => $val) { $html .= " - "; - } + "; + }} // close select $html .= ""; @@ -254,7 +258,19 @@ class JsonToForm case 'text': $html .= " - "; + "; + + $checkFilledJS = " + if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } + values.{$name} = $('input[name={$name}]').val();"; + + break; + + + case 'password': + + $html .= " + "; $checkFilledJS = " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } @@ -266,7 +282,7 @@ class JsonToForm case 'integer': $html .= " - "; + "; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } @@ -278,7 +294,7 @@ class JsonToForm case 'textarea': $html .= " - "; + "; $checkFilledJS .= " if ($('textarea[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } @@ -290,7 +306,7 @@ class JsonToForm case 'date': $html .= " - "; + "; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } @@ -302,7 +318,7 @@ class JsonToForm case 'email': $html .= " - "; + "; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}
'; } @@ -313,7 +329,7 @@ class JsonToForm default: // label, acts as common text - $html .= "