summaryrefslogtreecommitdiff
path: root/public/app
diff options
context:
space:
mode:
Diffstat (limited to 'public/app')
-rw-r--r--public/app/config/setup_application.php33
-rw-r--r--public/app/controllers/Office.php15
-rw-r--r--public/app/views/js/pdf-designer/application.php5
-rw-r--r--public/app/views/js/pdf-designer/penalty.php197
-rw-r--r--public/app/views/js/submit/application-form.php60
-rw-r--r--public/app/views/js/submit/penalty-form.php133
-rw-r--r--public/app/views/templates/penalty.php141
7 files changed, 376 insertions, 208 deletions
diff --git a/public/app/config/setup_application.php b/public/app/config/setup_application.php
index 4eb7a55..068c8a8 100644
--- a/public/app/config/setup_application.php
+++ b/public/app/config/setup_application.php
@@ -69,12 +69,7 @@ define('USER_ACCESS_TYPE', [
]);
-// MESSAGES ////////////////////////////////////////////////////////////////////
-// -----------------------------------------------------------------------------
-// Error Mesagges, Warnings and other Common Mesages
-define('EMPTY_REQUIRED_FIELDS', 'Δεν έχουν συμπληρωθεί όλα τα υποχρεωτικά πεδία');
-define('TICKET_EXPIRED', 'Η φόρμα που συμπληρώσατε φαίνεται να έχει λήξη. Ανανεώστε τη και προσπαθήστε πάλι.');
@@ -82,32 +77,28 @@ define('TICKET_EXPIRED', 'Η φόρμα που συμπληρώσατε φαίν
// -----------------------------------------------------------------------------
// these paths are used in order to easily find and autoload useful elemets
-
-// JAVASCRIPT LIBRARY PATHS
-// -----------------------------------------------------------------------------
-define('JS_DIR', '/content/'); // <base> path to contruct link
+# define('JS_DIR', '/assets/js/'); // JavaScript base library path
+# define('CSS_DIR', '/assets/css/'); // CSS base path
-// CSS ASSET PATHS
+// MESSAGES ////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
-define('CSS_DIR', '/content/css/'); // <base> path to contruct link
-define('CSS_FILES', array( // path after <base> to the actual file
- 'main' => 'main.min.css',
- 'filter' => 'filter.css',
- 'overides' => 'overides.css',
- )
-);
-
-
+// Error Mesagges, Warnings and other Common Mesages
-// Mesagges ////////////////////////////////////////////////////////////////////
-// -----------------------------------------------------------------------------
// 404
// ---
define('PAGE_404_TITLE', '404: Not Found');
+
+// Alert and connfirmation messages
+// ---
+define('EMPTY_REQUIRED_FIELDS', 'Δεν έχουν συμπληρωθεί όλα τα υποχρεωτικά πεδία');
+define('TICKET_EXPIRED', 'Η φόρμα που συμπληρώσατε φαίνεται να έχει λήξη. Ανανεώστε τη και προσπαθήστε πάλι.');
+define('CONFIRM_EXIT', 'ΠΡΟΣΟΧΗ: αν εγκαταλείψετε την σελίδα θα χάσετε ό,τι πληροφορίες έχετε εισάγει στη φόρμα.\n\nΘέλετε να φύγετε από τη σελίδα;');
+
+
// registration
// ---
define('REGISTRATION_SUCCESS', "<h3>Επιτυχής Εγγραφή</h3>
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php
index 9ff4e14..a876f6c 100644
--- a/public/app/controllers/Office.php
+++ b/public/app/controllers/Office.php
@@ -16,7 +16,6 @@ use app\extends\Cache_service;
class Office {
## -------------------------------------------------------------------------
- ##
## SERVE METHODS (selects)
##
## -------------------------------------------------------------------------
@@ -114,10 +113,8 @@ class Office {
## -------------------------------------------------------------------------
- ##
## PETITION FORMS
## secretarial support / serve forms for teachers' requests and applications
- ##
## -------------------------------------------------------------------------
@@ -256,8 +253,12 @@ class Office {
['name' => 'user_id', 'value' => $user_id] // pass user identity
]);
- // #5: render the view -------------------------------------------------
- Render::view('templates/penalty', ['form' => $form]);
+ // #5: create ticket; then render the view -----------------------------
+ $ticket = self::create_ticket(); // save ticket
+ Render::view('templates/penalty', [
+ 'form' => $form,
+ 'ticket' => $ticket
+ ]);
}
@@ -282,11 +283,11 @@ class Office {
public static function add_petition()
{
$post = Registry::get('REQUEST')->POST;
-
if (self::remove_ticket($post['ticket'])) { // check ticket + remove
- $manager = new App_manager();
+ $manager = new App_manager(); // use APP Manager
+ // to get the real author (user_id) of the petition
$new_id = Content_model::add_petition([
'user_id' => $manager->getUserToken()->getUser()->getID(),
diff --git a/public/app/views/js/pdf-designer/application.php b/public/app/views/js/pdf-designer/application.php
index 7441094..8017fa9 100644
--- a/public/app/views/js/pdf-designer/application.php
+++ b/public/app/views/js/pdf-designer/application.php
@@ -1,3 +1,8 @@
+<?php
+/** application PDF designer
+ * -----------------------------------------------------------------------------
+ */
+?>
<script>
function designer(data, defines) {
// handle date
diff --git a/public/app/views/js/pdf-designer/penalty.php b/public/app/views/js/pdf-designer/penalty.php
index e69de29..d452ed4 100644
--- a/public/app/views/js/pdf-designer/penalty.php
+++ b/public/app/views/js/pdf-designer/penalty.php
@@ -0,0 +1,197 @@
+<?php
+/** penalty PDF designer
+ * -----------------------------------------------------------------------------
+ */
+?>
+<script>
+function designer(data, defines) {
+ // handle date
+ const d = new Date( data.date );
+ const options = {
+ weekday: 'long',
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric'
+ };
+ var elDate = d.toLocaleDateString('el-GR', options);
+ var year = d.getFullYear().toString();
+
+ // var tick_parts = defines.ticket.match(/.{1,4}/g) ?? [];
+ // var easyread_ticket = tick_parts.join('-');
+
+
+
+ // get labels from id-specified objects
+ let petition = 'Αίτηση';
+
+ return {
+ info: {
+ title: data.subject,
+ author: defines.organization,
+ subject: data.subject,
+ keywords: [petition, year].join(', '),
+ },
+ content: [
+ {
+ text: [
+ 'ΠΡΑΚΤΙΚΟ ',
+ 'something',
+ ' / ',
+ 'something else\n\n'
+ ],
+ style: 'header'
+ },
+ {
+ alignment: 'left',
+ text: [
+ {
+ style: 'bigger',
+ text: 'ΘΕΜΑ: '
+ },
+ 'Πειθαρχική υπόθεση '+ data.of_article,
+ ' '+ data.student_names +', ',
+ 'του τμήματος ' + data.of_department + '\n',
+
+ {
+ style: 'bigger',
+ text: 'ΗΜΕΡΑ: '
+ },
+ elDate,
+ ', Ωρα'+ data.time + '\n',
+
+ {
+ style: 'bigger',
+ text: 'ΤΟΠΟΣ: '
+ },
+ data.place + '\n',
+
+ {
+ style: 'bigger',
+ text: 'ΠΕΙΘΑΡΧΙΚΟ ΟΡΓΑΝΟ: \n'
+ }
+ ]
+ },
+
+ {
+ columns: [
+ {
+ width: 6,
+ text: ''
+ },
+ {
+ width: 'auto',
+ text:[
+ {
+ style: 'bigger',
+ text: 'Πειθαρχικό Συμβούλιο από τους:\n'
+ },
+ {
+ style: 'bigger',
+ text: 'Πρόεδρος: '
+ },
+ data.president + '\n',
+
+ {
+ style: 'bigger',
+ text: 'Μέλη: '
+ },
+ data.members.join(', ') + '\n'
+ ]
+ }
+ ]
+ },
+ {
+ alignment: 'left',
+ text: [
+ {
+ style: 'bigger',
+ text: 'Εισηγητής: '
+ },
+ data.rapporteur + '\n',
+
+ {
+ style: 'bigger',
+ text: 'Κατηγορία: '
+ },
+ data.charge + '\n\n',
+
+ {
+ style: 'bigger',
+ text: 'Απολογία '+ data.of_article +': '
+ },
+ data.apology + '\n\n',
+
+ data.decision_reasoning + '\n\n'
+ ]
+ },
+ {
+ alignment: 'center',
+ style: 'bigger',
+ text: 'Το Πειθαρχικό Συμβούλιο αποφασίζει'
+ },
+ {
+ alignment: 'left',
+ text: data.decision
+ },
+
+ {
+ columns: [
+ {
+ width: 210,
+ alignment: 'center',
+ text: [
+ { style: 'bigger', text: 'Πρόεδρος:\n' },
+ data.president
+ ]
+ },
+ {
+ width: 'auto',
+ alignment: 'center',
+ text: [
+ { style: 'bigger', text: 'Μέλη:\n' },
+ data.members.join('\n')
+ ]
+ }
+ ]
+ }
+ ],
+ footer: {
+ text: [
+ 'Αριθμός πρωτοκόλου: A124-2501-4568-7 / 2023-12-15',
+ '\ndocument signature: ' + defines.ticket
+
+ ],
+ style: 'signature'
+ },
+ styles: {
+ header: {
+ fontSize: 12,
+ bold: true,
+ alignment: 'center',
+ color: '#000'
+ },
+ bigger: {
+ fontSize: 10,
+ italics: false,
+ bold: true,
+ color: '#000'
+ // decoration: 'underline'
+ },
+ signature: {
+ fontSize: 8,
+ italics: false,
+ alignment: 'center',
+ font: 'FiraMono'
+
+ }
+ },
+ defaultStyle: {
+ columnGap: 35,
+ fontSize: 9,
+ font: 'FiraSans',
+ lineHeight: 1.35
+ }
+ };
+}
+
+</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
index 2480d67..168ca0d 100644
--- a/public/app/views/js/submit/application-form.php
+++ b/public/app/views/js/submit/application-form.php
@@ -1,27 +1,31 @@
<script>
- function postObject() {
- return { // select content data
- subject: $('input[name=subject]').val(),
- date: $('input[name=date]').val(),
- type_id: 1, // 1 = application document
- first_name: $('input[name=first_name]').val(),
- last_name: $('input[name=last_name]').val(),
- father_name: $('input[name=father_name]').val(),
- phone: $('input[name=phone]').val(),
- email: $('input[name=email]').val(),
- registration_number: $('input[name=registration_number]').val(),
- belonging_school: $('input[name=belonging_school]').val(),
- date: $('input[name=date]').val(),
- sector: selected_text($('select[name=sector]')),
- position: selected_text($('select[name=position]')),
- request: $('textarea[name=request]').val(),
- now: Math.floor(Date.now() / 1000), // client timestamp
- ticket: ref.ticket
- };
- }
+ $(document).ready(function() {
+
+ // application details
+ ////////////////////////////////////////////////////////////////////////
+
+ function postObject() {
+ return { // select content data
+ subject: $('input[name=subject]').val(),
+ date: $('input[name=date]').val(),
+ type_id: 1, // 1 = application document
+ first_name: $('input[name=first_name]').val(),
+ last_name: $('input[name=last_name]').val(),
+ father_name: $('input[name=father_name]').val(),
+ phone: $('input[name=phone]').val(),
+ email: $('input[name=email]').val(),
+ registration_number: $('input[name=registration_number]').val(),
+ belonging_school: $('input[name=belonging_school]').val(),
+ date: $('input[name=date]').val(),
+ sector: selected_text($('select[name=sector]')),
+ position: selected_text($('select[name=position]')),
+ request: $('textarea[name=request]').val(),
+ now: Math.floor(Date.now() / 1000), // client timestamp
+ ticket: ref.ticket
+ };
+ }
- $(document).ready(function() {
// When form is submited
////////////////////////////////////////////////////////////////////////
@@ -73,5 +77,19 @@
});
+
+ // go-back event
+ ////////////////////////////////////////////////////////////////////////
+
+ $('.btn-back2panel').click( event => {
+ event.preventDefault();
+
+ let confirm_exit = confirm('<?=CONFIRM_EXIT?>');
+ if (confirm_exit) {
+ window.location.href = '/panel';
+ }
+ });
+
+
});
</script>
diff --git a/public/app/views/js/submit/penalty-form.php b/public/app/views/js/submit/penalty-form.php
index fcf9093..a5a8ec6 100644
--- a/public/app/views/js/submit/penalty-form.php
+++ b/public/app/views/js/submit/penalty-form.php
@@ -1,25 +1,33 @@
<script>
- function constructPost() {
- post = { // 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[]"]'))
- };
- }
+ $(document).ready(function() {
+
+ // penalty details
+ ////////////////////////////////////////////////////////////////////////
+
+ function postObject() {
+ return { // select content data
+ type_id: 2, // 1 = penalty document
+ subject: $('input[name=subject]').val(),
+ 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]')),
+ now: Math.floor(Date.now() / 1000), // client timestamp
+ members: selected_multitexts($('select[name="members[]"]')),
+ ticket: ref.ticket
+ };
+ }
- $(document).ready(function() {
// When form is submited
////////////////////////////////////////////////////////////////////////
@@ -27,46 +35,61 @@
$('.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 = '/petition/new';
- // select action url (add or update)
- // var request = '/account/register';
+ // send POST request
+ $.post(request, postObject())
+ .done(function( data ) {
console.log(data);
- // send POST request
- // $.post(request, form_data)
- // .done(function( data ) {
- // $('.classroom .content-form').html(data.message)
- // });
- }
+ if (data.success) { // ok ? redirect to panel
+ window.location.href = '/panel';
+
+ } else { // error ? alert!
+ alert(data.error);
+ }
+
+ });
+
+ });
+
+
+
+ // preview event
+ ////////////////////////////////////////////////////////////////////////
+
+ $('.btn-preview').click( event => {
+ event.preventDefault();
+ console.log('preview', postObject());
+
+ pdfMake.fonts = {
+ FiraSans: {
+ normal: '<?=SITE_URL?>/assets/fonts/FiraSans-Light.ttf',
+ bold: '<?=SITE_URL?>/assets/fonts/FiraSans-Medium.ttf'
+ // italics: 'https://example.com/fonts/fontFile3.ttf',
+ // bolditalics: 'https://example.com/fonts/fontFile4.ttf'
+ },
+ FiraMono: {
+ normal: '<?=SITE_URL?>/assets/fonts/FiraMono-Regular.ttf',
+ }
+ }
+
+ pdfMake.createPdf(designer( postObject(), ref )).open();
+ });
+
+
+
+ // go-back event
+ ////////////////////////////////////////////////////////////////////////
+
+ $('.btn-back2panel').click( event => {
+ event.preventDefault();
+ let confirm_exit = confirm('<?=CONFIRM_EXIT?>');
+ if (confirm_exit) {
+ window.location.href = '/panel';
+ }
});
diff --git a/public/app/views/templates/penalty.php b/public/app/views/templates/penalty.php
index e913721..4709d60 100644
--- a/public/app/views/templates/penalty.php
+++ b/public/app/views/templates/penalty.php
@@ -52,121 +52,53 @@
</div>
</body>
+
+<!-- SCRIPTS
+////////////////////////////////////////////////////////////////////////////////
+-->
+
<script>
-var values = {};
-var empty = '';
+ var ref = {
+ organization: '<?=DEFAULT_SCHOOL?>',
+ ticket: '<?=$ticket?>'
+ };
+</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 (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']?>
+<script>// pass dynamic js prepared by form designer
+ $(document).ready(function() {
+
+ // intializations from form-definition
+ ////////////////////////////////////////////////////////////////////////
+ <?=$form['init_js']?>
+
+ });
+</script>
- // track empty values
+<?php // handle form submition
////////////////////////////////////////////////////////////////////////////
+ Render::view('js/submit/penalty-form');
+?>
+
+
+<?php // load application pdf-designer
+ ////////////////////////////////////////////////////////////////////////////
+ Render::view('js/pdf-designer/penalty');
+?>
-
-
+
+
+<!-- DEPRICATED:
+<script>
+ $(document).ready(function() {
// When form is submited
////////////////////////////////////////////////////////////////////////////
@@ -219,5 +151,6 @@ $(document).ready(function() {
});
</script>
+-->
</html>