Access to forms information from restricted access users

parent 4dd337f6
......@@ -81,7 +81,7 @@ return [
],
'admin' => [
'adminhome' => [
'label' => 'Αρχική σελίδα διαχειριστή',
'label' => 'Σελίδα διαχειριστή',
'route' => 'admin',
],
]
......
......@@ -22,16 +22,6 @@ return function (App $app) {
});
$events('on', 'app.services', function (Container $container) {
// $nav = $container['settings']->get('navigation');
// $nav['admin'] = [
// 'adminhome' => [
// 'label' => 'Διαχειριστής',
// 'route' => 'admin',
// 'icon' => 'user-secret',
// ],
// ];
// $container['settings']->set('navigation', $nav);
$container[GrEduLabs\Admin\Action\Index::class] = function ($c) {
return new GrEduLabs\Admin\Action\Index($c['view']);
};
......
......@@ -6,9 +6,24 @@
<div class="panel-heading">
<h4>Σελίδα διαχειριστή</h4>
</div>
<div class="panel-body">
<p>Διαθέσιμες διαχειριστικές λειτουργίες</p>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>Διαθέσιμες διαχειριστικές λειτουργίες</th>
<th>&nbsp;</th>
<tr>
</thead>
<tbody>
<tr>
<td>Καταχωρημένες αιτήσεις εθελοντών - Εκπαιδευτικοί</td>
<td><a class="btn btn-primary btn-sm" href="{{ path_for('export.csv', {type: 'volunteer_teachers'}) }}"><i class="fa fa-download"></i> Αρχείο .csv</a></td>
</tr>
<tr>
<td>Καταχωρημένες αιτήσεις εθελοντών - Ιδρύματα</td>
<td><a class="btn btn-primary btn-sm" href="{{ path_for('export.csv', {type: 'volunteer_institutions'}) }}"><span class="fa fa-download"></span> Αρχείο .csv</a></td>
</tr>
</tbody>
</table>
<div class="panel-footer text-center">
<a class="btn btn-sm btn-default" href="{{ path_for('index') }}"><span class="fa fa-home"></span> Αρχική</a>
<a class="btn btn-sm btn-primary" href="{{ path_for('admin') }}"><span class="fa fa-user-secret"></span> Διαχειριστής</a>
......
......@@ -22,6 +22,13 @@ return function (App $app) {
$events('on', 'app.services', function (Container $c) {
$c['csv_export_protected_exports'] = function ($c) {
return [
'volunteer_teachers',
'volunteer_institutions',
];
};
$c['csv_export_config'] = function ($c) {
return [
......@@ -95,7 +102,6 @@ return function (App $app) {
'Σχόλια - Παρατηρήσεις',
],
],
'appnewforms' => [
'data_callback' => 'csv_export_appnewforms',
'headers' => [
......@@ -107,8 +113,6 @@ return function (App $app) {
'Σχόλια - Παρατηρήσεις',
],
],
'appforms_items' => [
'data_callback' => 'csv_export_appforms_items',
'headers' => [
......@@ -142,6 +146,62 @@ return function (App $app) {
'Αιτιολογία χρήσης',
],
],
'volunteer_teachers' => [
'data_callback' => 'csv_export_volunteer_teachers',
'headers' => [
'ID',
'Όνομα',
'Επώνυμο',
'Ειδικότητα',
'Αριθμός Μητρώου',
'Τηλέφωνο',
'Email',
'Σχολείο που υπηρετεί',
'Τηλέφωνο Σχολείου',
'Σχόλια/Παρατηρήσεις',
'Σχετική δράση που συμμετείχε',
'URL δράσης που συμμετείχε',
'Περιγραφή δράσης που συμμετείχε',
'Έργο 1',
'Έργο 2',
'Έργο 3',
'Έργο 4',
'Έργο 5',
'Έργο 6',
'Έργο 7',
'Έργο 8',
'Έργο 9',
'Έργο 10',
],
],
'volunteer_institutions' => [
'data_callback' => 'csv_export_volunteer_institutions',
'headers' => [
'ID',
'Ίδρυμα',
'Σχολή',
'Τμήμα',
'Ερευνητικό Κέντρο',
'Ινστιτούτο',
'Άλλο',
'Υπεύθυνος Επικοινωνίας',
'Τηλέφωνο',
'Email',
'Σχόλια/Παρατηρήσεις',
'Έργα',
'Περιγραφή (ακολουθούν ανά στήλη)',
'Έργο 1',
'Έργο 2',
'Έργο 3',
'Έργο 4',
'Έργο 5',
'Έργο 6',
'Έργο 7',
'Έργο 8',
'Έργο 9',
'Έργο 10',
],
],
];
};
......@@ -179,6 +239,102 @@ return function (App $app) {
};
};
$c['csv_export_volunteer_teachers'] = function ($c) {
return function () {
$sql = 'SELECT `id`, '
. '`name`, '
. '`surname`, '
. '`eidikothta`, '
. '`arithmitroou`, '
. '`telef`, '
. '`email`, '
. '`school`, '
. '`schooltelef`, '
. '`comments`, '
. '`projecttitle`, '
. '`projecturl`, '
. '`projectdescription` '
. ' FROM `volunteerteachers` '
. ' ORDER BY id ';
$volunteer_teachers = R::getAll($sql);
$volunteer_teachers = array_map(function ($row) {
if (($projects = preg_split('/###@@@###/msUu', $row['projectdescription'])) !== false) {
$projects_parts = array_map(function ($r) {
return preg_split('/_@@@_/msUu', $r);
}, $projects);
$projects_cnt = 0;
foreach ($projects_parts as $part) {
if (count($part) > $projects_cnt) {
$projects_cnt = count($part);
}
}
$recons = array_fill(0, $projects_cnt, '');
for ($i = 0; $i < $projects_cnt; $i++) {
$recons[$i] .= $projects_parts[0][$i] . "\r\n"
. (isset($projects_parts[1][$i]) ? $projects_parts[1][$i] : '') . "\r\n"
. (isset($projects_parts[2][$i]) ? $projects_parts[2][$i] : '');
$row['project' . $i] = $recons[$i];
}
$row['projectdescription'] = implode("\r\n--------------\r\n", $recons);
}
return $row;
}, $volunteer_teachers);
return $volunteer_teachers;
};
};
$c['csv_export_volunteer_institutions'] = function ($c) {
return function () {
$sql = 'SELECT `id`, '
. '`idrima`, '
. '`sxolh`, '
. '`tmhma`, '
. '`ereunitiko`, '
. '`institute`, '
. '`other`,'
. '`person`, '
. '`telef`, '
. '`email`, '
. '`comments`, '
. '`erga`, '
. '`projectdescription` '
. ' FROM `univ` '
. ' ORDER BY id';
$volunteer_institutions = R::getAll($sql);
$volunteer_institutions = array_map(function ($row) {
if (($projects = preg_split('/###@@@###/msUu', $row['projectdescription'])) !== false) {
$projects_parts = array_map(function ($r) {
return preg_split('/_@@@_/msUu', $r);
}, $projects);
$projects_cnt = 0;
foreach ($projects_parts as $part) {
if (count($part) > $projects_cnt) {
$projects_cnt = count($part);
}
}
$recons = array_fill(0, $projects_cnt, '');
for ($i = 0; $i < $projects_cnt; $i++) {
$recons[$i] .= $projects_parts[0][$i] . "\r\n"
. (isset($projects_parts[1][$i]) ? $projects_parts[1][$i] : '') . "\r\n"
. (isset($projects_parts[2][$i]) ? $projects_parts[2][$i] : '');
$row['project' . $i] = $recons[$i];
}
$row['projectdescription'] = implode("\r\n--------------\r\n", $recons);
}
return $row;
}, $volunteer_institutions);
return $volunteer_institutions;
};
};
$c['csv_export_schools'] = function ($c) {
return function () {
......@@ -347,7 +503,6 @@ return function (App $app) {
$appForms = R::getAll($sql, $appFormIds);
return $appForms;
};
};
......@@ -392,7 +547,7 @@ return function (App $app) {
$c['csv_export_appforms_items'] = function ($c) {
return function () use ($c){
return function () use ($c) {
$settings = $c->get('settings');
$version = $settings['application_form']['itemcategory']['currentversion'];
......@@ -487,13 +642,22 @@ return function (App $app) {
return $appForms;
};
};
});
$events('on', 'app.bootstrap', function (App $app, Container $c) {
$app->get('/export/csv/edulabs_{type}.csv', function (Request $req, Response $res, array $args) use ($c) {
$type = $args['type'];
$role = call_user_func($c['current_role']);
if (in_array($type, $c['csv_export_protected_exports'])) {
if ($role !== 'admin') {
$res = $res->withStatus(403);
$res->getBody()->write('Forbidden. The information requested in not available.');
return $res;
}
}
try {
$config = $c['csv_export_config'];
......
......@@ -13,61 +13,61 @@
$("#select_school").autocomplete({
source: window.location.protocol + "//" + window.location.host + "/teacher-form/mm",
minLength: 4,
select: function(event, ui) {
select: function (event, ui) {
console.log(ui);
$("#mm_id").val(ui.item.mm_id);
$("#el-school").val(ui.item.value);
$("#el-schooltelef").val(ui.item.tel);
},
html: false,
open: function(event, ui) {
open: function (event, ui) {
$(".ui-autocomplete").css("z-index", 1000);
}
});
}(window.jQuery, _, window.EDULABS.utils));
$(document).ready(function() {
$(document).ready(function () {
var max_fields = 10; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
$(add_button).click(function (e) { //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
if (x < max_fields) { //max input box allowed
x++; //text box increment
$(wrapper).append('<div><div><label for="projects">Σχετική δράση που συμμετείχατε </label><input type="text" name="projects" id="projects"></div> <div><label for="urlproject">URL δράσης που συμμετείχατε</label><input type="text" name="urlproject" id="urlproject"></div> <div><label for "commentproject">Περιγραφή δράσης που συμμετείχατε</label><input type="text" name="commentsproject" id="commentproject"></div><a href="#" class="remove_field">Διαγραφή</a></div>');
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
$(wrapper).on("click", ".remove_field", function (e) { //user click on remove text
e.preventDefault();
$(this).parent('div').remove(); x--;
})
$(this).parent('div').remove();
x--;
});
$("#submit").click(function(){
$("#submit").click(function () {
var projects = $("input[id='projects']")
.map(function(){return $(this).val();}).get();
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var urlproject = $("input[id='urlproject']")
.map(function(){return $(this).val();}).get();
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var commentproject = $("input[id='commentproject']")
.map(function(){return $(this).val();}).get();
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var newfield = projects+"#"+urlproject+"#"+commentproject;
var newfield = projects + "###@@@###" + urlproject + "###@@@###" + commentproject;
$('#projectdescription').val(newfield);
})
});
});
......@@ -89,7 +89,5 @@ input[type=text] {
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script>
<script src="{{ base_url }}/js/jquery-ui.autoc.min.js"></script>
<script src="{{ base_url() }}/js/teacher_form/index.js"></script>
<script src="{{ base_url() }}/js/teacher_form/index-1.1.js"></script>
{% endblock %}
This diff is collapsed.
......@@ -101,7 +101,7 @@ input[type=text] {
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script>
<script src="{{ base_url() }}/js/jquery-3.1.1.min.js"></script>
<script src="{{ base_url() }}/js/university_form/index.js"></script>
<script src="{{ base_url() }}/js/university_form/index-1.1.js"></script>
<script type="text/javascript">
</script>
......
(function ($, _, utils) {
'use strict';
(function () {
var form = $('#app-form form');
var messages = form.data('messages');
utils.formMessages.render(form, messages);
}());
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
$("#select_school").autocomplete({
source: window.location.protocol + "//" + window.location.host + "/teacher-form/mm",
minLength: 4,
select: function (event, ui) {
console.log(ui);
$("#mm_id").val(ui.item.mm_id);
$("#el-school").val(ui.item.value);
$("#el-schooltelef").val(ui.item.tel);
},
html: false,
open: function (event, ui) {
$(".ui-autocomplete").css("z-index", 1000);
}
});
}(window.jQuery, _, window.EDULABS.utils));
$(document).ready(function () {
var max_fields = 10; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function (e) { //on add input button click
e.preventDefault();
if (x < max_fields) { //max input box allowed
x++; //text box increment
$(wrapper).append('<div><div><label for="projects">Σχετική δράση που συμμετείχατε </label><input type="text" name="projects" id="projects"></div> <div><label for="urlproject">URL δράσης που συμμετείχατε</label><input type="text" name="urlproject" id="urlproject"></div> <div><label for "commentproject">Περιγραφή δράσης που συμμετείχατε</label><input type="text" name="commentsproject" id="commentproject"></div><a href="#" class="remove_field">Διαγραφή</a></div>');
}
});
$(wrapper).on("click", ".remove_field", function (e) { //user click on remove text
e.preventDefault();
$(this).parent('div').remove();
x--;
});
$("#submit").click(function () {
var projects = $("input[id='projects']")
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var urlproject = $("input[id='urlproject']")
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var commentproject = $("input[id='commentproject']")
.map(function () {
return $(this).val();
}).get().join("_@@@_");
var newfield = projects + "###@@@###" + urlproject + "###@@@###" + commentproject;
$('#projectdescription').val(newfield);
});
});
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment