summaryrefslogtreecommitdiff
path: root/public/app/views/templates/penalty.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-05 04:07:05 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-05 04:07:05 +0300
commit537673748f0b01539fc5839c2af1bacbefafc86d (patch)
treec2032ff9efb06257bbf70f3329524d86bc2cb6e3 /public/app/views/templates/penalty.php
parent63f714d5a78b765c117ebf6bbdfdbd748dd45644 (diff)
downloadgyraf1gov-537673748f0b01539fc5839c2af1bacbefafc86d.tar.gz
gyraf1gov-537673748f0b01539fc5839c2af1bacbefafc86d.tar.bz2
gyraf1gov-537673748f0b01539fc5839c2af1bacbefafc86d.zip
the penalty form (input, new record)
Diffstat (limited to 'public/app/views/templates/penalty.php')
-rw-r--r--public/app/views/templates/penalty.php227
1 files changed, 155 insertions, 72 deletions
diff --git a/public/app/views/templates/penalty.php b/public/app/views/templates/penalty.php
index bbd7b4a..17e5426 100644
--- a/public/app/views/templates/penalty.php
+++ b/public/app/views/templates/penalty.php
@@ -9,115 +9,198 @@
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>
+<body class="office central-form">
+
+<div class='container'>
+ <div class="content max720px">
+
<div class='content-form'>
<form method="post">
<div>
- <h2>Πρακτικό Πειθαρχικής Υπόθεσης</h2>
+ <h4>Πρακτικό Πειθαρχικής Υπόθεσης</h4>
+ <hr />
<?=$form['html']?>
<br />
- <button type="submit" class="btn btn-primary btn-sm col-12">Εγγραφή</button>
+ <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>
+</body>
<script>
+var values = {};
+var empty = '';
+
+$(document).ready(function() {
+
+ // supplementary functions to select2 control
+ ////////////////////////////////////////////////////////////////////////////
+
+ /** getValues
+ * --- -- -- - - -
+ * Get selected value(s) of Select2 control
+ *
+ * @param arg: source-element
+ * @return (string) value(s) comma-separated
+ */
+ function getValues(srcElm) {
+ var res;
+ var obj = srcElm.select2('data'); // get delected data array
+
+ if (obj.length === 0) return ''; // if empty list then nothig is selected
+ else {
+ var i = 0;
+ obj.forEach(function(elm){ // loop through object elements array
+
+ if (i) res += ',' + elm.id; // if not first item, prepend ',' befor value(id)
+ else res = elm.id; // else set (first) checked value
+
+ i++;
+ });
+ }
+ return res;
+ }
+
+ /** select2_set_text
+ * --- -- -- - - -
+ * select an (select2-)option by text
+ * onto a (single) select2 control
+ *
+ * @param control = jquery selector,
+ * @param t (string) = text of option
+ */
+ function select2_set_text(control, t) {
+ opts = control.select2()[0].options;
+ var id;
+ for(i=0; i<opts.length; i++) { if (opts[i].text == t) id = i; }
+ control.val(id).trigger('change');
+ }
+
+ /** get_id_of_text
+ * --- -- -- - - -
+ * get id (=value) of an option with `t` as text
+ * onto a select2 control;
+ *
+ * Can be used on single or multiple select2 contols
+ *
+ * @param control = jquery selector,
+ * @param t (string) = text of option
+ */
+ function get_id_of_text( control , t) {
+ opts = control.select2()[0].options;
+ var id = false;
+ for(i=0; i<opts.length; i++) { if (opts[i].text == t) id = i; }
+ return id;
+ }
+
+ /** select2_set_multi_text
+ * --- -- -- - - -
+ * select several (select2-)options by text
+ *
+ * @param control = jquery selector,
+ * @param t_list (string) = list of selected texts
+ */
+ function select2_set_multi_text(control, t_list) { /* define function */
+ var ids = [];
+ t_list.forEach (t => { let id = get_id_of_text(control, t);
+ if (id !== false) ids.push(id);
+ })
+ control.val(ids).change();
+ }
+
+ /**
+ * get selected text of a select2 control
+ */
+ function selected_text(control) {
+ if (typeof control.select2('data') === 'undefined') return false;
+ else if (control.select2('data').length == 0) return false;
+ else return control.select2('data')[0].text;
+ }
+
+ /**
+ * get all selected texts from a multi-select2 contol
+ */
+ function selected_multitexts(control) {
+ if (typeof control.select2('data') === 'undefined') return false;
+ else if (control.select2('data').length == 0) return false;
+ else {
+ var result = [];
+ control.select2('data').forEach( item => { result.push(item.text); });
+ return result;
+ }
+ }
+
+ // intializations from form-definition
+ ////////////////////////////////////////////////////////////////////////////
+
+ <?=$form['init_js']?>
+
+
+ // track empty values
+ ////////////////////////////////////////////////////////////////////////////
+
+
+
+
+
// When form is submited
- // -------------------------------------------------------------------------
+ ////////////////////////////////////////////////////////////////////////////
$('.content-form form').submit( event => {
event.preventDefault();
- if ($('input[name=password]').val() != $('input[name=password2]').val()) {
+ if (false) {
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()
+ var data = { // select content data
+ of_article: selected_text($('select[name=of_article]')),
+ student_names: $('textarea[name=student_names]').val(),
+ of_department: $('input[name=of_department]').val(),
+ date: $('input[name=date]').val(),
+ time: $('input[name=time]').val(),
+ place: selected_text($('select[name=place]')),
+ rapporteur: selected_text($('select[name=rapporteur]')),
+ charge: $('textarea[name=charge]').val(),
+ apology: $('textarea[name=apology]').val(),
+ decision_reasoning: $('textarea[name=decision_reasoning]').val(),
+ decision: selected_text($('select[name=decision]')),
+ decision_more: $('input[name=decision_more]').val(),
+ president: selected_text($('select[name=president]')),
+ members: selected_multitexts($('select[name="members[]"]'))
};
+ var form_data = { // prepare data to post
+ subject: $('input[name=of_department]').val(),
+ content: JSON.stringify(data),
+ on_date: $('input[name=date]').val(),
+ user_id: $('input[name=id]').val()
+ }
+
// select action url (add or update)
- var request = '/account/register';
+ // var request = '/account/register';
+ console.log(data);
// send POST request
- $.post(request, data)
- .done(function( data ) {
- $('.classroom .content-form').html(data.message)
- });
+ // $.post(request, form_data)
+ // .done(function( data ) {
+ // $('.classroom .content-form').html(data.message)
+ // });
}
});
- <?=$form['init_js']?>
-
- <?=$form['values_js']?>
+ });
</script>
</html>