summaryrefslogtreecommitdiff
path: root/public/app
diff options
context:
space:
mode:
Diffstat (limited to 'public/app')
-rw-r--r--public/app/config/setup_application.php31
-rw-r--r--public/app/controllers/Auth.php6
-rw-r--r--public/app/controllers/Office.php22
-rw-r--r--public/app/extends/App_user.php3
-rw-r--r--public/app/views/js/attachments-handling.php171
-rw-r--r--public/app/views/js/select2-supplementary.php101
-rw-r--r--public/app/views/js/submit/application-form.php54
-rw-r--r--public/app/views/js/submit/invitation-form.php52
-rw-r--r--public/app/views/templates/application.php266
-rw-r--r--public/app/views/user/invitation.php164
10 files changed, 531 insertions, 339 deletions
diff --git a/public/app/config/setup_application.php b/public/app/config/setup_application.php
index d44f59d..a5b7557 100644
--- a/public/app/config/setup_application.php
+++ b/public/app/config/setup_application.php
@@ -169,7 +169,7 @@ define('TEACHER_SECTORS', [
/** GENDER-ed constant arrays (LGBTQIA+ inclusive)
- * they use pronounces as key instead of binary gender-flag
+ * they use pronounces as key instead of a binary gender-flag
* -----------------------------------------------------------------------------
*/
@@ -218,48 +218,41 @@ define('REGISTRATION_FORM', [
[
'name' => 'first_name',
'label' => 'Όνομα',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'last_name',
'label' => 'Επίθετο',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'email',
'label' => 'Email',
'type' => 'email',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'father_name',
'label' => 'Πατρώνυμο',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'registration_number',
'label' => 'Αριθμός μητρώου',
'class' => 'col-8',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'sector',
'label' => 'Κλάδος / Ειδικότητα',
- 'value' => 'auto',
'type' => 'select',
- 'attributes' => ['required'],
+ 'attributes' => ['required', 'auto'],
'options' => TEACHER_SECTORS
],
[
'name' => 'belonging_school',
'label' => 'Σχολείο τοποθέτησης',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
// [ // working school = (obviously) is the current school
// 'name' => 'working_school',
@@ -270,16 +263,14 @@ define('REGISTRATION_FORM', [
'name' => 'position',
'label' => 'Θέση',
'type' => 'select',
- 'value' => 'auto',
- 'attributes' => ['required'],
+ 'attributes' => ['required', 'auto'],
'options' => []
],
[
'name' => 'phone',
'label' => 'Τηλέφωνο',
'class' => 'col-8',
- 'value' => 'auto',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'password',
@@ -340,7 +331,7 @@ define('APPLICATION_FORM', [
'name' => 'phone',
'label' => 'Τηλέφωνο',
'class' => 'col-5',
- 'attributes' => ['required']
+ 'attributes' => ['required', 'auto']
],
[
'name' => 'email',
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php
index d52b6c9..e2fe989 100644
--- a/public/app/controllers/Auth.php
+++ b/public/app/controllers/Auth.php
@@ -50,6 +50,7 @@ class Auth {
->set('first_name', $record['first_name'])
->set('last_name', $record['last_name'])
->set('father_name', $record['father_name'])
+ ->set('phone', $record['phone'])
->set('email', $record['email'])
->set('sector', $record['sector'])
->set('position', $record['position'])
@@ -172,7 +173,7 @@ class Auth {
$form_setup->form[$key]->options = $gendered_position;
// attach default values
- $form_setup->defaults->values = $user;
+ $form_setup->defaults = $user;
// get Form's HTML and Jsvascript
$form = JsonToForm::json_form($form_setup, [
@@ -180,7 +181,7 @@ class Auth {
['name' => 'id', 'value' => $user->id],
['name' => 'invitation', 'value' => $user->invitation]
- ]);
+ ]); // print_r($form_setup); die();
Render::view('user/invitation', [
'form' => $form,
@@ -231,6 +232,7 @@ class Auth {
'first_name' => $user->get('first_name'),
'last_name' => $user->get('last_name'),
'father_name' => $user->get('father_name'),
+ 'phone' => $user->get('phone'),
'email' => $user->get('email'),
'sector' => $user->get('sector'),
'position' => $user->get('position'),
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php
index 5038200..d4b0217 100644
--- a/public/app/controllers/Office.php
+++ b/public/app/controllers/Office.php
@@ -118,12 +118,12 @@ class Office {
- /** (any) petition
+ /** request any (empty/new) petition form
*
- * check if user is authorized to view the content;
- * if so, prepare and render the petition view
+ * The method acts as an authorization checker and internal router
+ * to actual petition form-templates
*
- * @param $petition_type (string): [common|penalty]
+ * @param $petition_tag (string): petition type ex. [common|penalty]
*/
public static function request_petition($petition_tag)
{
@@ -135,8 +135,9 @@ class Office {
'moto' => 'Forbidden',
'message' => 'Για να έχετε πρόσβαση, θα πρέπει πρώτα να συνδεθείτε'
]);
- die(); // then end;
- }
+ die(); // then die();
+
+ } // else continue...
$token = $manager->getUserToken(); // from token
$user = $token->getUser(); // create user
@@ -160,8 +161,9 @@ class Office {
}
- /** render application form
+ /** render an (empty/new) application form
*
+ * @param array $opts : user identity ([user_id => id])
*/
private static function render_application_form($opts)
{
@@ -192,8 +194,6 @@ class Office {
? GENDERED_POSITIONS['she']
: GENDERED_POSITIONS['he'];
-
-
// #4: get Form's HTML and Javascript ----------------------------------
$form = JsonToForm::json_form($form_setup, [
['name' => 'user_id', 'value' => $user_id] // pass user identity
@@ -204,8 +204,10 @@ class Office {
}
- /** render penalty form
+ /**
+ * render an (empty/new) penalty form
*
+ * @param array $opts : user identity ([user_id => id])
*/
private static function render_penalty_form($opts)
{
diff --git a/public/app/extends/App_user.php b/public/app/extends/App_user.php
index bb3d61d..dd41e2c 100644
--- a/public/app/extends/App_user.php
+++ b/public/app/extends/App_user.php
@@ -40,6 +40,7 @@ class App_user extends User
private $last_name;
private $father_name;
private $registration_number;
+ private $phone;
private $email;
private $sector;
private $belonging_school;
@@ -144,6 +145,7 @@ class App_user extends User
case 'first_name': $this->first_name = $val; return $this; break;
case 'last_name': $this->last_name = $val; return $this; break;
case 'father_name': $this->father_name = $val; return $this; break;
+ case 'phone': $this->phone = $val; return $this; break;
case 'email': $this->email = $val; return $this; break;
case 'sector': $this->sector = $val; return $this; break;
case 'position': $this->position = $val; return $this; break;
@@ -171,6 +173,7 @@ class App_user extends User
case 'first_name': return $this->first_name; break;
case 'last_name': return $this->last_name; break;
case 'father_name': return $this->father_name; break;
+ case 'phone': return $this->phone; break;
case 'email': return $this->email; break;
case 'sector': return $this->sector; break;
case 'position': return $this->position; break;
diff --git a/public/app/views/js/attachments-handling.php b/public/app/views/js/attachments-handling.php
new file mode 100644
index 0000000..4d97b0e
--- /dev/null
+++ b/public/app/views/js/attachments-handling.php
@@ -0,0 +1,171 @@
+<script>
+$(document).ready(function() {
+
+ // Attachements handling
+ ////////////////////////////////////////////////////////////////////////////
+
+
+ // Modal HTML Creators
+ // -----------------------------------------------------------------------------
+
+ const modal_header = (title) => {
+ return [
+ '<div class="modal-header">',
+ '<h4 class="modal-title" id="myModalLabel">',
+ title,
+ '</h4>',
+ '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">',
+ '<span aria-hidden="true"></span>',
+ '</button>',
+ '</div>'
+ ].join('\n');
+ }
+
+
+ const upload_file_form = () => {
+ return [
+ '<form method="POST" id="file_upload_form" name="upload_file_form">',
+
+ '<div class="modal-body">',
+
+ '<input type="hidden" name="folder" value="'+ altID +'">',
+
+ '<div class="form-group">',
+ '<label for="title">Τίτλος/Περιγραφή για το Αρχείο</label>',
+ '<input type="text" class="form-control " value="" name="title" id="title" placeholder="Τίτλος για το Αρχείο" required="">',
+ '</div>',
+
+ '<div class="form-group">',
+ '<label class="control-label" for="file">Εισαγωγή Αρχείου</label>',
+ '<input class="form-control" type="file" id="file" name="file" required="">',
+ '</div>',
+
+ '</div>',
+
+ '<div class="modal-footer">',
+ '<div class="row" style="width: 50%;">',
+ '<div class="form-actions">',
+ '<div class="col col-4">',
+ '<buton type="button" class="btn btn-default js-modal-close col-12" data-bs-dismiss="modal">',
+ 'Κλείσιμο',
+ '</button>',
+ '</div>',
+ '<div class="col-8">',
+ '<button class="btn btn-success col-12" type="submit">Καταχώριση</button>',
+ '</div>',
+ '</div>',
+ '</div>',
+ '</div>',
+
+ '</form>'
+ ].join('\n');
+ }
+
+
+ const preview_article = (title, intro, body) => {
+ return [
+ '<div class="modal-body">',
+ '<div class="post">',
+
+ '<h2>'+ title +'</h2>',
+
+ ((intro == '') ? '' : ('<div class="intro">'+ intro +'</div>')),
+
+ '<div class="article-body">',
+ marked.parse(body, { sanitize: true }),
+ '</div>',
+
+ '</div>',
+ '</div>',
+ '<div class="modal-footer">',
+ '<div class="row" style="width: 50%;">',
+ '<div class="form-actions">',
+ '<div class="col-md-4 col-md-offset-4 col-6 col-offset-3">',
+ '<buton type="button" class="btn btn-default js-modal-close col-12" data-bs-dismiss="modal">',
+ 'Κλείσιμο',
+ '</button>',
+ '</div>',
+ '</div>',
+ '</div>',
+ '</div>'
+ ].join('\n');
+ }
+
+
+ /** When modal show-up
+ * -------------------------------------------------------------------------
+ * ... prepare the manage-category form
+ * ... update select2 with possible parents
+ */
+ $('#editorModal').on('show.bs.modal', event => {
+ let button = $(event.relatedTarget); // Button that triggered the modal
+ let action = button.data('action'); // action
+ // var modal = $(this); // modal object
+
+ // update modal literature
+
+ switch (action) {
+ case 'upload_file':
+ $("#editorModal .modal-content").html(
+ modal_header('Εισαγωγή Αρχείου') + upload_file_form()
+ );
+ break;
+
+ case 'preview':
+ let preview = preview_article(
+ $('.edit-post form input[name=title]').val(),
+ $('.edit-post form textarea[name=intro]').val(),
+ $('.edit-post form textarea[name=body]').val()
+ );
+ $("#editorModal .modal-content").html( modal_header('Προεπισκόπηση') + preview);
+ break;
+
+ default:
+ // do nothing
+ }
+
+ });
+
+
+ /** submit upload file event
+ * -------------------------------------------------------------------------
+ */
+ $('#editorModal').on('submit', 'form[name=upload_file_form]', function (event) {
+ event.preventDefault();
+
+ // create the FormData object
+ // --- -- -- - - -
+ var fd = new FormData(document.getElementById('file_upload_form'));
+
+ // post the form (via ajax)
+ $.ajax({
+ url: '/admin/api/file_upload',
+ type: 'POST',
+ data: fd,
+ contentType: false,
+ processData: false,
+ dataType: 'json',
+ success: function(response) { // on success
+
+ if (response.success) {
+ files.push({ // ... update files array
+ id: response.id,
+ label: response.title,
+ path: response.path,
+ type: response.type
+ });
+ draw_files_list();
+
+ $('#editorModal').modal('hide');
+
+ } else {
+ console.log('File not uploaded');
+ }
+ }
+ });
+ });
+
+
+
+});
+</script>
diff --git a/public/app/views/js/select2-supplementary.php b/public/app/views/js/select2-supplementary.php
new file mode 100644
index 0000000..a7aa7e2
--- /dev/null
+++ b/public/app/views/js/select2-supplementary.php
@@ -0,0 +1,101 @@
+<script>
+
+ // 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();
+ }
+
+ /** selected_text
+ * --- -- -- - - -
+ * 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;
+ }
+ }
+
+</script> \ No newline at end of file
diff --git a/public/app/views/js/submit/application-form.php b/public/app/views/js/submit/application-form.php
new file mode 100644
index 0000000..badff03
--- /dev/null
+++ b/public/app/views/js/submit/application-form.php
@@ -0,0 +1,54 @@
+<script>
+ $(document).ready(function() {
+
+ // 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>
diff --git a/public/app/views/js/submit/invitation-form.php b/public/app/views/js/submit/invitation-form.php
new file mode 100644
index 0000000..efeba27
--- /dev/null
+++ b/public/app/views/js/submit/invitation-form.php
@@ -0,0 +1,52 @@
+<script>
+ $(document).ready(function() {
+
+ // When form is submited
+ ////////////////////////////////////////////////////////////////////////////
+
+ $('form').submit( event => {
+ event.preventDefault();
+
+ if ($('input[name=password]').val() != $('input[name=confirm_password]').val()) {
+ alert('Τα δυο κωδικοί πρόσβασης δεν ταιριάζουν!');
+
+ } else if ($('input[name=password]').val() == "") {
+ alert('Ο κωδικός πρόσβασης δεν μπορεί να είναι κενός')
+
+ } else if ( ($('input[name=password]').val() == '0')
+ || ($('input[name=password]').val() =='') ) {
+ alert('Παρκαλώ συμπληρώστε ένα τηλέφωνο επικοινωνίας')
+
+ } else {
+ // prepare data to POST
+ var data = {
+ // identification fields
+ id: $('input[name=id]').val(),
+ invitation: $('input[name=invitation]').val(),
+ // data fields
+ first_name: $('input[name=first_name]').val(),
+ last_name: $('input[name=last_name]').val(),
+ father_name: $('input[name=father_name]').val(),
+ email: $('input[name=email]').val(),
+ registration_number: $('input[name=registration_number]').val(),
+ sector: $('select[name=sector]').select2('data')[0].text,
+ belonging_school: $('input[name=belonging_school]').val(),
+ position: $('select[name=position]').select2('data')[0].text,
+ phone: $('input[name=phone]').val(),
+ // access verification
+ password: $('input[name=password]').val()
+ };
+ console.log(data);
+
+ var request = '/account/activate'; // set action url
+
+ // send POST request
+ $.post(request, data)
+ .done(function( data ) {
+ $('.office .content-form').html(`<h4>${data.title}<h4><br>${data.message}`)
+ });
+ }
+ });
+
+ });
+</script> \ No newline at end of file
diff --git a/public/app/views/templates/application.php b/public/app/views/templates/application.php
index a6b2b6b..f1f45fb 100644
--- a/public/app/views/templates/application.php
+++ b/public/app/views/templates/application.php
@@ -12,7 +12,7 @@
</head>
<body class="office central-form">
-<div class='container'>
+ <div class='container'>
<div class="content max720px">
<div class='content-form'>
@@ -31,185 +31,133 @@
</form>
</div>
+ <!-- attachments -->
+ <?php /* exclude until beta version
<div class="info">
- <h4>Synhmena</h4>
- <ul>
- <li>uno</li>
- <li>duo</li>
- <li>tre</li>
- </ul>
- </div>
+ <div class="row form-group">
- </div>
- </div>
-
-</body>
-<script>
-var values = {};
-var empty = '';
+ <label class="control-label col-sm-12" for="media">Συνημμένα</label>
-$(document).ready(function() {
+ <div class="col-sm-12 post-media">
- // supplementary functions to select2 control
- ////////////////////////////////////////////////////////////////////////////
+ <!-- Button trigger modal -->
+ <button type="button" class="btn btn-sm btn-success pull-right over-bar"
+ data-bs-toggle="modal" data-bs-target="#editorModal" data-action="upload_file">
+ <i class="fas fa-plus"></i> &nbsp; Προσθήκη
+ </button>
- /** 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;
- }
+ <ul id="files_list">
+ </ul>
- /** 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');
- }
+ </div>
- /** 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();
- }
+ </div>
+ </div>
+ */
+ ?>
+ </div>
+ </div>
- /**
- * 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;
- }
+ <!-- MODAL for file uploads and preview -->
+ <div class="modal fade" id="editorModal" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <!-- content will be dynamic -->
+ </div>
+ </div>
+ </div>
- /**
- * 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;
- }
- }
+</body>
- // intializations from form-definition
- ////////////////////////////////////////////////////////////////////////////
+<!-- SCRIPTS
+////////////////////////////////////////////////////////////////////////////////
+-->
- <?=$form['init_js']?>
+<script>// initialize needed global variables
+ var values = {};
+ var empty = '';
+</script>
- // track empty values
+<?php // include select2 supplementary functions
////////////////////////////////////////////////////////////////////////////
+ Render::view('js/select2-supplementary');
+?>
-
-
+<script>// pass dynamic js prepared by form designer
+ $(document).ready(function() {
- // When form is submited
- ////////////////////////////////////////////////////////////////////////////
+ // intializations from form-definition
+ ////////////////////////////////////////////////////////////////////////
+ <?=$form['init_js']?>
+
+ });
+</script>
- $('.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);
+<?php // handle form submition
+ ////////////////////////////////////////////////////////////////////////////
+ Render::view('js/submit/application-form');
+?>
- // send POST request
- // $.post(request, form_data)
- // .done(function( data ) {
- // $('.classroom .content-form').html(data.message)
- // });
- }
- });
+<?php // include attachments handling
+ ////////////////////////////////////////////////////////////////////////////
+ Render::view('js/attachments-handling');
+?>
+</html>
- });
-</script>
-</html>
+<!-- application pdf template
+ check: http://pdfmake.org/playground.html
+ // playground requires you to assign document definition to a variable called dd
+
+ var dd = {
+ content: [
+ 'APPLICATION:\n\n',
+ {
+ alignment: 'justify',
+ columns: [
+ {
+ text: [
+ 'NAME: My Name',
+ 'Father: I do',
+ 'Mother:Me too',
+ 'Specs: Some quite big Address Lorem ipsum dolor sit amet, consectetur adipisicing elit'
+ ].join('\n\n')
+ },
+ {
+ text:[
+ 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.',
+ 'Malit profecta versatur nomine ocurreret multavit, officiis viveremus aeternum.',
+ 'Quando nostros congressus susceperant concederetur leguntur iam, vigiliae democritea tantopere causae.',
+ 'Atilii plerumque ipsas potitur pertineant multis rem quaeri pro, legendum didicisse credere ex maluisset per videtis.',
+ 'Cur discordans praetereat aliae ruinae dirigentur orestem eodem, praetermittenda divinum.',
+ 'Collegisti, deteriora malint loquuntur officii cotidie finitas referri doleamus ambigua acute.',
+ 'Adhaesiones ratione beate arbitraretur detractis perdiscere, constituant hostis polyaeno.',
+ 'Diu concederetur.'
+ ].join('\n')
+ }
+ ]
+ },
+ '\n\nOh, don\'t forget, we can use everything from styling examples (named styles, custom overrides) here as well.',
+ '\n\nWow, you\'ve read the whole document! Congratulations :D'
+ ],
+ styles: {
+ header: {
+ fontSize: 18,
+ bold: true
+ },
+ bigger: {
+ fontSize: 15,
+ italics: true
+ }
+ },
+ defaultStyle: {
+ columnGap: 20
+ }
+
+ }
+--> \ No newline at end of file
diff --git a/public/app/views/user/invitation.php b/public/app/views/user/invitation.php
index 34cfbf6..030c1d3 100644
--- a/public/app/views/user/invitation.php
+++ b/public/app/views/user/invitation.php
@@ -59,108 +59,19 @@
</body>
-<script>
-var values = {};
-var empty = '';
+<script>// initialize needed global variables
+ var values = {};
+ var empty = '';
+</script>
-$(document).ready(function() {
- // supplementary functions to select2 control
+<?php // include select2 supplementary functions
////////////////////////////////////////////////////////////////////////////
+ Render::view('js/select2-supplementary');
+?>
- /** 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 (control.select2('data').lenght == 0) return false
- else return control.select2('data')[0].text;
- }
-
- /**
- * get all selected texts from a multi-select2 contol
- */
- function selected_multitexts(control) {
- if (control.select2('data').legth == 0) return false;
- else {
- var result = [];
- control.select2('data').forEach( item => { result.push(item.text); });
- return result;
- }
- }
+<script>
+$(document).ready(function() {
// intializations from form-definition
////////////////////////////////////////////////////////////////////////////
@@ -168,60 +79,17 @@ $(document).ready(function() {
<?=$form['init_js']?>
- // track empty values
+ // set known values
////////////////////////////////////////////////////////////////////////////
<?=$form['values_js']?>
-
- // When form is submited
- ////////////////////////////////////////////////////////////////////////////
-
- $('form').submit( event => {
- event.preventDefault();
-
- if ($('input[name=password]').val() != $('input[name=confirm_password]').val()) {
- alert('Τα δυο κωδικοί πρόσβασης δεν ταιριάζουν!');
-
- } else if ($('input[name=password]').val() == "") {
- alert('Ο κωδικός πρόσβασης δεν μπορεί να είναι κενός')
-
- } else if ( ($('input[name=password]').val() == '0')
- || ($('input[name=password]').val() =='') ) {
- alert('Παρκαλώ συμπληρώστε ένα τηλέφωνο επικοινωνίας')
-
- } else {
- // prepare data to POST
- var data = {
- // identification fields
- id: $('input[name=id]').val(),
- invitation: $('input[name=invitation]').val(),
- // data fields
- first_name: $('input[name=first_name]').val(),
- last_name: $('input[name=last_name]').val(),
- father_name: $('input[name=father_name]').val(),
- email: $('input[name=email]').val(),
- registration_number: $('input[name=registration_number]').val(),
- sector: $('select[name=sector]').select2('data')[0].text,
- belonging_school: $('input[name=belonging_school]').val(),
- position: $('select[name=position]').select2('data')[0].text,
- phone: $('input[name=phone]').val(),
- // access verification
- password: $('input[name=password]').val()
- };
- console.log(data);
-
- var request = '/account/activate'; // set action url
-
- // send POST request
- $.post(request, data)
- .done(function( data ) {
- $('.office .content-form').html(`<h4>${data.title}<h4><br>${data.message}`)
- });
- }
- });
-
-
});
</script>
+
+
+<?php // handle form submition
+ ////////////////////////////////////////////////////////////////////////////
+ Render::view('js/submit/invitation-form');
+?>
</html>