Merge branch 'app-form-receive-confirm' into 'master'

Form to receive equipment and confirm

See merge request !16
parents 658d9c20 027f4aea
<?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/)
......@@ -20,6 +20,7 @@ return [
'module/sch_sync/bootstrap.php',
'module/schools/bootstrap.php',
'module/application_form/bootstrap.php',
'module/receive_equip/bootstrap.php',
'module/tpe_survey/bootstrap.php',
'module/in_numbers/bootstrap.php',
'module/in_numbers_mm/bootstrap.php',
......
<?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
......@@ -32,6 +32,10 @@ return [
['/application-form', ['school'], ['get', 'post']],
['/application-form/submit-success', ['school'], ['get']],
['/application-form/report', ['school'], ['get']],
['/receive-equip', ['school'], ['get', 'post'], GrEduLabs\ReceiveEquip\Acl\Assertion\CanSubmit::class],
['/receive-equip/submit-success', ['school'], ['get']],
['/receive-equip/report', ['school'], ['get']],
['/receive-equip/receive-doc/{fn}', ['school'], ['get']],
['/tpe_survey', ['school'], ['get', 'post']],
['/tpe_survey/total-teachers', ['school'], ['post']],
['/forum', ['guest', 'user'], ['get']],
......@@ -39,6 +43,7 @@ return [
['/in_numbers', ['guest', 'user'], ['get']],
['/export/csv/edulabs_{type}.csv', ['guest', 'user'], ['get']],
['/open-data', ['guest', 'user'], ['get']],
['/receive-equip/undo-submit/{applicationform_id}', ['school'], ['get']], // only for tests. Must be removed
],
],
],
......
<?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/)
......@@ -51,6 +51,10 @@ return [
'label' => 'Αίτηση',
'route' => 'application_form',
],
'receive-equip' => [
'label' => 'Παραλαβή εξοπλισμού',
'route' => 'receive_equip',
],
'open-data' => [
'label' => 'Ανοικτά δεδομένα',
'route' => 'open_data',
......
<?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
*/
return [
'receive_equip' => [
'file_upload_path' => __DIR__ . '/../../data/uploads', // path to save file
'file_upload_max_size' => 3145728, // Maximum number of bytes allowed(default 3MB)
'file_upload_types_permitted' => ['jpg', 'jpeg', 'pdf', 'png'], // Array of allowed extensions
],
];
......@@ -22,12 +22,16 @@ CREATE TABLE `applicationform` (
`comments` text COLLATE utf8mb4_unicode_ci,
`submitted` int(11) unsigned NOT NULL,
`submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`received_ts` timestamp NULL,
`received_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`received_document` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
PRIMARY KEY (`id`),
KEY `index_foreignkey_applicationform_school` (`school_id`),
CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
--
-- Dumping data for table `applicationform`
--
......@@ -49,6 +53,7 @@ CREATE TABLE `applicationformitem` (
`itemcategory_id` int(11) unsigned NOT NULL,
`qty` int(11) unsigned NOT NULL,
`qtyacquired` int(11) unsigned NOT NULL DEFAULT 0,
`qtyreceived` int(11) unsigned DEFAULT 0,
`reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`applicationform_id` int(11) unsigned NOT NULL,
`lab_id` int(11) unsigned NOT NULL,
......@@ -172,7 +177,7 @@ CREATE TABLE `itemcategory` (
LOCK TABLES `itemcategory` WRITE;
/*!40000 ALTER TABLE `itemcategory` DISABLE KEYS */;
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(8,'ACCESS POINT',0,8),
(26,'ΦΟΡΗΤΟΣ Η/Υ (LAPTOP)',0,26),
(6,'MODEM / ROUTER ',0,6),
......@@ -196,7 +201,7 @@ INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(43,'ΤΡΙΣΔΙΑΣΤΑΤΟΣ ΣΑΡΩΤΗΣ',0,43),
(44,'ΣΕΤ ΡΟΜΠΟΤΙΚΗΣ - ΑΙΣΘΗΤΗΡΩΝ',0,44),
(45,'ΔΟΜΗΜΕΝΗ ΚΑΛΩΔΙΩΣΗ',0,45);
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
INSERT INTO `itemcategory` (`id`,`name`,`groupflag`,`sort`) VALUES
(101,'ΣΤΑΘΕΡΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (DESKTOP)', 1,1),
(102,'ΦΟΡΗΤΟΣ ΗΛΕΚΤΡΟΝΙΚΟΣ ΥΠΟΛΟΓΙΣΤΗΣ (LAPTOP)', 1,2),
(103,'ΕΠΙΤΡΑΠΕΖΙΟΣ ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ (SHORT THROW PROJECTOR)', 1,3),
......@@ -280,7 +285,7 @@ CREATE TABLE `lab_lesson` (
UNIQUE KEY `UQ_82ac3a020f1d21984f224331fbd99880f89b2e71` (`lab_id`,`lesson_id`),
KEY `index_foreignkey_lab_lesson_lesson` (`lesson_id`),
KEY `index_foreignkey_lab_lesson_lab` (`lab_id`),
CONSTRAINT `c_fk_lab_lesson_lesson_id` FOREIGN KEY (`lesson_id`) REFERENCES `lesson` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `c_fk_lab_lesson_lesson_id` FOREIGN KEY (`lesson_id`) REFERENCES `lesson` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `c_fk_lab_lesson_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
......
ALTER TABLE `applicationformitem`
DROP COLUMN `qtyreceived` ;
ALTER TABLE `applicationform`
DROP COLUMN `received_ts` ;
ALTER TABLE `applicationform`
DROP COLUMN `received_by` ;
ALTER TABLE applicationform DROP INDEX `index_applicationform_submitted`;
ALTER TABLE `applicationformitem`
ADD COLUMN `qtyreceived` int(11) unsigned NOT NULL DEFAULT 0
AFTER `qtyacquired` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_ts` timestamp NULL
AFTER `submitted_by` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
AFTER `received_ts` ;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
ALTER TABLE `applicationform`
DROP COLUMN `received_document` ;
ALTER TABLE `applicationform`
ADD COLUMN `received_document` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''
AFTER `received_by` ;
......@@ -22,11 +22,16 @@ CREATE TABLE `applicationform` (
`comments` text COLLATE utf8mb4_unicode_ci,
`submitted` int(11) unsigned NOT NULL,
`submitted_by` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`received_ts` timestamp NULL,
`received_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`received_document` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
PRIMARY KEY (`id`),
KEY `index_foreignkey_applicationform_school` (`school_id`),
CONSTRAINT `c_fk_applicationform_school_id` FOREIGN KEY (`school_id`) REFERENCES `school` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
CREATE INDEX `index_applicationform_submitted` ON `applicationform`(`submitted`);
CREATE INDEX `index_applicationform_received_ts` ON `applicationform`(`received_ts`);
--
-- Dumping data for table `applicationform`
......@@ -49,6 +54,7 @@ CREATE TABLE `applicationformitem` (
`itemcategory_id` int(11) unsigned NOT NULL,
`qty` int(11) unsigned NOT NULL,
`qtyacquired` int(11) unsigned DEFAULT 0,
`qtyreceived` int(11) unsigned DEFAULT 0,
`reasons` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`applicationform_id` int(11) unsigned NOT NULL,
`lab_id` int(11) unsigned NOT NULL,
......@@ -61,7 +67,6 @@ CREATE TABLE `applicationformitem` (
CONSTRAINT `c_fk_applicationformitem_lab_id` FOREIGN KEY (`lab_id`) REFERENCES `lab` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `applicationformitem`
--
......@@ -78,4 +83,4 @@ UNLOCK TABLES;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
\ No newline at end of file
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
<?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/)
......@@ -42,7 +42,7 @@ class Login
/**
*
*
* @param Twig $view
* @param AuthenticationService $authService
* @param Messages $flash
......
<?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
*/
use Slim\Http\Request;
use Slim\Http\Response;
use RedBeanPHP\R;
return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\ReceiveEquip\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($container) {
$container[GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\Service\ReceiveEquipService($c['logger']);
};
$container[GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquip::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquip(
$c->get(GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItemCollection::class)
);
};
$container[GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItem::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItem(
);
};
$container[GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItemCollection::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItemCollection(
$c->get(GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquipItem::class)
);
};
$container[GrEduLabs\ReceiveEquip\Action\ReceiveEquip::class] = function ($c) {
$settings = $c->get('settings');
return new GrEduLabs\ReceiveEquip\Action\ReceiveEquip(
$c->get('view'),
$c->get(GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface::class),
$c->get(GrEduLabs\ReceiveEquip\InputFilter\ReceiveEquip::class),
$c->get('authentication_service'),
$c->get('router')->pathFor('receive_equip.submit_success'),
$c
);
};
$container[GrEduLabs\ReceiveEquip\Action\SubmitSuccess::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\Action\SubmitSuccess(
$c->get('view'),
$c->get('router')->pathFor('receive_equip')
);
};
$container[GrEduLabs\ReceiveEquip\Action\ReceiveEquipPdf::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\Action\ReceiveEquipPdf(
$c->get(GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface::class),
$c->get('view')
);
};
$container[GrEduLabs\ReceiveEquip\Acl\Assertion\CanSubmit::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\Acl\Assertion\CanSubmit(
$c->get('authentication_service'),
$c->get(GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface::class)
);
};
});
$events('on', 'app.services', function ($container) {
$container[GrEduLabs\ReceiveEquip\Middleware\HandleEmptyPosts::class] = function ($c) {
return new GrEduLabs\ReceiveEquip\Middleware\HandleEmptyPosts(
$c->get('view'),
$c->get(GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface::class),
$c['flash'],
$c
);
};
}, -100000);
$events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$app->group('/receive-equip', function () {
$this->map(['get', 'post'], '', GrEduLabs\ReceiveEquip\Action\ReceiveEquip::class)
->add(GrEduLabs\Application\Middleware\AddCsrfToView::class)
->add('csrf')
->add(GrEduLabs\ReceiveEquip\Middleware\HandleEmptyPosts::class)
->setName('receive_equip');
$this->get('/submit-success', GrEduLabs\ReceiveEquip\Action\SubmitSuccess::class)
->setName('receive_equip.submit_success');
$this->get('/report', GrEduLabs\ReceiveEquip\Action\ReceiveEquipPdf::class)
->setName('receive_equip.report');
})->add(GrEduLabs\Schools\Middleware\FetchSchoolFromIdentity::class);
$app->get('/receive-equip/receive-doc/{fn}', function (Request $req, Response $res) use ($container) {
$route = $req->getAttribute('route');
$fn = $route->getArgument('fn');
/* $container["logger"]->info(sprintf('filename = %s url=%s', $fn, path_for('receive_equip.receive_doc', [
'fn' => form.values.received_document,])
)); */
$file = $container['settings']['receive_equip']['file_upload_path'] . "/" . $fn;
$response = $res->withHeader('Content-Description', 'File Transfer')
->withHeader('Content-Type', 'application/octet-stream')
->withHeader('Content-Disposition', 'attachment;filename="' . basename($file) . '"')
->withHeader('Expires', '0')
->withHeader('Cache-Control', 'must-revalidate')
->withHeader('Content-Length', filesize($file));
readfile($file);
return $response;
})->setName('receive_equip.receive_doc');
/******************* only for tests ***************************/
$app->get('/receive-equip/undo-submit/{applicationform_id}', function (Request $req, Response $res) use ($container) {
$route = $req->getAttribute('route');
$applicationform_id = $route->getArgument('applicationform_id');
$sql = 'update `applicationform` set `approved`=1, `received_ts`=null where `id`=' . $applicationform_id;
R::exec($sql);
return $res->withRedirect("/receive-equip");
})->setName('receive_equip.undosubmit');
/****************** /only for tests ***************************/
});
};
/**
* 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
*/
* {
font-family: 'DejaVu Sans', Arial;
font-size: 80%;
}
.header {
height: 150px;
}
.header img {
float: left;
width: 30%;
overflow: hidden;
clear: left;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
padding: 10px;
}
.header .h1 {
font-size: 200%;
text-align: right;
padding: 0;
}
.header.h1 a {
text-align: center;
text-decoration: none;
color: #555;
}
dl {
margin-top: 0;
margin-bottom: 20px;
}
dt,
dd {
line-height: 1.42857143;
}
dt {
font-weight: bold;
float: left;
width: 30%;
overflow: hidden;
clear: left;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
}
th {
text-align: left;
}
table {
width: 100%;
max-width: 100%;
margin-bottom: 20px;
}
table > thead > tr > th,
table > tbody > tr > th,
table > tfoot > tr > th,
table > thead > tr > td,
table > tbody > tr > td,
table > tfoot > tr > td {
padding: 8px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
}
table > thead > tr > th {
vertical-align: bottom;
border-bottom: 2px solid #ddd;
}
table > caption + thead > tr:first-child > th,
table > colgroup + thead > tr:first-child > th,
table > thead:first-child > tr:first-child > th,
table > caption + thead > tr:first-child > td,
table > colgroup + thead > tr:first-child > td,
table > thead:first-child > tr:first-child > td {
border-top: 0;
}
table > tbody + tbody {
border-top: 2px solid #ddd;
}
table table {
background-color: #fff;
}
table tbody > tr:nth-of-type(odd) {
background-color: #f9f9f9;
}
\ No newline at end of file
(function ($, _, utils) {
'use strict';
var ItemsView,
ItemRowView;
ItemRowView = Backbone.View.extend({
tagName: 'tr',
render: function (index) {
this.$el.html(this.template({ index: index | 0}));
return this;
},
template: _.template($('#receive-equip-item-row-template').html())
});
ItemsView = Backbone.View.extend({
el: '#items-list',
initialize: function () {
this.itemCount = this.$el.find('tbody tr').length;
},
});
new ItemsView();
(function () {
var form = $('#receive-equip form'),
messages = (function (messages) {
var itemMessages = {};
_.each(messages.items || [], function (message, idx){
var name = 'items[' + idx + ']';
_.each(_.keys(message), function (prop) {
itemMessages[name + '[' + prop + ']'] = message[prop];
});
});
delete messages.items;
_.extend(messages, itemMessages);
return messages;
}(form.data('messages')));
utils.formMessages.render(form, messages);
}());
}(window.jQuery, _, window.EDULABS.utils));
<?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\ReceiveEquip\Acl\Assertion;
use GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface;
use RedBeanPHP\R;
use Zend\Authentication\AuthenticationServiceInterface;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Assertion\AssertionInterface;
use Zend\Permissions\Acl\Resource\ResourceInterface;
use Zend\Permissions\Acl\Role\RoleInterface;
class CanSubmit implements AssertionInterface
{
/**
*
* @var AuthenticationServiceInterface
*/
protected $authService;
/**
*
* @var ReceiveEquipServiceInterface
*/
protected $receiveEquipService;
public function __construct(
AuthenticationServiceInterface $authService,
ReceiveEquipServiceInterface $receiveEquipService
) {
$this->authService = $authService;
$this->receiveEquipService = $receiveEquipService;
}
public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
{
$identity = $this->authService->getIdentity();
$user = R::load('user', $identity->id);
if (!($school = $user->school)) {
return false;
}
$receiveEquip = $this->receiveEquipService->findSchoolReceiveEquip($school->id);
return null !== $receiveEquip;
}
}
This diff is collapsed.
<?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\ReceiveEquip\Action;
use GrEduLabs\ReceiveEquip\Service\ReceiveEquipServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class ReceiveEquipPdf
{
/**
*
* @var ReceiveEquipServiceInterface
*/
protected $receiveEquipService;
/**
*
* @var Twig
*/
protected $view;
public function __construct(ReceiveEquipServiceInterface $receiveEquipService, Twig $view)
{
$this->receiveEquipService = $receiveEquipService;
$this->view = $view;
}
public function __invoke(Request $req, Response $res)
{
$school = $req->getAttribute('school');
$receiveEquip = $this->receiveEquipService->findSchoolReceiveEquip($school->id);
if (null === $receiveEquip) {
return $res->withStatus(404);
}
$html = $this->view->fetch('receive_equip/pdf.twig', [
'school' => $school,
'receiveEquip' => $receiveEquip,
'logo' => base64_encode(file_get_contents(__DIR__ . '/../../public/img/receive_equip/minedu_logo.jpg')),
'style' => file_get_contents(__DIR__ . '/../../public/css/receive_equip/pdf.css'),
]);
$pdf = new \Dompdf\Dompdf([
'default_paper_size' => 'A4',
'default_font' => 'DejaVu Sans',
'isHtml5ParserEnabled' => true,
'is_remote_enabled' => false,
]);
$pdf->loadHtml($html);
$pdf->render();
$filename = 'edulabs_receive_equip_' . $receiveEquip['id'] . '.pdf';
$str = $pdf->output();
$length = mb_strlen($str, '8bit');
return $res->withHeader('Cache-Control', 'private')
->withHeader('Content-type', 'application/pdf')
->withHeader('Content-Length', $length)
->withHeader('Content-Disposition', 'attachment; filename=' . $filename)
->withHeader('Accept-Ranges', $length)
->write($str);
}
}
<?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\ReceiveEquip\Action;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class SubmitSuccess
{
protected $view;
protected $formUrl;
public function __construct(Twig $view, $formUrl)
{
$this->view = $view;
$this->formUrl = $formUrl;
}
public function __invoke(Request $req, Response $res)
{
$school = $req->getAttribute('school');
if (!isset($_SESSION['receiveEquipForm']['receiveEquip'])) {
$res = $res->withRedirect($this->formUrl);
return $res;
}
$receiveEquip = $_SESSION['receiveEquipForm']['receiveEquip'];
$_SESSION['receiveEquipForm']['receiveEquip'] = null;
unset($_SESSION['receiveEquipForm']['receiveEquip']);
return $this->view->render($res, 'receive_equip/submit_success.twig', [
'school' => $school,
'receiveEquip' => $receiveEquip,
]);
}
}
<?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\ReceiveEquip\InputFilter;
use Zend\Filter;
use Zend\InputFilter\CollectionInputFilter;
use Zend\InputFilter\Input;