Stability Schooltype
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user