diff options
| -rw-r--r-- | public/app/config/setup_application.php | 33 | ||||
| -rw-r--r-- | public/app/controllers/Office.php | 15 | ||||
| -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 | ||||
| -rw-r--r-- | public/app/views/templates/penalty.php | 141 | ||||
| -rw-r--r-- | public/assets/css/class.css | 50 | ||||
| -rw-r--r-- | public/assets/css/overides.css | 47 |
9 files changed, 466 insertions, 215 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> diff --git a/public/assets/css/class.css b/public/assets/css/class.css index ef9239e..9f8d8be 100644 --- a/public/assets/css/class.css +++ b/public/assets/css/class.css @@ -35,15 +35,46 @@ --form-input-height: 31px; --form-layer-border: 1px solid #e7e5e5; --select2-arrow-top: -1px; + /* + --background-image: url(https://static.vecteezy.com/system/resources/previews/001/946/670/original/abstract-template-grey-geometric-shine-and-layer-background-with-light-blue-effect-technology-style-free-vector.jpg); + + --background-image: url(https://e0.pxfuel.com/wallpapers/512/865/desktop-wallpaper-grey-background-vectors-stock-psd-light-gray.jpg); + + https://img.freepik.com/free-vector/blue-sky-abstract-light-background_1182-1758.jpg + + https://wallpaperaccess.com/full/2661986.jpg + + https://i.pinimg.com/originals/4d/b7/72/4db7721932b839f545f474363bf5288c.jpg + + https://images.pexels.com/photos/7130555/pexels-photo-7130555.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1 + + https://img.freepik.com/free-vector/white-abstract-background-paper-style_23-2148385754.jpg?w=2000 + + https://wallpaperaccess.com/full/1216514.jpg + + + https://img.freepik.com/free-vector/beige-blurred-background_1034-247.jpg + + https://img.freepik.com/premium-photo/smoke-abstract-background-light-pastel-colors_89245-89.jpg + + https://img.freepik.com/premium-vector/light-blurred-bokeh-background-vector-illustration_64749-4578.jpg?w=2000 + + + https://c4.wallpaperflare.com/wallpaper/425/710/482/evening-night-picnic-blur-wallpaper-preview.jpg + + */ + + --background-image: url(https://c4.wallpaperflare.com/wallpaper/425/710/482/evening-night-picnic-blur-wallpaper-preview.jpg); } + html, body, select, select option { font-family: "Fira Sans", sans-serif; font-weight: 400; font-size: 1rem; } -body { margin: 1em 0; } +body { padding: 1em 0; background: var(--background-image); background-size: cover; } .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { font-weight: 400; }; @@ -74,7 +105,10 @@ html, body { .info .list-group-item a { display: block; text-decoration: none; font-size: 14px; color: #444; padding: 8px 16px; } .info li.list-group-item { margin:0; padding: 0; } .info li.list-group-item:hover { background: #f2f2f2; } -.info li.list-group-item.separator { border: 2px solid #f2f2f2; background: #f2f2f2; padding:1px 8px; color: #666; } +.info li.list-group-item.separator { + border: none; padding:2px 8px 1px; + background: #f2f2f299; color: #345; +} @@ -167,3 +201,15 @@ html, body { } .office .page-container { max-width: 1024px; } + + +/* themed OVERIDES */ + + +/* class.css | http://localhost/assets/css/class.css */ + +.central-form .content-form { + /* background: var(--light-grey-layer-bgr); */ + background: #dddb; +} + diff --git a/public/assets/css/overides.css b/public/assets/css/overides.css index aa3173a..6f34702 100644 --- a/public/assets/css/overides.css +++ b/public/assets/css/overides.css @@ -144,10 +144,7 @@ ul.select2-selection__rendered { margin-bottom: 0; } /* select2: ul */ -.central-form form label { - /* font-size: 14px; */ - font-size: .92rem; color: #554c; - } +.central-form form label { font-size: 14px; color: #433; } /* bootstrap.min.css | https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css */ @@ -167,4 +164,44 @@ ul.select2-selection__rendered { margin-bottom: 0; } /* select2: ul */ .select2-container--default.select2-container--focus .select2-selection--multiple { border: 1px solid #86b7fe;; outline: 0; - }
\ No newline at end of file + } + + + + + +/* Element | http://localhost/panel */ + +.list-group { + box-shadow: var(--light-grey-shade); + } + + /* class.css | http://localhost/assets/css/class.css */ + + .info li.list-group-item.separator { + /* border: none; */ + /* background: #f2f2f299; */ + /* color: #345; */ + border-bottom: none; + background: #f2f2f2ee; + color: #776; + background: #fff; + border-top: 1px solid #edd; + } + + .info li.list-group-item:hover { background: #def; } + .info li.list-group-item.separator:hover { background: #fff; } + + .info li.list-group-item { + border-bottom: none; + } + + + +/* overides.css | http://localhost/assets/css/overides.css */ + +.info li.list-group-item.separator { + border-left: 1px solid #dee2e6; + border-right: 1px solid #dee2e6; +} +
\ No newline at end of file |
