diff options
Diffstat (limited to 'public/app/views/js')
| -rw-r--r-- | public/app/views/js/pdf-designer/application.php | 142 | ||||
| -rw-r--r-- | public/app/views/js/pdf-designer/penalty.php (renamed from public/app/views/js/pdf/penalty-styler.php) | 0 | ||||
| -rw-r--r-- | public/app/views/js/pdf/application-styler.php | 191 | ||||
| -rw-r--r-- | public/app/views/js/submit/application-form.php | 62 | ||||
| -rw-r--r-- | public/app/views/js/submit/penalty-form.php | 74 |
5 files changed, 262 insertions, 207 deletions
diff --git a/public/app/views/js/pdf-designer/application.php b/public/app/views/js/pdf-designer/application.php new file mode 100644 index 0000000..1d77c67 --- /dev/null +++ b/public/app/views/js/pdf-designer/application.php @@ -0,0 +1,142 @@ +<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(); + + // 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: 'ΑΙΤΗΣΗ\n\n', + style: 'header' + }, + { + alignment: 'justify', + columns: [ + { + width: 210, + text: '' + }, + { + width: 'auto', + lineHeight: 1.35, + text:[ + 'ΠΡΟΣ\n', + { + style: 'bigger', + text: defines.organization + } + ] + } + ] + }, + { + columns: [ + { + width: 210, + lineHeight: 1.25, + alignment: 'left', + text: [ + 'Επώνυμο: ', { style: 'bigger', text: data.last_name }, + '\n\nΌνομα: ', { style: 'bigger', text: data.first_name }, + '\n\nΌνομα πατρός: ',{ style: 'bigger', text: data.father_name }, + '\n\nAM: ',{ style: 'bigger', text: data.registration_number }, + '\n\nΚλάδος/Ειδικότητα: ',{ style: 'bigger', text: data.sector }, + '\n\nΣχολείο Οργανικής: ',{ + style: 'bigger', text: data.belonging_school + }, + // '\n\nΣχολείο Υπηρέτησης:\n\t',{ + // style: 'bigger', text: data.constants.organization + // }, + '\n\nΤηλέφωνο Επικοινωνίας: ',{ style: 'bigger', text: data.phone }, + '\n\nEmail: ', { style: 'bigger', text: data.email }, + '\n\nΘέση Υπηρέτησης: ',{ style: 'bigger', text: data.position } + + ] + }, + { + width: 'auto', + lineHeight: 1.33, + text: [ + '\n\n', + { + style: 'bigger', + text: data.request+'\n', + alignment: 'left' + }, + '\n\n', + { + text: elDate, + style: 'bigger', + alignment: 'center' + }, + { + text: '\n\n'+ defines.applier +'\n', + style: 'bigger', + alignment: 'center' + }, + { + style: 'bigger', + text: data.last_name +' '+data.first_name, + alignment: 'center' + } + ] + } + ] + } + ], + footer: { + text: [ + 'Αριθμός πρωτοκόλου: A124-2501-4568-7 / 2023-12-15', + '\ndocument signature: ' + defines.ticket + + ], + style: 'signature' + }, + styles: { + header: { + fontSize: 20, + 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' + } + }; +} + +</script>
\ No newline at end of file diff --git a/public/app/views/js/pdf/penalty-styler.php b/public/app/views/js/pdf-designer/penalty.php index e69de29..e69de29 100644 --- a/public/app/views/js/pdf/penalty-styler.php +++ b/public/app/views/js/pdf-designer/penalty.php diff --git a/public/app/views/js/pdf/application-styler.php b/public/app/views/js/pdf/application-styler.php deleted file mode 100644 index 35077ef..0000000 --- a/public/app/views/js/pdf/application-styler.php +++ /dev/null @@ -1,191 +0,0 @@ -<!-- 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 - } - - } - - - - --- also --- - - var dd = { - content: [ - { - text: 'This is a header with style', - style: 'header' - }, - - 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Confectum ponit legam, perferendis nomine miserum, animi. Moveat nesciunt triari naturam.\n\n', - - 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Confectum ponit legam, perferendis nomine miserum, animi. Moveat nesciunt triari naturam posset, eveniunt specie deorsus efficiat sermone instituendarum fuisse veniat, eademque mutat debeo. Delectet plerique protervi diogenem dixerit logikh levius probabo adipiscuntur afficitur, factis magistra inprobitatem aliquo andriam obiecta, religionis, imitarentur studiis quam, clamat intereant vulgo admonitionem operis iudex stabilitas vacillare scriptum nixam, reperiri inveniri maestitiam istius eaque dissentias idcirco gravis, refert suscipiet recte sapiens oportet ipsam terentianus, perpauca sedatio aliena video.\n\n', - - { - text: 'It is possible to apply multiple styles, by passing an array. This paragraph uses two styles: quote and small. When multiple styles are provided, they are evaluated in the specified order which is important in case they define the same properties', - style: ['quote', 'small'] - } - ], - styles: { - header: { - fontSize: 18, - bold: true, - alignment: 'center' - }, - subheader: { - fontSize: 15, - bold: true - }, - quote: { - italics: true - }, - small: { - fontSize: 8 - } - } - -} ---> - - - -<script> -var source = { - first_name: 'George', - last_name: 'Its me!', - father_name: 'Pipis', - message: 'Adhaesiones ratione beate arbitraretur detractis perdiscere, constituant hostis polyaeno.', - constants: { - organization: 'Ministry of Nothing' - } -} - - -function designer(data) { - return { - content: [ - { - text: 'ΑΙΤΗΣΗ\n\n', - style: 'header' - }, - { - alignment: 'justify', - columns: [ - { - width: 210, - text: '' - }, - { - width: 'auto', - text:[ - 'ΠΡΟΣ\n', - { - style: 'bigger', - text: data.constants.organization - } - ] - } - ] - }, - { - alignment: 'justify', - columns: [ - { - width: 210, - lineHeight: 1.5, - text: [ - 'Όνομα: ', { style: 'bigger', text: data.first_name }, - '\nΕπίθετο: ', { style: 'bigger', text: data.last_name }, - '\nΌνομα πατρός: ',{ style: 'bigger', text: data.father_name }, - '\nEmail: ', { style: 'bigger', text: data.email }, - ] - }, - { - width: 'auto', - lineHeight: 1.33, - text: [ - '\n\n', - { - style: 'bigger', - text: data.message+'\n' - }, - '\n\ndate: ', - '\n\nze Is', - '\n\n\n', - { - style: 'bigger', - text: data.last_name +' '+data.first_name - } - ] - } - ] - }, - '\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: 24, - bold: true, - alignment: 'center', - color: '#000' - }, - bigger: { - fontSize: 15, - italics: false, - color: '#000' - } - }, - defaultStyle: { - columnGap: 25, - fontSize: 13 - } - - }; - -} - -var dd = designer(source); diff --git a/public/app/views/js/submit/application-form.php b/public/app/views/js/submit/application-form.php index badff03..ed77c1f 100644 --- a/public/app/views/js/submit/application-form.php +++ b/public/app/views/js/submit/application-form.php @@ -1,4 +1,25 @@ <script> + function postObject() { + return { // select content data + subject: $('input[name=subject]').val(), + date: $('input[name=date]').val(), + 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), + ticket: ref.ticket + }; + } + + $(document).ready(function() { // When form is submited @@ -12,22 +33,7 @@ } 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 data = postObject(); var form_data = { // prepare data to post subject: $('input[name=of_department]').val(), @@ -50,5 +56,29 @@ }); + + // 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(); + }); + + }); </script> diff --git a/public/app/views/js/submit/penalty-form.php b/public/app/views/js/submit/penalty-form.php new file mode 100644 index 0000000..fcf9093 --- /dev/null +++ b/public/app/views/js/submit/penalty-form.php @@ -0,0 +1,74 @@ +<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() { + + // 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> |
