diff options
| -rw-r--r-- | public/app/config/app_constants.php | 355 | ||||
| -rw-r--r-- | public/app/controllers/JsonToForm.php | 92 | ||||
| -rw-r--r-- | public/app/extends/App_manager.php (renamed from public/app/extends/Classroom_manager.php) | 2 | ||||
| -rw-r--r-- | public/app/extends/App_user.php (renamed from public/app/extends/Classroom_user.php) | 2 | ||||
| -rw-r--r-- | public/app/models/Access_model.php | 28 | ||||
| -rw-r--r-- | public/app/models/_info.md | 15 | ||||
| -rw-r--r-- | public/app/routes/backend.php | 52 | ||||
| -rw-r--r-- | public/app/routes/frontend.php | 4 | ||||
| -rw-r--r-- | public/app/routes/user.php | 15 | ||||
| -rw-r--r-- | public/app/views/templates/penalty.php | 127 | ||||
| -rw-r--r-- | public/app/views/user/registration.php | 67 | ||||
| -rw-r--r-- | public/app/views/welcome.php | 211 | ||||
| -rw-r--r-- | public/assets/css/overides.css | 13 | ||||
| -rwxr-xr-x | tests/code/eval.php | 111 |
14 files changed, 699 insertions, 395 deletions
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/'); // <base> path to contruct link -define('JS_LIBRARIES', array( // path after <base> 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 <base> 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', "<h3>Αποτυχία Εγγραφής</h3> // activation // --- define('ACCOUNT_ACTIVATED_TITLE', 'Ο λογαριασμός σας έχει ενεργοποιηθεί'); -define('ACCOUNT_ACTIVATED_MESSAGE', 'Τώρα μπορείτε να κάνετε - <a href="/login">Είσοδο στο σύστημα</a> - για να δείτε περισσότερο περιεχόμενο'); +define('ACCOUNT_ACTIVATED_MESSAGE', 'Τώρα μπορείτε να + <a href="/login">συνδεθείτε στο σύστημα</a>.'); 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 = ' - <div class="pi-container"> - <h2>Εισαγωγή Εγγραφής</h2>'; + $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 <label for='{$name}'>{$label} {$asterisk}</label> "; - 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 .=" - <select id='{$name}$' class='select-field' name='{$name}[]' multiple='multiple' style='width:100%'>"; + <select id='{$name}' class='form-select form-select-sm' name='{$name}[]' multiple='multiple' style='width:100%'>"; // 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 .=" - <select id='{$name}$' class='select-field' name='{$name}' style='width:100%'> - <option></option>"; + <select id='{$name}' class='form-select form-select-sm' name='{$name}' style='width:100%'> + <option value='0'>(επιλέξτε)</option>"; - // 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 .= " - <option value='{$val->id}'>{$val->tag}</option>"; - } + <option value='{$key}'>{$val}</option>"; + }} // close select $html .= "</select>"; @@ -254,7 +258,19 @@ class JsonToForm case 'text': $html .= " - <input type='text' class='form-control' name='{$name}' {$required}>"; + <input type='text' class='form-control form-control-sm' name='{$name}' {$required}>"; + + $checkFilledJS = " + if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } + values.{$name} = $('input[name={$name}]').val();"; + + break; + + + case 'password': + + $html .= " + <input type='password' class='form-control form-control-sm' name='{$name}' {$required}>"; $checkFilledJS = " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } @@ -266,7 +282,7 @@ class JsonToForm case 'integer': $html .= " - <input type='number' class='form-control' name='{$name}' min='0' step='1' {$required}>"; + <input type='number' class='form-control form-control-sm' name='{$name}' min='0' step='1' {$required}>"; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } @@ -278,7 +294,7 @@ class JsonToForm case 'textarea': $html .= " - <textarea class='form-control' name='{$name}' {$required}></textarea>"; + <textarea class='form-control form-control-sm' name='{$name}' {$required}></textarea>"; $checkFilledJS .= " if ($('textarea[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } @@ -290,7 +306,7 @@ class JsonToForm case 'date': $html .= " - <input type='date' class='form-control' name='{$name}' {$required}>"; + <input type='date' class='form-control form-control-sm' name='{$name}' {$required}>"; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } @@ -302,7 +318,7 @@ class JsonToForm case 'email': $html .= " - <input type='email' class='form-control' name='{$name}' {$required}>"; + <input type='email' class='form-control form-control-sm' name='{$name}' {$required}>"; $checkFilledJS .= " if ($('input[name={$name}]').val() =='') { empty += '{$label} {$asterisk}<br />'; } @@ -313,7 +329,7 @@ class JsonToForm default: // label, acts as common text - $html .= "<label>{$label}</label"; + //$html .= "<label>{$label}</label"; } @@ -405,7 +421,7 @@ class JsonToForm * <!-- custom field --> * <div class="form-group"> * <label for="more">Συμπληρωματική Πληροφορία</label> - * <textarea name="note" class="form-control tall"></textarea> + * <textarea name="note" class="form-control form-control-sm tall"></textarea> * <?php * // append js code * // for checking if field is empty @@ -559,7 +575,7 @@ class JsonToForm * * * - * // 03. FORM-CONTROLS + * // 03. form-control form-control-smS * // --------------------------------------------------------------------------- * ////////////////////////////////////////////////////////////////////////////// * diff --git a/public/app/extends/Classroom_manager.php b/public/app/extends/App_manager.php index ea2e891..8e6ce95 100644 --- a/public/app/extends/Classroom_manager.php +++ b/public/app/extends/App_manager.php @@ -13,7 +13,7 @@ use Registry; * according to this app's special rules * */ -class Classroom_manager extends UserManager +class App_manager extends UserManager { private $index_key = 'email'; // identifing user field (username, email, etc ) diff --git a/public/app/extends/Classroom_user.php b/public/app/extends/App_user.php index c27c4bf..9aed489 100644 --- a/public/app/extends/Classroom_user.php +++ b/public/app/extends/App_user.php @@ -21,7 +21,7 @@ use Registry; * So the content is available to the READER(s) that have certain Privileges * */ -class Classroom_user extends User +class App_user extends User { /** user id diff --git a/public/app/models/Access_model.php b/public/app/models/Access_model.php index d5ae19e..8d446dc 100644 --- a/public/app/models/Access_model.php +++ b/public/app/models/Access_model.php @@ -56,33 +56,7 @@ class Access_model FROM user_role WHERE user_role.user_id = :id ) - ) AS Roles_json, - ( -- construct array of (root-)privileges granted to user - SELECT CONCAT( - '[', - GROUP_CONCAT(privilege.id), - ']' - ) - FROM privilege - WHERE privilege.id IN ( - SELECT user_privilege.privilege_id - FROM user_privilege - WHERE user_privilege.user_id = :id - ) - ) AS RootPrivileges_json, - ( -- construct array of (root-)privileges granted to user - SELECT CONCAT( - '[', - GROUP_CONCAT(privilege.includes), - ']' - ) - FROM privilege - WHERE privilege.id IN ( - SELECT user_privilege.privilege_id - FROM user_privilege - WHERE user_privilege.user_id = :id - ) - ) AS SubPrivileges_json + ) AS Roles_json FROM user WHERE id = :id", [ ':id' => $id ] diff --git a/public/app/models/_info.md b/public/app/models/_info.md index 0c19c02..401c13c 100644 --- a/public/app/models/_info.md +++ b/public/app/models/_info.md @@ -112,3 +112,18 @@ record_id media_id +USER menu +--- +profile -> name, hello, last-login, do ... +profile/information +profile/requests (all) +profile/request/id (one) + +Admin menu +--- +admin -> requests (all), MODAL: protocol +admin/request/id -> request (one) +admin/iinvite + + + diff --git a/public/app/routes/backend.php b/public/app/routes/backend.php index 027c50a..1290f8a 100644 --- a/public/app/routes/backend.php +++ b/public/app/routes/backend.php @@ -31,58 +31,6 @@ Route::add('/admin/panel', function () { // admin panel #2 }); -// admin categories (=courses) -//////////////////////////////////////////////////////////////////////////////// - - -Route::add('/admin/categories', function () { // manage categories page - Auth::allowRoles([1, 2, 3]); - Render::view('admin/skeleton', [ - 'title' => 'Διαχείριση Κεφαλαίων', - 'action' => 'categories', - ]); -}); - -Route::add('/admin/api/categories', function () { // ajax: get all courses; with breadcrumbs - Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - CmsAdmin::breadcrumbs(); -}); - -Route::add('/admin/api/categories/add', function () { // ajax: add new category (course) - Auth::allowRoles([1, 2, 3]); - CmsAdmin::add_course(); -}, 'post'); - -Route::add('/admin/api/categories/update', function () { // ajax: edit category (course) - Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - CmsAdmin::update_course(); -}, -'post'); - - -// admin privileges -//////////////////////////////////////////////////////////////////////////////// - - -Route::add('/admin/privileges', function () { // manage privileges page - Auth::allowRoles([1, 2, 3]); - Render::view('admin/skeleton', [ - 'title' => 'Διαχείριση Δικαιωμάτων Πρόσβασης', - 'action' => 'privileges', - ]); -}); - -// ajax: get all privileges (courses; with breadcrumbs) -// use proxy (cache results); send as json -Route::add('/admin/api/privileges', function () { - Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json( Cache_service::privileges_hierarchy() ); -}); - -// add privilege - -// update privilege - // admin lessons diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php index 2112537..2defce5 100644 --- a/public/app/routes/frontend.php +++ b/public/app/routes/frontend.php @@ -9,8 +9,10 @@ use app\extends\Cache_service; // Home/Welcome //////////////////////////////////////////////////////////////////////////////// -Route::add('/', function() { Render::view('welcome'); }); +// Route::add('/', function() { Render::view('welcome'); }); +Route::add('/', function() { Render::view('user/registration'); }); +Route::add('/penalty', function() { Render::view('templates/penalty'); }); // Error pages //////////////////////////////////////////////////////////////////////////////// diff --git a/public/app/routes/user.php b/public/app/routes/user.php index 7ad0fa6..146b212 100644 --- a/public/app/routes/user.php +++ b/public/app/routes/user.php @@ -29,6 +29,13 @@ Route::add('/account/activate', function() { Auth::activate(); } ); Route::add('/account/reset_password', function() { Auth::reset_password(); } ); +// invite +Route::add('/invite', function() { + Auth::allowRoles([1, 2, 3]); + Render::view('admin/invite'); +}); + + // Replies to common requests (POST method) // --- -- -- - - - @@ -43,11 +50,9 @@ Route::add('/account/check-login', function() { // user sends a registration form Route::add('/account/register', function() { - $response = Auth::register(); - Render::json($response); - }, - 'post' -); + $response = Auth::register(); + Render::json($response); +},'post'); // Account Management diff --git a/public/app/views/templates/penalty.php b/public/app/views/templates/penalty.php new file mode 100644 index 0000000..6a8f563 --- /dev/null +++ b/public/app/views/templates/penalty.php @@ -0,0 +1,127 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title><?=SITE_TITLE?> - Εγγραφή</title> + + <?php // header includes + //////////////////////////////////////////////////////////////////////// + Render::view('components/header_includes'); + ?> + + <style> + html,body{ + padding:0; margin:0; + font-size:1.25em; + color: #037; background: #f6f6f6; + line-height:1.2em; + } + h3 { + font-size: 2em; font-style: normal; + font-weight: 400; + color: #05a; + margin: 0; padding: 5px; + opacity: 0.27; + border-bottom: 1px solid #05a; + } + .container { display: flex; height: 100vh; align-items:center; } + .content { position: relative; + max-width: 800px; width: 100%; + margin: auto auto; padding: .5em; + justify-center: center; + font-size: .78em; + } + .content-form { + padding: 1.5em; + background: #eee; + border-radius: 8px; + box-shadow: 1px 5px 7px #7777; + } + .content .info { padding: 1.5em; font-size: .92em; } + .content .info p { padding: .5em; color: #444; font-size: .82em } + .form-label { margin-bottom: .25rem; } + + .select2-container--default .select2-selection--multiple { font-size: 15px; } + .select2-container--default.select2-container--focus .select2-selection--multiple { line-height: 100%; } + label { font-size: 14px; } + </style> +</head> +<body class="classroom"> + <div class='container'> + <div class="content"> + <div class="info"> + <!--<h4>1o Γυμνάσιο Ραφήνας</h4> + <p>1o Γυμνάσιο Ραφήνας: Πλατφόρμα ηλεκτρονικών αιτήσεων και δημιουργίας εγγράφων</p>--> + </div> + <div class='content-form'> + <form method="post"> + <div> + <p>1o Γυμνάσιο Ραφήνας /<br /> + Πλατφόρμα ηλεκτρονικών αιτήσεων και δημιουργίας διαδικαστικών εγγράφων</p> + + <h2>Πρόσκληση #</h2> + + <?php + $form = JsonToForm::make_a_form(PENALTY_FORM); + ?> + + <?=$form['html']?> + + <br /> + <button type="submit" class="btn btn-primary btn-sm col-12">Εγγραφή</button> + + </div> + </form> + </div> + + <div class="info"> + <p>Απαιτείται η συμπλήρωση όλων των στοιχείων προκειμένου να γίνεται γρήγορα η σύνταξη των εγγράφων. Τα στοιχεία σας δεν πρόκειται να δημοσιοποιηθούν και προστατεύονται κατά την εισαγωγή τους με κρυπτογράφιση AES. Παράλληλα η σύνδεση στο site γίνεται με χρήση πιστοποιητικού SSL (RSA 2048 bits).</p> + <p>Αν έχετε ενεργοποιήσει ήδη το λογαρισμό σας <a href="/login">μπορείτε να συνδεθείτε</a>.</p> + + </div> + </div> +</body> + +<script> + // When form is submited + // ------------------------------------------------------------------------- + + $('.content-form form').submit( event => { + event.preventDefault(); + + if ($('input[name=password]').val() != $('input[name=password2]').val()) { + alert('Τα δυο passrods δεν ταιριάζουν!'); + + } else { + + // prepare data to POST + var data = { + first_name: $('input[name=first_name]').val(), + last_name: $('input[name=last_name]').val(), + email: $('input[name=email]').val(), + registration_number: $('input[name=registration_number]').val(), + sector: $('input[name=sector]').val(), + belonging_school: $('input[name=belonging_school]').val(), + working_shcool: $('input[name=working_shcool]').val(), + position_type_id: $('input[name=position_type_id]').val(), + phone: $('input[name=phone]').val(), + password: $('input[name=password]').val() + }; + + // select action url (add or update) + var request = '/account/register'; + + // send POST request + $.post(request, data) + .done(function( data ) { + $('.classroom .content-form').html(data.message) + }); + } + + }); + + + <?=$form['init_js']?> +</script> + +</html> diff --git a/public/app/views/user/registration.php b/public/app/views/user/registration.php index 57fbb8f..9eb0ea3 100644 --- a/public/app/views/user/registration.php +++ b/public/app/views/user/registration.php @@ -13,7 +13,7 @@ html,body{ padding:0; margin:0; font-size:1.25em; - color: #037; background: #eee; + color: #037; background: #f6f6f6; line-height:1.2em; } h3 { @@ -26,60 +26,55 @@ } .container { display: flex; height: 100vh; align-items:center; } .content { position: relative; - max-width:480px; width: 100%; + max-width: 540px; width: 100%; margin: auto auto; padding: .5em; justify-center: center; - font-size: .9em; + font-size: .78em; } .content-form { padding: 1.5em; - background: #e3e3e3; + background: #eee; border-radius: 8px; box-shadow: 1px 5px 7px #7777; } .content .info { padding: 1.5em; font-size: .92em; } - .content .info p { padding: .5em; } + .content .info p { padding: .5em; color: #444; font-size: .82em } .form-label { margin-bottom: .25rem; } + label { font-size: 14px; } </style> </head> <body class="classroom"> <div class='container'> <div class="content"> <div class="info"> - <h4>Classroom: Εγγραφή</h4> + <!--<h4>1o Γυμνάσιο Ραφήνας</h4> + <p>1o Γυμνάσιο Ραφήνας: Πλατφόρμα ηλεκτρονικών αιτήσεων και δημιουργίας εγγράφων</p>--> </div> <div class='content-form'> <form method="post"> <div> - <div class="mb-3"> - <label for="name" class="form-label">Όνομα</label> - <input type="text" class="form-control form-control-sm" name="name" required> - </div> - <div class="mb-3"> - <label for="surname" class="form-label">Επίθετο</label> - <input type="text" class="form-control form-control-sm" name="surname" required> - </div> - <div class="mb-3"> - <label for="exampleInputEmail1" class="form-label">Email</label> - <input type="email" class="form-control form-control-sm" name="email" aria-describedby="emailHelp" rerquired> - </div> - <div class="mb-3"> - <label for="exampleInputPassword1" class="form-label">Κωδικός Πρόσβασης</label> - <input type="password" class="form-control form-control-sm" name="password" required> - </div> - <div class="mb-3"> - <label for="exampleInputPassword2" class="form-label">Επιβεβαίωση Κωδικού Πρόσβασης</label> - <input type="password" class="form-control form-control-sm" name="password2" required> - </div> - <br /> - <button type="submit" class="btn btn-primary btn-sm col-12">Εγγραφή</button> + <p>1o Γυμνάσιο Ραφήνας /<br /> + Πλατφόρμα ηλεκτρονικών αιτήσεων και δημιουργίας διαδικαστικών εγγράφων</p> + + <h2>Πρόσκληση #</h2> + + <?php + $form = JsonToForm::make_a_form(REGISTRATION_FORM); + ?> + + <?=$form['html']?> + + <br /> + <button type="submit" class="btn btn-primary btn-sm col-12">Εγγραφή</button> + </div> </form> </div> + <div class="info"> - <p>Αν έχετε ήδη λογαρισμό <a href="/login">συνδεθείτε</a>.</p> - <p>Σε κάθε περίπτωση μπορείτε να επιστρέψετε στην <a href="/">αρχική σελίδα</a>.</p> - </div> + <p>Απαιτείται η συμπλήρωση όλων των στοιχείων προκειμένου να γίνεται γρήγορα η σύνταξη των εγγράφων. Τα στοιχεία σας δεν πρόκειται να δημοσιοποιηθούν και προστατεύονται κατά την εισαγωγή τους με κρυπτογράφιση AES. Παράλληλα η σύνδεση στο site γίνεται με χρήση πιστοποιητικού SSL (RSA 2048 bits).</p> + <p>Αν έχετε ενεργοποιήσει ήδη το λογαρισμό σας <a href="/login">μπορείτε να συνδεθείτε</a>.</p> + </div> </div> </body> @@ -98,9 +93,15 @@ // prepare data to POST var data = { - name: $('input[name=name]').val(), - surname: $('input[name=surname]').val(), + first_name: $('input[name=first_name]').val(), + last_name: $('input[name=last_name]').val(), email: $('input[name=email]').val(), + registration_number: $('input[name=registration_number]').val(), + sector: $('input[name=sector]').val(), + belonging_school: $('input[name=belonging_school]').val(), + working_shcool: $('input[name=working_shcool]').val(), + position_type_id: $('input[name=position_type_id]').val(), + phone: $('input[name=phone]').val(), password: $('input[name=password]').val() }; diff --git a/public/app/views/welcome.php b/public/app/views/welcome.php index ae260c6..e97f748 100644 --- a/public/app/views/welcome.php +++ b/public/app/views/welcome.php @@ -13,208 +13,29 @@ <!-- select2 --> <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> + + <style> +label { font-size:12px; } +.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { padding-left: 0; } +.form-group { margin-bottom: .667rem; } +select { height: 31px; padding-left: 8px; padding-right: 24px; } +select, input, +select option { font-size: .87rem; } + </style> </head> <body class='classroom'> - <div class="container"> + <div class="container" style="max-width: 640px;"> + <div class="row"> <?php - $formJsonText = '[ - { - "nam" : "summary", - "lab" : "My date", - "typ" : "date", - "len" : 4 - }, - { - "nam" : "material", - "lab" : "Υλικό", - "typ" : "select", - "atr" : "multiple", - "len" : 12, - "opt" : [ - { "id" : "SILV", "tag" : "Άργυλος" }, - { "id" : "COTTO", "tag" : "Βαμβάκι" }, - { "id" : "GRASS", "tag" : "Γυαλί" }, - { "id" : "STUCC", "tag" : "Γύψος (Στούκο)" }, - { "id" : "LEATH", "tag" : "Δέρμα" }, - { "id" : "IVORY", "tag" : "Ελεφαντόδοντο" }, - { "id" : "SPSTN", "tag" : "Ημιπολύτιμος Λίθος" }, - { "id" : "FIBER", "tag" : "Ίνες δέντρου" }, - { "id" : "CANE", "tag" : "Καλάμι" }, - { "id" : "HORN", "tag" : "Κέρατα Ζώων" }, - { "id" : "BRANC", "tag" : "Κλαδί δένδρου" }, - { "id" : "BONE", "tag" : "Κόκκαλο Ζώου" }, - { "id" : "CORAL", "tag" : "Κοράλι" }, - { "id" : "SHELL", "tag" : "Κοχύλι" }, - { "id" : "WOOL", "tag" : "Μαλλί" }, - { "id" : "METAL", "tag" : "Μέταλλο" }, - { "id" : "SILK", "tag" : "Μετάξι" }, - { "id" : "WOOD", "tag" : "Ξύλο" }, - { "id" : "STONE", "tag" : "Πέτρα" }, - { "id" : "PLAST", "tag" : "Πλαστικό" }, - { "id" : "CLSTN", "tag" : "Πολίτιμος Λίθος" }, - { "id" : "FEATH", "tag" : "Πούπουλα - Φτερά ζώου" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "technique", - "lab" : "Τεχνική κατασκευής", - "typ" : "select", - "len" : 6, - "opt" : [ - { "id" : "HND", "tag" : "Χειροποίητο" }, - { "id" : "MCH", "tag" : "Μηχανοποίητο" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "color", - "lab" : "Χρωματισμός", - "typ" : "select", - "atr" : "multiple", - "len" : 6, - "opt" : [ - { "id" : "SLV", "tag" : "Ασημί" }, - { "id" : "SEA", "tag" : "Γαλάζιο" }, - { "id" : "GRY", "tag" : "Γκρι" }, - { "id" : "BRW", "tag" : "Καφέ" }, - { "id" : "YEL", "tag" : "Κίτρινο" }, - { "id" : "RED", "tag" : "Κόκκινο" }, - { "id" : "CRM", "tag" : "Κρεμ" }, - { "id" : "WHI", "tag" : "Λευκό" }, - { "id" : "LOO", "tag" : "Λουλακί (Μπλε - Μωβ)" }, - { "id" : "BLK", "tag" : "Μαύρο" }, - { "id" : "BEZ", "tag" : "Μπεζ" }, - { "id" : "BLU", "tag" : "Μπλε" }, - { "id" : "VIO", "tag" : "Μωβ (Βιολετί)" }, - { "id" : "ORN", "tag" : "Πορτοκαλί" }, - { "id" : "GRN", "tag" : "Πράσινο" }, - { "id" : "PNK", "tag" : "Ροζ" }, - { "id" : "BRZ", "tag" : "Χάλκινο" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "decoration", - "lab" : "Διακόσμηση", - "typ" : "select", - "atr" : "multiple", - "len" : 6, - "opt" : [ - { "id" : "NATR", "tag" : "Με διακόσμηση" }, - { "id" : "GEOM", "tag" : "Χωρίς διακόσμηση" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "condition", - "lab" : "Κατάσταση", - "typ" : "select", - "atr" : "multiple", - "len" : 6, - "opt" : [ - { "id" : "REP", "tag" : "Επιδιορθωμένο" }, - { "id" : "NEW", "tag" : "Καινούργιο" }, - { "id" : "DMG", "tag" : "Κατεστραμμένο" }, - { "id" : "FUL", "tag" : "Πλήρες" }, - { "id" : "PRT", "tag" : "Τμήμα - Μέρος αντικειμένου" }, - { "id" : "WRN", "tag" : "Φθαρμένο" }, - { "id" : "USE", "tag" : "Χρησιμοποιημένο" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "birthplace", - "lab" : "Τόπος κατασκευής", - "typ" : "select", - "atr" : "multiple", - "len" : 12, - "opt" : [ - { "id" : "KLS", "tag" : "Καλλασσικές Κοιλάδες" }, - { "id" : "CTY", "tag" : "Αστικά Κέντρα" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "maker", - "lab" : "Κατασκευαστής", - "typ" : "select", - "atr" : "multiple", - "len" : 12, - "opt" : [ - { "id" : "PRIV", "tag" : "Ιδιώτης" }, - { "id" : "ARTI", "tag" : "Βιοτεχνία" }, - { "id" : "zzz", "tag" : "Άλλο" } - ] - }, - { - "nam" : "decade", - "lab" : "Δεκαετία", - "typ" : "select", - "len" : 6, - "opt" : [ - { "id": "190", "tag": "1900-1909" }, - { "id": "191", "tag": "1910-1919" }, - { "id": "192", "tag": "1920-1929" }, - { "id": "193", "tag": "1930-1939" }, - { "id": "194", "tag": "1940-1949" }, - { "id": "195", "tag": "1950-1959" }, - { "id": "196", "tag": "1960-1969" }, - { "id": "197", "tag": "1970-1979" }, - { "id": "198", "tag": "1980-1989" }, - { "id": "199", "tag": "1990-1999" }, - { "id": "200", "tag": "2000-2009" }, - { "id": "201", "tag": "2010-2019" }, - { "id": "202", "tag": "2020-2029" } - ] - }, - { - "nam" : "birthyear", - "lab" : "Έτος Κατασκευής", - "typ" : "integer", - "len" : 3 - }, - { - "nam" : "days2make", - "lab" : "Χρόνος κατασκευής (μέρες)", - "typ" : "integer", - "len" : 3 - }, - { - "nam" : "scope", - "lab" : "Σκοπός", - "typ" : "select", - "atr" : "multiple", - "opt" : [ - { "id" : "APO", "tag" : "Αποτροπαϊκός" }, - { "id" : "DEC", "tag" : "Διακοσμητικός" }, - { "id" : "CLB", "tag" : "Εορταστικός" }, - { "id" : "SMB", "tag" : "Συμβολικός" }, - { "id" : "RIT", "tag" : "Ιεροτελεστικός" }, - { "id" : "CER", "tag" : "Τελετουργικός" }, - { "id" : "TOU", "tag" : "Τουριστικός" }, - { "id" : "USE", "tag" : "Χρηστικός" }, - { "id" : "zzz", "tag" : "Άλλος" } - ] - }, - { - "nam" : "moreaboutStory", - "lab" : "Κατασκευαστικές Παρατηρήσεις", - "typ" : "textarea" - } - ]'; - - $formJson = json_decode($formJsonText); - - $form = JsonToForm::make_a_form($formJson); - - ?> + $form = JsonToForm::make_a_form(REGISTRATION_FORM); + ?> <?=$form['html']?> </div> + </div> @@ -453,4 +274,6 @@ $('#post-form').on('submit', function(e){ </body> -</html>
\ No newline at end of file +</html> + + diff --git a/public/assets/css/overides.css b/public/assets/css/overides.css index f9d351c..6e577fc 100644 --- a/public/assets/css/overides.css +++ b/public/assets/css/overides.css @@ -8,19 +8,10 @@ html, body { font-family: "Roboto Slab", serif; font-weight: 400; } .content { text-align: unset; } -.form-control { border: 1px solid #7777; } - +.form-group { margin-bottom: 8px; } +.form-control, .form-select { border: 1px solid #7777; font-size: .857em; } .form-label { font-size: .72em; color: var(--bs-heading-color); } - - - -/* main.min.css */ -.product__img { - /* max-width: 320px; */ - max-width: 240px; -} - .footer__listLink { color: #bbb; } diff --git a/tests/code/eval.php b/tests/code/eval.php new file mode 100755 index 0000000..911c68a --- /dev/null +++ b/tests/code/eval.php @@ -0,0 +1,111 @@ +<?php + +eval("\$a = [ + 'defaults' => [ + 'outer_class' => 'col-12', + 'inrer_class' => 'form-control', + 'type' => 'text', + 'source' => 'user' + ], + 'form' => [ + [ + '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' => 'request', + 'label' => 'Αίτημα (πχ, Παρακαλώ να μου χορηγήσετε ...)', + 'type' => 'textarea', + 'attributes' => ['required'] + ], + [ + 'name' => 'president', + 'label' => 'Ημερομηνία αίτησης', + 'type' => 'date', + 'attributes' => ['required'] + ], + [ + 'name' => 'members', + 'label' => '', + 'type' => 'select', + 'attributes' => ['required', 'multiple'], + 'source' => 'teachers' + ] + ] + ]; +"); + + +echo '<pre>'; +// var_dump($a); +$b = json_decode(json_encode($a)); +print_r($b); +echo '</pre>';
\ No newline at end of file |
