View forms data on site

parent 7a013e01
...@@ -48,6 +48,8 @@ return [ ...@@ -48,6 +48,8 @@ return [
['/teacher-form/submit-success',['guest'], ['get','post']], ['/teacher-form/submit-success',['guest'], ['get','post']],
['/teacher-form/mm',['guest'], ['get']], ['/teacher-form/mm',['guest'], ['get']],
['/admin', ['admin'], ['get']], ['/admin', ['admin'], ['get']],
['/admin/university-form/display', ['admin'], ['get']],
['/admin/teacher-form/display', ['admin'], ['get']],
], ],
], ],
], ],
......
...@@ -16,11 +16,17 @@ ...@@ -16,11 +16,17 @@
<tbody> <tbody>
<tr> <tr>
<td>Καταχωρημένες αιτήσεις εθελοντών - Εκπαιδευτικοί</td> <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> <td class="text-right">
<a class="btn btn-primary btn-sm" href="{{ path_for('export.csv', {type: 'volunteer_teachers'}) }}"><i class="fa fa-download"></i> Αρχείο .csv</a>
<a class="btn btn-default btn-sm" href="{{ path_for('admin.volunteer.teacher') }}"><span class="fa fa-list"></span> Προβολή</a>
</td>
</tr> </tr>
<tr> <tr>
<td>Καταχωρημένες αιτήσεις εθελοντών - Ιδρύματα</td> <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> <td class="text-right">
<a class="btn btn-primary btn-sm" href="{{ path_for('export.csv', {type: 'volunteer_institutions'}) }}"><span class="fa fa-download"></span> Αρχείο .csv</a>
<a class="btn btn-default btn-sm" href="{{ path_for('admin.volunteer.univ') }}"><span class="fa fa-list"></span> Προβολή</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -7,6 +7,7 @@ use Slim\App; ...@@ -7,6 +7,7 @@ use Slim\App;
use Slim\Container; use Slim\Container;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
use GrEduLabs\UniversityForm\Service\UniversityFormService;
/** /**
* gredu_labs. * gredu_labs.
...@@ -153,6 +154,7 @@ return function (App $app) { ...@@ -153,6 +154,7 @@ return function (App $app) {
'Όνομα', 'Όνομα',
'Επώνυμο', 'Επώνυμο',
'Ειδικότητα', 'Ειδικότητα',
'Ειδικότητα (λεκτικό)',
'Αριθμός Μητρώου', 'Αριθμός Μητρώου',
'Τηλέφωνο', 'Τηλέφωνο',
'Email', 'Email',
...@@ -242,43 +244,32 @@ return function (App $app) { ...@@ -242,43 +244,32 @@ return function (App $app) {
$c['csv_export_volunteer_teachers'] = function ($c) { $c['csv_export_volunteer_teachers'] = function ($c) {
return function () { return function () {
$sql = 'SELECT `id`, ' $sql = 'SELECT `volunteerteachers`.`id`, '
. '`name`, ' . '`volunteerteachers`.`name`, '
. '`surname`, ' . '`volunteerteachers`.`surname`, '
. '`eidikothta`, ' . '`volunteerteachers`.`eidikothta`, '
. '`arithmitroou`, ' . '`branch`.`name` AS `eidikothta_name`, '
. '`telef`, ' . '`volunteerteachers`.`arithmitroou`, '
. '`email`, ' . '`volunteerteachers`.`telef`, '
. '`school`, ' . '`volunteerteachers`.`email`, '
. '`schooltelef`, ' . '`volunteerteachers`.`school`, '
. '`comments`, ' . '`volunteerteachers`.`schooltelef`, '
. '`projecttitle`, ' . '`volunteerteachers`.`comments`, '
. '`projecturl`, ' . '`volunteerteachers`.`projecttitle`, '
. '`projectdescription` ' . '`volunteerteachers`.`projecturl`, '
. ' FROM `volunteerteachers` ' . '`volunteerteachers`.`projectdescription` '
. ' FROM `volunteerteachers` JOIN `branch` ON (`volunteerteachers`.`eidikothta` = `branch`.`id`) '
// . ' FROM `volunteerteachers` '
. ' ORDER BY id '; . ' ORDER BY id ';
$volunteer_teachers = R::getAll($sql); $volunteer_teachers = R::getAll($sql);
$volunteer_teachers = array_map(function ($row) { $volunteer_teachers = array_map(function ($row) {
if (($projects = preg_split('/###@@@###/msUu', $row['projectdescription'])) !== false) { $row['projectdescription'] = UniversityFormService::recomposeProjects($row['projectdescription'], false);
$projects_parts = array_map(function ($r) { if (($projects = preg_split('/' . UniversityFormService::PLAIN_TEXT_SEPARATOR . '/msUu', $row['projectdescription'])) !== false) {
return preg_split('/_@@@_/msUu', $r); foreach ($projects as $i => $proj) {
}, $projects); $row["project{$i}"] = $proj;
$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; return $row;
}, $volunteer_teachers); }, $volunteer_teachers);
...@@ -309,24 +300,11 @@ return function (App $app) { ...@@ -309,24 +300,11 @@ return function (App $app) {
$volunteer_institutions = R::getAll($sql); $volunteer_institutions = R::getAll($sql);
$volunteer_institutions = array_map(function ($row) { $volunteer_institutions = array_map(function ($row) {
if (($projects = preg_split('/###@@@###/msUu', $row['projectdescription'])) !== false) { $row['projectdescription'] = UniversityFormService::recomposeProjects($row['projectdescription'], false);
$projects_parts = array_map(function ($r) { if (($projects = preg_split('/' . UniversityFormService::PLAIN_TEXT_SEPARATOR . '/msUu', $row['projectdescription'])) !== false) {
return preg_split('/_@@@_/msUu', $r); foreach ($projects as $i => $proj) {
}, $projects); $row["project{$i}"] = $proj;
$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; return $row;
}, $volunteer_institutions); }, $volunteer_institutions);
......
...@@ -12,10 +12,9 @@ use Slim\Http\Response; ...@@ -12,10 +12,9 @@ use Slim\Http\Response;
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
return function (App $app) { return function (App $app) {
$container = $app->getContainer(); $container = $app->getContainer();
$events = $container['events']; $events = $container['events'];
$events('on', 'app.autoload', function ($autoloader) { $events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\TeacherForm\\', __DIR__ . '/src/'); $autoloader->addPsr4('GrEduLabs\\TeacherForm\\', __DIR__ . '/src/');
...@@ -33,17 +32,22 @@ return function (App $app) { ...@@ -33,17 +32,22 @@ return function (App $app) {
$container[GrEduLabs\TeacherForm\Action\TeacherForm::class] = function ($c) { $container[GrEduLabs\TeacherForm\Action\TeacherForm::class] = function ($c) {
return new GrEduLabs\TeacherForm\Action\TeacherForm( return new GrEduLabs\TeacherForm\Action\TeacherForm(
$c->get('view'), $c->get('view'), $c->get(GrEduLabs\TeacherForm\Service\TeacherFormServiceInterface::class), $c->get(GrEduLabs\TeacherForm\InputFilter\TeacherForm::class), $c->get('router')->pathFor('teacher_form.submit_success'), $c);
$c->get(GrEduLabs\TeacherForm\Service\TeacherFormServiceInterface::class),
$c->get(GrEduLabs\TeacherForm\InputFilter\TeacherForm::class),
$c->get('router')->pathFor('teacher_form.submit_success'),
$c);
}; };
$container[GrEduLabs\TeacherForm\Action\SubmitSuccess::class] = function ($c) { $container[GrEduLabs\TeacherForm\Action\SubmitSuccess::class] = function ($c) {
return new GrEduLabs\TeacherForm\Action\SubmitSuccess( return new GrEduLabs\TeacherForm\Action\SubmitSuccess(
$c->get('view'), $c->get('view'), $c->get('router')->pathFor('teacher_form')
$c->get('router')->pathFor('teacher_form') );
};
$container[GrEduLabs\TeacherForm\Service\TeacherFormServiceInterface::class] = function ($c) {
return new GrEduLabs\TeacherForm\Service\TeacherFormService();
};
$container[GrEduLabs\TeacherForm\Action\Display::class] = function ($c) {
return new GrEduLabs\TeacherForm\Action\Display(
$c->get('view'), $c->get(GrEduLabs\TeacherForm\Service\TeacherFormServiceInterface::class)
); );
}; };
}); });
...@@ -64,12 +68,12 @@ return function (App $app) { ...@@ -64,12 +68,12 @@ return function (App $app) {
$school_name = $req->getQueryParam('term'); $school_name = $req->getQueryParam('term');
$httpClient = new GuzzleHttp\Client([ $httpClient = new GuzzleHttp\Client([
'base_uri' => $container['settings']['sch_mm']['public_api_url'] 'base_uri' => $container['settings']['sch_mm']['public_api_url']
]); ]);
$config = $httpClient->getConfig(); $config = $httpClient->getConfig();
$baseUri = $config['base_uri']; $baseUri = $config['base_uri'];
$url = $baseUri . "?name=" . $school_name; $url = $baseUri . "?name=" . $school_name;
$response = $httpClient->request('GET', $url); $response = $httpClient->request('GET', $url);
$responseData = json_decode($response->getBody()->getContents(), true); $responseData = json_decode($response->getBody()->getContents(), true);
...@@ -78,7 +82,7 @@ return function (App $app) { ...@@ -78,7 +82,7 @@ return function (App $app) {
} }
$cnt = count($responseData['data']); $cnt = count($responseData['data']);
$school_arr = []; $school_arr = [];
for ($i=0; $i<$cnt; $i++) { for ($i = 0; $i < $cnt; $i++) {
$school_arr[$i]['mm_id'] = $responseData['data'][$i]['mm_id']; $school_arr[$i]['mm_id'] = $responseData['data'][$i]['mm_id'];
$school_arr[$i]['value'] = $responseData['data'][$i]['name']; $school_arr[$i]['value'] = $responseData['data'][$i]['name'];
$school_arr[$i]['tel'] = $responseData['data'][$i]['phone_number']; $school_arr[$i]['tel'] = $responseData['data'][$i]['phone_number'];
...@@ -86,5 +90,8 @@ return function (App $app) { ...@@ -86,5 +90,8 @@ return function (App $app) {
return $res->withJson($school_arr); return $res->withJson($school_arr);
})->setName('teacher_form.mm'); })->setName('teacher_form.mm');
$app->get('/admin/teacher-form/display', GrEduLabs\TeacherForm\Action\Display::class)
->setName('admin.volunteer.teacher');
}); });
}; };
ALTER TABLE `volunteerteachers` MODIFY `eidikothta` int(11) UNSIGNED;
ALTER TABLE `volunteerteachers` ADD CONSTRAINT `fk_branch_id` FOREIGN KEY (`eidikothta`) REFERENCES `branch`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\TeacherForm\Action;
use GrEduLabs\TeacherForm\Service\TeacherFormServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class Display
{
/**
* @var Twig
*/
protected $view;
/**
* @var FormServiceInterface
*/
protected $formService;
public function __construct(Twig $view, TeacherFormServiceInterface $formService)
{
$this->view = $view;
$this->formService = $formService;
}
public function __invoke(Request $req, Response $res)
{
$forms = $this->formService->findAll();
return $this->view->render($res, 'teacher_form/display.twig', [
'forms' => $forms
]);
}
}
...@@ -8,24 +8,28 @@ ...@@ -8,24 +8,28 @@
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
namespace GrEduLabs\TeacherForm\Service; namespace GrEduLabs\TeacherForm\Service;
use RedBeanPHP\OODBBean; use RedBeanPHP\OODBBean;
use RedBeanPHP\R; use RedBeanPHP\R;
use GrEduLabs\UniversityForm\Service\UniversityFormService;
class TeacherFormService implements TeacherFormServiceInterface class TeacherFormService implements TeacherFormServiceInterface
{ {
public function submit(array $data) public function submit(array $data)
{ {
$appForm = R::dispense('volunteerteachers'); $appForm = R::dispense('volunteerteachers');
// $appForm->id = $data['id']; // $appForm->id = $data['id'];
$appForm->name = $data['name']; $appForm->name = $data['name'];
$appForm->surname = $data['surname']; $appForm->surname = $data['surname'];
$appForm->eidikothta = $data['eidikothta']; $appForm->eidikothta = $data['eidikothta'];
$appForm->arithmitroou = $data['arithmitroou']; $appForm->arithmitroou = $data['arithmitroou'];
$appForm->email = $data['email']; $appForm->email = $data['email'];
$appForm->telef = trim($data['telef']); $appForm->telef = trim($data['telef']);
$appForm->school = $data['school']; $appForm->school = $data['school'];
$appForm->schooltelef = trim($data['schooltelef']); $appForm->schooltelef = trim($data['schooltelef']);
$appForm->projectdescription = $data['projectdescription']; $appForm->projectdescription = $data['projectdescription'];
$appForm->comments = $data['comments']; $appForm->comments = $data['comments'];
R::store($appForm); R::store($appForm);
return $appForm; return $appForm;
} }
...@@ -36,4 +40,35 @@ class TeacherFormService implements TeacherFormServiceInterface ...@@ -36,4 +40,35 @@ class TeacherFormService implements TeacherFormServiceInterface
return $branch->export(); return $branch->export();
}, R::findAll('branch', 'ORDER BY name ASC')); }, R::findAll('branch', 'ORDER BY name ASC'));
} }
/**
*
* @param OODBBean $bean the form bean
* @return array
*/
private function exportApplicationForm(OODBBean $bean)
{
$form = $bean->export();
$form['projectdescription'] = UniversityFormService::recomposeProjects($form['projectdescription']);
return $form;
}
/**
* Get all the university volunteer submissions
*
* @return array The exported bean info from retrieved data
*/
public function findAll()
{
$forms = R::getAll('SELECT `volunteerteachers`.*, `branch`.`name` AS `eidikothta_name` '
. 'FROM `volunteerteachers` JOIN `branch` ON (`volunteerteachers`.`eidikothta` = `branch`.`id`) '
. 'ORDER BY `id` DESC');
$beanForms = R::convertToBeans('volunteerteachers', $forms);
return array_map(function ($form) {
return $this->exportApplicationForm($form);
}, $beanForms);
}
} }
...@@ -7,11 +7,17 @@ ...@@ -7,11 +7,17 @@
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
namespace GrEduLabs\TeacherForm\Service; namespace GrEduLabs\TeacherForm\Service;
interface TeacherFormServiceInterface interface TeacherFormServiceInterface
{ {
public function submit(array $data); public function submit(array $data);
public function getBranches(); public function getBranches();
/**
* Gets all forms and return an array of data
*/
public function findAll();
} }
{% extends "layout.twig" %}
{% block content %}
<div id="approved_applications">
<h1>Ιδρύματα <small>Αιτήσεις εκπαιδευτικών</small></h1>
<p>Ακολουθεί λίστα των αιτήσεων που κατατέθηκαν από εκπαιδευτικούς.</p>
{% if forms %}
<div class="table-responsive">
<caption>Συνολικά <span class="label label-success">{{ forms | length }} αιτήσεις</span>
<span class="pull-right">
<a class="btn btn-primary btn-sm" href="{{ path_for('export.csv', {type: 'volunteer_teachers'}) }}"><span class="fa fa-download"></span> Αρχείο .csv</a>
</span>
</caption>
<table class="table table-condensed table-hover">
<thead>
<tr>
<th class="text-center">ID</th>
<th>Ονοματεπώνυμο<br/>
<span class="text-muted">Αριθμός μητρώου, Ειδικότητα</span></th>
<th>Σχολείο <span class="text-muted">Τηλέφωνο</span></th>
<th>Τηλέφωνο</th>
<th>Email</th>
</tr>
</thead>
<tbody>
{% for form in forms %}
<tr>
<td class="text-center col-xs-1"><span class="text-muted">{{ form.id }}</span></td>
<td class="col-xs-4">{{ form.name }} {{ form.surname }}<br/>
<span class="text-muted">{{ form.arithmitroou }}, {{ form.eidikothta_name }}</span></td>
<td class="col-xs-4">{{ form.school }} <span class="text-muted">{{ form.schooltelef }}</span></td>
<td class="col-xs-1">{{ form.telef }}</td>
<td class="col-xs-2">{{ form.email }}</td>
</tr>
<tr>
<td></td>
<td colspan="4"><span class="text-muted">ΣΧΟΛΙΑ:</span> {{ form.comments }}<br/>
<span class="text-muted">ΕΡΓΑ:</span> {{ form.projectdescription|raw }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info" role="alert">Δεν υπάρχουν καταχωρημένα στοιχεία</div>
{% endif %}
</div>
{% endblock %}
...@@ -13,16 +13,15 @@ use Slim\Http\Response; ...@@ -13,16 +13,15 @@ use Slim\Http\Response;
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
return function (App $app) { return function (App $app) {
$container = $app->getContainer(); $container = $app->getContainer();
$events = $container['events']; $events = $container['events'];
$events('on', 'app.autoload', function ($autoloader) { $events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\UniversityForm\\', __DIR__ . '/src/'); $autoloader->addPsr4('GrEduLabs\\UniversityForm\\', __DIR__ . '/src/');
}); });
$events('on', 'app.services', function ($container) { $events('on', 'app.services', function ($container) {
$container[GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class] = function ($c) { $container[GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class] = function ($c) {
return new GrEduLabs\UniversityForm\Service\UniversityFormService(); return new GrEduLabs\UniversityForm\Service\UniversityFormService();
...@@ -36,40 +35,40 @@ $events('on', 'app.services', function ($container) { ...@@ -36,40 +35,40 @@ $events('on', 'app.services', function ($container) {
return new GrEduLabs\UniversityForm\InputFilter\UniversityForm1(); return new GrEduLabs\UniversityForm\InputFilter\UniversityForm1();
}; };
$container[GrEduLabs\UniversityForm\Action\UniversityForm::class] = function ($c) { $container[GrEduLabs\UniversityForm\Action\UniversityForm::class] = function ($c) {
return new GrEduLabs\UniversityForm\Action\UniversityForm( return new GrEduLabs\UniversityForm\Action\UniversityForm(
$c->get('view'), $c->get('view'), $c->get(GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class), $c->get(GrEduLabs\UniversityForm\InputFilter\UniversityForm::class), $c->get(GrEduLabs\UniversityForm\InputFilter\UniversityForm1::class), $c->get('router')->pathFor('university_form.submit_success'), $c);
$c->get(GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class),
$c->get(GrEduLabs\UniversityForm\InputFilter\UniversityForm::class),
$c->get(GrEduLabs\UniversityForm\InputFilter\UniversityForm1::class),
$c->get('router')->pathFor('university_form.submit_success'),
$c);
}; };
$container[GrEduLabs\UniversityForm\Action\SubmitSuccess::class] = function ($c) { $container[GrEduLabs\UniversityForm\Action\SubmitSuccess::class] = function ($c) {
return new GrEduLabs\UniversityForm\Action\SubmitSuccess( return new GrEduLabs\UniversityForm\Action\SubmitSuccess(
$c->get('view'), $c->get('view'), $c->get('router')->pathFor('university_form')
$c->get('router')->pathFor('university_form')
); );
}; };
}); $container[GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class] = function ($c) {
return new GrEduLabs\UniversityForm\Service\UniversityFormService();
};
$container[GrEduLabs\UniversityForm\Action\Display::class] = function ($c) {
return new GrEduLabs\UniversityForm\Action\Display(
$c->get('view'), $c->get(GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface::class)
);
};
});
$events('on', 'app.bootstrap', function ($app, $container) { $events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates'); $container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$app->group('/university-form', function () { $app->group('/university-form', function () {
$this->map(['get', 'post'], '', GrEduLabs\UniversityForm\Action\UniversityForm::class) $this->map(['get', 'post'], '', GrEduLabs\UniversityForm\Action\UniversityForm::class)
->add(GrEduLabs\Application\Middleware\AddCsrfToView::class) ->add(GrEduLabs\Application\Middleware\AddCsrfToView::class)
->add('csrf') ->add('csrf')
->setName('university_form'); ->setName('university_form');
$this->get('/submit-success', GrEduLabs\UniversityForm\Action\SubmitSuccess::class) $this->get('/submit-success', GrEduLabs\UniversityForm\Action\SubmitSuccess::class)
->setName('university_form.submit_success'); ->setName('university_form.submit_success');
});
}); $app->get('/admin/university-form/display', GrEduLabs\UniversityForm\Action\Display::class)
->setName('admin.volunteer.univ');
}); });
};
};
\ No newline at end of file
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\UniversityForm\Action;
use GrEduLabs\UniversityForm\Service\UniversityFormServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class Display
{
/**
* @var Twig
*/
protected $view;
/**
* @var FormServiceInterface
*/
protected $formService;
public function __construct(Twig $view, UniversityFormServiceInterface $formService)
{
$this->view = $view;
$this->formService = $formService;
}
public function __invoke(Request $req, Response $res)
{
$forms = $this->formService->findAll();
return $this->view->render($res, 'university_form/display.twig', [
'forms' => $forms
]);
}
}
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/) * @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html * @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/ */
namespace GrEduLabs\UniversityForm\Service; namespace GrEduLabs\UniversityForm\Service;
use RedBeanPHP\OODBBean; use RedBeanPHP\OODBBean;
...@@ -15,28 +14,93 @@ use RedBeanPHP\R; ...@@ -15,28 +14,93 @@ use RedBeanPHP\R;
class UniversityFormService implements UniversityFormServiceInterface class UniversityFormService implements UniversityFormServiceInterface
{ {
const PLAIN_TEXT_SEPARATOR = ' ---------------NEXT_PROJECT--------------- ';
public function submit(array $data) public function submit(array $data)
{ {
$appForm = R::dispense('univ');
$appForm->id = $data['id'];
$appForm->idrima = $data['idrima'];
$appForm->sxolh = $data['sxolh'];
$appForm->tmhma = $data['tmhma'];
$appForm->ereunitiko = $data['ereunitiko'];
$appForm->institute = $data['institute'];
$appForm->other = $data['other'];
$appForm->erga = $data['erga'];
$appForm->person = $data['person'];
$appForm->telef = trim($data['telef']);
$appForm->email = $data['email'];
$appForm->projectdescription = $data['projectdescription'];
$appForm->comments = $data['comments'];
$appForm = R::dispense('univ'); R::store($appForm);
$appForm->id = $data['id'];
$appForm->idrima = $data['idrima'];
$appForm->sxolh = $data['sxolh'];
$appForm->tmhma = $data['tmhma'];
$appForm->ereunitiko = $data['ereunitiko'];
$appForm->institute = $data['institute'];
$appForm->other = $data['other'];
$appForm->erga = $data['erga'];
$appForm->person = $data['person'];
$appForm->telef = trim($data['telef']);
$appForm->email = $data['email'];
$appForm->projectdescription = $data['projectdescription'];
$appForm->comments = $data['comments'];
R::store($appForm);
return $appForm; return $appForm;
}
public static function recomposeProjects($data, $html = true)
{
$recons = [];
if (($projects = preg_split('/###@@@###/msUu', $data)) !== 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);