Stability Schooltype

This commit is contained in:
2018-04-10 16:31:25 +02:00
parent 6247ec5037
commit d94a8e88c5
7 changed files with 188 additions and 15272 deletions

View File

@@ -16,6 +16,10 @@ namespace App\Controller;
use Cake\Controller\Controller;
use Cake\Event\Event;
use Cake\Http\Cookie\Cookie;
use Cake\Http\Cookie\CookieCollection;
use Cake\I18n\Time;
use Cake\Controller\Component\CookieComponent;
/**
* Application Controller
@@ -43,12 +47,44 @@ class AppController extends Controller
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Cookie');
$this->Cookie->config('encryption', false);
$this->Cookie->config('path', '/');
$this->Cookie->config([
'expires' => '+100 days',
'httpOnly' => true
]);
$session = $this->request->session();
if(!($session->check('SchoolType'))) {
$session->write('SchoolType','02');
}
/**
debug($this->Cookie->check('schooltype'));
if(!$this->Cookie->check('schooltype')) {
debug('Cookie neu');
$this->Cookie->write('schooltype', '2');
}
debug($this->Cookie->read('schooltype'));
*/
/** if(!($this->request->getCookie('schooltype'))) {
debug('Hallo');
$cookie = (new Cookie('schooltype'))
->withValue('2')
->withExpiry(new \DateTime('+1 year'))
->withSecure(false)
->withHttpOnly(true);
$this->response = $this->response->withCookie($cookie);
debug($this->response->getCookie('schooltype'));
$cookies = new CookieCollection([$cookie]);
$cookies = $cookies->add($cookie);
debug(count($cookies));
//die;
} */
/*
* Enable the following components for recommended CakePHP security settings.

View File

@@ -22,6 +22,21 @@ class BudgetController extends AppController
else {
$session->write('SchoolType','02');
}
/* debug($this->Cookie->read('schooltype'));
if($this->Cookie->read('schooltype') == '2') {
debug('Gymnasium');
//$this->Cookie->delete('schooltype');
$this->Cookie->write('schooltype', '4');
debug($this->Cookie->read('schooltype'));
}
else {
debug('Realschule');
//$this->Cookie->delete('schooltype');
$this->Cookie->write('schooltype', '2');
debug($this->Cookie->read('schooltype'));
}
*/
//die;
$this->redirect($this->referer());
}
@@ -77,14 +92,26 @@ class BudgetController extends AppController
$budget = $this->Budget->wlBudgets->get($id);
$this->set('budget',$budget);
$this->set('data',$data_arr);
$this->set('schooltype',$schooltype);
}
public function editajax($id = null) {
public function editajax() {
$this->autoRender = false;
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug-edit.txt', "w");
//fwrite($myfile,$id . PHP_EOL);
$data = $this->request->input('json_decode');
//fwrite($myfile,json_encode($data) . PHP_EOL);
$params = $this->request->params;
debug($params['?']);
fwrite($myfile,json_encode($params['?']['budget']) . PHP_EOL);
fwrite($myfile,json_encode($params['?']['schooltype']) . PHP_EOL);
$id = $params['?']['budget'];
$schooltype = $params['?']['schooltype'];
if($schooltype = '02') {
$schooltype_nr = '2';
}
else {
$schooltype_nr = '4';
}
foreach($data as $line) {
@@ -118,7 +145,7 @@ class BudgetController extends AppController
else {
fwrite($myfile,'empty' . PHP_EOL);
$new = $this->Budget->newEntity();
$new_budget['wl_schooltype_id'] = 4;
$new_budget['wl_schooltype_id'] = $schooltype_nr;
$new_budget['snr'] = $line[0];
$new_budget['wl_budget_id'] = $id;
$new_budget['count'] = $line[2];
@@ -134,11 +161,11 @@ class BudgetController extends AppController
fclose($myfile);
}
public function sajax() {
public function sajax($schooltype = null) {
$session = $this->request->session();
//$session = $this->request->session();
//debug($session->read('SchoolType'));die;
$schooltype = $session->read('SchoolType');
//$schooltype = $session->read('SchoolType');
if ($schooltype == '02') {
$wl_offset = 31;
$schooltype_id = '2';
@@ -162,7 +189,7 @@ class BudgetController extends AppController
$key = $entry['snr'] . '_' . $entry['wl_budget_id'];
fwrite($myfile,json_encode($key) . PHP_EOL);
$search_arr[$key]['count'] = $entry['count'];
$search_arr[$key]['comment'] = $entry['comment'];
//$search_arr[$key]['comment'] = $entry['comment'];
fwrite($myfile,json_encode($search_arr[$key]) . PHP_EOL);
}
@@ -230,9 +257,24 @@ class BudgetController extends AppController
public function overview() {
//debug($this->Cookie->read('schooltype'));
//debug($this->request);
//$cookie = $this->response->getCookie('schooltype');
//debug($cookie['value']);
//$schooltype = $cookie['value'];
//die;
$session = $this->request->session();
//debug($session->read('SchoolType'));die;
$schooltype = $session->read('SchoolType');
/**
$cookie_value = $this->Cookie->read('schooltype');
if($cookie_value == 2) {
$schooltype = '02';
}
else {
$schooltype = '04';
} */
if ($schooltype == '02') {
$schulart = 'RS';
$offset = -31;
@@ -278,6 +320,7 @@ class BudgetController extends AppController
$this->set('data',$data_arr);
$this->set('wlBudgets',$wlBudgets);
$this->set('schooltype',$schooltype);
}
public function gettype($id = null) {

View File

View File

@@ -40,7 +40,7 @@ var data = <?php echo json_encode($data); ?>;
//console.log(JSON.stringify({data: hot.getData()}));
$.ajax({
//url: "editajax?id=<?php echo $budget['id']; ?>",
url: "<?php echo $this->Url->build(array('controller' => 'budget', 'action' => 'editajax',$budget['id']), true); ?>",
url: "<?php echo $this->Url->build(array('controller' => 'budget', 'action' => 'editajax'), true) . '?budget=' . $budget['id'] . '&schooltype=' . $schooltype ?>",
data: JSON.stringify(hot.getData()),
type: 'POST',
success: function (res) {

View File

@@ -1,5 +1,5 @@
<?php
//debug($schooltype);
//$test = '["<a href=\"test\">SNR<\/a>","Schule","RS Modellversuch","RS geb. Ganztagsklassen","RS St\u00fctzpunktschule Schulsport","RS Partnerschule Wintersport","RS Sonderp\u00e4d. F\u00f6rderbedarf","Abordnung Grundschullehrkraft","Bilingualer Unterricht","Inklusion","sonstige Budgetzuschl\u00e4ge","RS Koop. mit and. Schulart","RS Integrierte Lehrerres.","RS Bestenf\u00f6rderung","MINT","Musikrealschule"]';
$cols = array();
$columns = array();
@@ -63,7 +63,7 @@ var data = <?php echo json_encode($data); ?>;
//console.log(JSON.stringify({data: hot.getData()}));
$.ajax({
//url: "sajax",
url: "<?php echo $this->Url->build(array('controller' => 'budget', 'action' => 'sajax',$budget['id']), true); ?>",
url: "<?php echo $this->Url->build(array('controller' => 'budget', 'action' => 'sajax',$schooltype), true); ?>",
data: JSON.stringify(hot.getData()),
type: 'POST',
success: function (res) {

View File

@@ -1,13 +1,14 @@
{"id":11,"wl_schooltype_id":2,"snr":"0402","wl_budget_id":33,"count":5,"comment":"auto","year":"2018","created":"2018-04-04T09:10:38+00:00","modified":"2018-04-04T09:10:38+00:00"}
"33"
"02"
{"id":11,"wl_schooltype_id":2,"snr":"0402","wl_budget_id":33,"count":7,"comment":"auto","year":"2018","created":"2018-04-04T09:10:38+00:00","modified":"2018-04-09T13:31:02+00:00"}
{"id":18,"wl_schooltype_id":2,"snr":"0403","wl_budget_id":33,"count":3,"comment":"Aichach rules","year":"2018","created":"2018-04-06T11:58:36+00:00","modified":"2018-04-09T09:23:00+00:00"}
{"id":23,"wl_schooltype_id":4,"snr":"0405","wl_budget_id":33,"count":8,"comment":"rein damit","year":"2018","created":"2018-04-09T09:33:09+00:00","modified":"2018-04-09T09:33:09+00:00"}
full-count
empty
empty
empty
empty
empty
empty
{"id":31,"wl_schooltype_id":2,"snr":"0407","wl_budget_id":33,"count":7,"comment":"auto","year":"2018","created":"2018-04-10T13:32:59+00:00","modified":"2018-04-10T13:32:59+00:00"}
{"id":35,"wl_schooltype_id":2,"snr":"0410","wl_budget_id":33,"count":3,"comment":"auto","year":"2018","created":"2018-04-10T13:32:59+00:00","modified":"2018-04-10T13:32:59+00:00"}
{"id":37,"wl_schooltype_id":2,"snr":"0411","wl_budget_id":33,"count":7,"comment":"auto","year":"2018","created":"2018-04-10T13:32:59+00:00","modified":"2018-04-10T13:32:59+00:00"}
{"id":41,"wl_schooltype_id":2,"snr":"0413","wl_budget_id":33,"count":3,"comment":"auto","year":"2018","created":"2018-04-10T13:33:00+00:00","modified":"2018-04-10T13:33:00+00:00"}
{"id":43,"wl_schooltype_id":2,"snr":"0415","wl_budget_id":33,"count":7,"comment":"auto","year":"2018","created":"2018-04-10T13:33:00+00:00","modified":"2018-04-10T13:33:00+00:00"}
{"id":47,"wl_schooltype_id":2,"snr":"0416","wl_budget_id":33,"count":3,"comment":"auto","year":"2018","created":"2018-04-10T13:33:00+00:00","modified":"2018-04-10T13:33:00+00:00"}
empty
empty
empty

File diff suppressed because it is too large Load Diff