handle inventory sync from config

parent a3ff6acb
......@@ -10,4 +10,7 @@
return [
'forum_url' => 'http://edulabs.minedu.gov.gr/forum',
'egkyklios_file' => 'http://edulabs.minedu.gov.gr/files/egkyklios.pdf',
'sch_sync' => [
'inventory_sync_on_demand' => false,
],
];
......@@ -86,11 +86,26 @@ return function (App $app) {
});
$events('on', 'app.bootstrap', function ($app, $container) {
$app->get('/sch_sync/sync', SchSync\Action\Sync::class)->setName('sch_sync/sync');
$settings = $container['settings'];
$enabled = isset($settings['sch_sync']['inventory_sync_on_demand'])
? (bool) $settings['sch_sync']['inventory_sync_on_demand'] : false;
if ($enabled) {
$app->get('/sch_sync/sync', SchSync\Action\Sync::class)->setName('sch_sync/sync');
}
});
$events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$container['router']->getNamedRoute('school.labs')
->add(function ($req, $res, $next) use ($container) {
$settings = $container['settings'];
$enabled = isset($settings['sch_sync']['inventory_sync_on_demand'])
? (bool) $settings['sch_sync']['inventory_sync_on_demand'] : false;
$view = $container->get('view');
$view['enable_inventory_sync'] = $enabled;
return $next($req, $res);
});
$container['router']->getNamedRoute('user.login.sso')
->add(CreateUser::class)
->add(CreateSchool::class)
......
......@@ -34,10 +34,11 @@
Σε κάθε περίπτωση θα πρέπει να δικαιολογηθεί η χρήση της αίθουσας
συμπληρώνοντας όλα τα πεδία.
</p>
{% if enable_inventory_sync %}
<p>
<button data-href="{{ path_for('sch_sync/sync') }}" class="btn btn-primary" id="inventory_sync"><i class="fa fa-copy"></i> Ενημέρωση από το Κτηματολόγιο</button>
</p>
{% endif %}
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
......@@ -136,5 +137,7 @@
<script src="{{ base_url }}/js/jquery.iframe-transport.js"></script>
<script src="{{ base_url }}/js/jquery.fileupload.js"></script>
<script src="{{ base_url }}/js/schools/labs.js"></script>
{% if enable_inventory_sync %}
<script src="{{ base_url }}/js/sch_sync/sync.js"></script>
{% endif %}
{% endblock %}
\ No newline at end of file
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