summaryrefslogtreecommitdiff
path: root/public/app/views/templates/application.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/views/templates/application.php')
-rw-r--r--public/app/views/templates/application.php215
1 files changed, 215 insertions, 0 deletions
diff --git a/public/app/views/templates/application.php b/public/app/views/templates/application.php
new file mode 100644
index 0000000..a6b2b6b
--- /dev/null
+++ b/public/app/views/templates/application.php
@@ -0,0 +1,215 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title><?=SITE_TITLE?> - Αίτηση</title>
+
+ <?php // header includes
+ ////////////////////////////////////////////////////////////////////////
+ Render::view('components/header_includes');
+ ?>
+
+</head>
+<body class="office central-form">
+
+<div class='container'>
+ <div class="content max720px">
+
+ <div class='content-form'>
+ <form method="post">
+ <div>
+
+ <h4>Αίτηση</h4>
+ <hr />
+
+ <?=$form['html']?>
+
+ <br />
+ <button type="submit" class="btn btn-primary btn-sm col-12">Καταχώριση</button>
+
+ </div>
+ </form>
+ </div>
+
+ <div class="info">
+ <h4>Synhmena</h4>
+ <ul>
+ <li>uno</li>
+ <li>duo</li>
+ <li>tre</li>
+ </ul>
+ </div>
+
+ </div>
+ </div>
+
+</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 (false) {
+ alert('Τα δυο passrods δεν ταιριάζουν!');
+
+ } else {
+
+ 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';
+ console.log(data);
+
+ // send POST request
+ // $.post(request, form_data)
+ // .done(function( data ) {
+ // $('.classroom .content-form').html(data.message)
+ // });
+ }
+
+ });
+
+
+ });
+</script>
+
+</html>