diff options
Diffstat (limited to 'public/app/views/js')
| -rw-r--r-- | public/app/views/js/pdf-designer/application.php | 5 | ||||
| -rw-r--r-- | public/app/views/js/pdf-designer/penalty.php | 197 | ||||
| -rw-r--r-- | public/app/views/js/submit/application-form.php | 60 | ||||
| -rw-r--r-- | public/app/views/js/submit/penalty-form.php | 133 |
4 files changed, 319 insertions, 76 deletions
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'; + } }); |
