diff --git a/config/routes.php b/config/routes.php
index 43d6697..b2ceef3 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -49,7 +49,8 @@ Router::scope('/', function (RouteBuilder $routes) {
* its action called 'display', and we pass a param to select the view file
* to use (in this case, src/Template/Pages/home.ctp)...
*/
- $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
+ //$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
+ $routes->connect('/', ['controller' => 'Budget', 'action' => 'overview']);
/**
* ...and connect the rest of 'Pages' controller's URLs.
diff --git a/src/Controller/BudgetController.php b/src/Controller/BudgetController.php
index 6adf9dd..18784b0 100644
--- a/src/Controller/BudgetController.php
+++ b/src/Controller/BudgetController.php
@@ -82,43 +82,54 @@ class BudgetController extends AppController
public function editajax($id = null) {
$this->autoRender = false;
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug-edit.txt', "w");
- fwrite($myfile,$id . PHP_EOL);
+ //fwrite($myfile,$id . PHP_EOL);
$data = $this->request->input('json_decode');
+ //fwrite($myfile,json_encode($data) . PHP_EOL);
foreach($data as $line) {
- if($line[2] > 0) {
- $query = $this->Budget->find('all', [
- 'conditions' => array('snr' => $line[0], 'wl_budget_id' => $id)
- ]);
+
+ //fwrite($myfile,json_encode($line[0]) . PHP_EOL);
+ //$regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
+ //preg_match_all("/$regexp/siU", $line[0], $matches);
+ //fwrite($myfile,json_encode($line) . PHP_EOL);
+ $query = $this->Budget->find('all', [
+ 'conditions' => array('snr' => $line[0], 'wl_budget_id' => $id)
+ ]);
- if(!($query->isEmpty())) {
- $budget = $query->first();
- if($budget['count'] != $line[2] ) {
+ if(!($query->isEmpty())) {
+ $budget = $query->first();
+ fwrite($myfile,json_encode($budget) . PHP_EOL);
+ if($budget['count'] != $line[2] ) {
+ if($line[2] > 0) {
$budget['count'] = $line[2];
$this->Budget->save($budget);
- fwrite($myfile,'full-count' . PHP_EOL);
- }
- if($budget['comment'] != $line[3] ) {
- $budget['comment'] = $line[3];
- $this->Budget->save($budget);
- fwrite($myfile,'full-comment' . PHP_EOL);
- }
- }
- else {
- fwrite($myfile,'empty' . PHP_EOL);
- $new = $this->Budget->newEntity();
- $new_budget['wl_schooltype_id'] = 4;
- $new_budget['snr'] = $line[0];
- $new_budget['wl_budget_id'] = $id;
- $new_budget['count'] = $line[2];
- $new_budget['comment'] = $line[3];
- $new_budget['year'] = '2018';
- $new = $this->Budget->patchEntity($new, $new_budget);
- $this->Budget->save($new);
- }
- fwrite($myfile,serialize($budget). PHP_EOL);
- fwrite($myfile,$line[0] . ' ' .($i-1) . ' ' . $line[$i]. PHP_EOL);
- }
+ }
+ else {
+ $this->Budget->delete($budget);
+ }
+ fwrite($myfile,'full-count' . PHP_EOL);
+ }
+ if($budget['comment'] != $line[3] ) {
+ $budget['comment'] = $line[3];
+ $this->Budget->save($budget);
+ fwrite($myfile,'full-comment' . PHP_EOL);
+ }
+ }
+ else {
+ fwrite($myfile,'empty' . PHP_EOL);
+ $new = $this->Budget->newEntity();
+ $new_budget['wl_schooltype_id'] = 4;
+ $new_budget['snr'] = $line[0];
+ $new_budget['wl_budget_id'] = $id;
+ $new_budget['count'] = $line[2];
+ $new_budget['comment'] = $line[3];
+ $new_budget['year'] = '2018';
+ $new = $this->Budget->patchEntity($new, $new_budget);
+ $this->Budget->save($new);
+ }
+ //fwrite($myfile,serialize($budget). PHP_EOL);
+ //fwrite($myfile,$line[0] . ' ' .($i-1) . ' ' . $line[$i]. PHP_EOL);
+
}
fclose($myfile);
}
@@ -140,11 +151,15 @@ class BudgetController extends AppController
$this->autoRender = false;
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug.txt', "w");
$data = $this->request->input('json_decode');
-
-
+ //fwrite($myfile,json_encode($data) . PHP_EOL);
+ //fwrite($myfile,'hallo' . PHP_EOL);
+ // neue und geänderte Daten eintragen
foreach($data as $line) {
for($i=2;$i < sizeof($line);$i++) {
if($line[$i] > 0) {
+ //$regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
+ preg_match_all("/$regexp/siU", $line[0], $matches);
+ //fwrite($myfile,$matches[3][0] . PHP_EOL);
$query = $this->Budget->find('all', [
'conditions' => array('snr' => $line[0], 'wl_budget_id' => $i+$wl_offset)
]);
@@ -155,10 +170,10 @@ class BudgetController extends AppController
$budget['count'] = $line[$i];
$this->Budget->save($budget);
}
- fwrite($myfile,'full' . PHP_EOL);
+ //fwrite($myfile,'full' . PHP_EOL);
}
else {
- fwrite($myfile,'empty' . PHP_EOL);
+ //fwrite($myfile,'empty' . PHP_EOL);
$new = $this->Budget->newEntity();
$new_budget['wl_schooltype_id'] = $schooltype_id;
$new_budget['snr'] = $line[0];
@@ -171,11 +186,35 @@ class BudgetController extends AppController
$this->Budget->save($new);
}
- fwrite($myfile,serialize($budget). PHP_EOL);
- fwrite($myfile,$line[0] . ' ' .($i+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
+ //fwrite($myfile,serialize($budget). PHP_EOL);
+ //fwrite($myfile,$line[0] . ' ' .($i+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
}
}
}
+
+ // wurde etwas gelöscht?
+ $dbdata = $this->Budget->find('all', [
+ 'conditions' => array('wl_schooltype_id' => $schooltype_id)
+ ]);
+ foreach($dbdata as $entry) {
+ fwrite($myfile,json_encode($entry) . PHP_EOL);
+ fwrite($myfile,$entry->snr . PHP_EOL);
+ $value = array_search($entry->snr,array_column($data,0));
+
+ fwrite($myfile,json_encode($value). PHP_EOL);
+ fwrite($myfile,json_encode($data[$value]). PHP_EOL);
+ fwrite($myfile,json_encode($data[$value][$entry->wl_budget_id - $wl_offset]). PHP_EOL);
+ if($data[$value][$entry->wl_budget_id - $wl_offset] > 0) {
+ fwrite($myfile,'passt' . PHP_EOL);
+ }
+ else {
+ fwrite($myfile,'loeschen' . PHP_EOL);
+ //$budget = $this->Budget->get($id);
+ $this->Budget->delete($entry);
+ }
+ }
+
+
fclose($myfile);
}
@@ -193,7 +232,7 @@ class BudgetController extends AppController
$offset = 1;
}
- $wlBudgets = $this->Budget->wlBudgets->find('list', [
+ $wlBudgets = $this->Budget->wlBudgets->find('all', [
'conditions' => array('schulart' => $schulart)
]);
//debug($wlBudgets);die;
@@ -305,7 +344,7 @@ class BudgetController extends AppController
$exports = $this->Budget->find('all', [
'contain' => ['WlBudgets'],
- 'fields' => ['Budget.snr','WlBudgets.wl_werteliste_id','WlBudgets.wl_kurz_bezeichnung','Budget.count','Budget.comment']
+ 'fields' => ['Budget.snr','WlBudgets.wl_werteliste_nr','WlBudgets.wl_kurz_bezeichnung','Budget.count','Budget.comment']
]);
$data = array();
foreach($exports as $export) {
diff --git a/src/Controller/SchoolsController.php b/src/Controller/SchoolsController.php
index ae35088..4cb7dbc 100644
--- a/src/Controller/SchoolsController.php
+++ b/src/Controller/SchoolsController.php
@@ -21,58 +21,63 @@ class SchoolsController extends AppController
$data = $this->request->input('json_decode');
$this->loadModel('Budget');
$this->loadModel('wl_Budgets');
- fwrite($myfile,$schooltype . PHP_EOL);
+ //fwrite($myfile,$schooltype . PHP_EOL);
fwrite($myfile,$snr . PHP_EOL);
- foreach($data as $line) {
- fwrite($myfile,'Size: ' . strlen($line[0]) . PHP_EOL);
- if(strlen($line[0]) > 0) {
- fwrite($myfile,'Budget: ' . $line[0] . PHP_EOL);
- $query = $this->wl_Budgets->find('all', [
- 'conditions' => array('wl_kurz_bezeichnung' => $line[0])
- ]);
- $wl_budget = $query->first();
- fwrite($myfile,json_encode($wl_budget). PHP_EOL);
- $query = $this->Budget->find('all', [
- 'conditions' => array('snr' => $snr, 'wl_budget_id' => $wl_budget['id'])
- ]);
- fwrite($myfile,$wl_budget['id'] . PHP_EOL);
+ foreach($data as $line) {
+ fwrite($myfile,json_encode($line) . PHP_EOL);
+ //fwrite($myfile,'Size: ' . strlen($line[0]) . PHP_EOL);
+ if(strlen($line[0]) > 0) {
+ //fwrite($myfile,'Budget: ' . $line[0] . PHP_EOL);
+ $query = $this->wl_Budgets->find('all', [
+ 'conditions' => array('wl_kurz_bezeichnung' => $line[0])
+ ]);
+ $wl_budget = $query->first();
+ //fwrite($myfile,json_encode($wl_budget). PHP_EOL);
+ $query = $this->Budget->find('all', [
+ 'conditions' => array('snr' => $snr, 'wl_budget_id' => $wl_budget['id'])
+ ]);
+ //fwrite($myfile,$wl_budget['id'] . PHP_EOL);
- if(!($query->isEmpty())) {
- $budget = $query->first();
- fwrite($myfile,json_encode($budget). PHP_EOL);
- if($budget['wl_budget_id'] != $wl_budget['id'] ) {
- $budget['wl_budget_id'] = $wl_budget['id'];
- $this->Budget->save($budget);
- }
- elseif($budget['count'] != $line[1] ) {
+ if(!($query->isEmpty())) {
+ $budget = $query->first();
+ //fwrite($myfile,json_encode($budget). PHP_EOL);
+ if($budget['wl_budget_id'] != $wl_budget['id'] ) {
+ $budget['wl_budget_id'] = $wl_budget['id'];
+ $this->Budget->save($budget);
+ }
+ elseif($budget['count'] != $line[1] ) {
+ if($line[1] > 0) {
$budget['count'] = $line[1];
$this->Budget->save($budget);
}
- elseif($budget['comment'] != $line[2] ) {
- $budget['comment'] = $line[2];
- $this->Budget->save($budget);
+ else {
+ $this->Budget->delete($budget);
}
- fwrite($myfile,'full' . PHP_EOL);
}
- else {
- fwrite($myfile,'empty' . PHP_EOL);
- $new = $this->Budget->newEntity();
- $new_budget['wl_schooltype_id'] = $schooltype;
- $new_budget['snr'] = $snr;
- $new_budget['wl_budget_id'] = $wl_budget['id'];
- $new_budget['count'] = $line[1];
- $new_budget['comment'] = $line[2];
- $new_budget['year'] = '2018';
- fwrite($myfile,'New: ' . json_encode($new_budget). PHP_EOL);
- $new = $this->Budget->patchEntity($new, $new_budget);
-
- $this->Budget->save($new);
- }
- //fwrite($myfile,serialize($budget). PHP_EOL);
- //fwrite($myfile,$line[0] . ' ' .($i+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
+ elseif($budget['comment'] != $line[2] ) {
+ $budget['comment'] = $line[2];
+ $this->Budget->save($budget);
+ }
+ //fwrite($myfile,'full' . PHP_EOL);
}
-
+ else {
+ //fwrite($myfile,'empty' . PHP_EOL);
+ $new = $this->Budget->newEntity();
+ $new_budget['wl_schooltype_id'] = $schooltype;
+ $new_budget['snr'] = $snr;
+ $new_budget['wl_budget_id'] = $wl_budget['id'];
+ $new_budget['count'] = $line[1];
+ $new_budget['comment'] = $line[2];
+ $new_budget['year'] = '2018';
+ //fwrite($myfile,'New: ' . json_encode($new_budget). PHP_EOL);
+ $new = $this->Budget->patchEntity($new, $new_budget);
+
+ $this->Budget->save($new);
+ }
+ //fwrite($myfile,serialize($budget). PHP_EOL);
+ //fwrite($myfile,$line[0] . ' ' .($i+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
+ }
}
fclose($myfile);
}
diff --git a/src/Template/Budget/edit_budget.ctp b/src/Template/Budget/edit_budget.ctp
index 128d00d..5eb3c3c 100644
--- a/src/Template/Budget/edit_budget.ctp
+++ b/src/Template/Budget/edit_budget.ctp
@@ -1,7 +1,7 @@
Html->link($data[$i][0],array('controller' => 'schools', 'action' => 'showbudgets',$data[$i][0]));
+ $data[$i][1] = $this->Html->link($data[$i][1],array('controller' => 'schools', 'action' => 'showbudgets',$data[$i][0]));
}
echo '' . $budget['wl_kurz_bezeichnung'] .'
';
//debug($data);
@@ -29,7 +29,7 @@ var data = ;
wordWrap: false,
colHeaders: ['SNR','Name','Count','Comment'] ,
colWidths: ['50','500','50','500'],
- columns: [{renderer: "html", readOnly: true},{renderer: "text", readOnly: true},{renderer: "text"},{renderer: "text"}],
+ columns: [{renderer: "text", readOnly: true},{renderer: "html", readOnly: true},{renderer: "text"},{renderer: "text"}],
filters: true,
dropdownMenu: true
});
diff --git a/src/Template/Budget/overview.ctp b/src/Template/Budget/overview.ctp
index bc64fdc..4da6ca1 100644
--- a/src/Template/Budget/overview.ctp
+++ b/src/Template/Budget/overview.ctp
@@ -1,29 +1,39 @@
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();
array_push($cols,'SNR');
+array_push($columns,['renderer' => 'text', 'readOnly' => true]);
+
array_push($cols,'Schule');
+array_push($columns,['renderer' => 'html', 'readOnly' => true]);
+
$col_width = array();
array_push($col_width,'50');
array_push($col_width,'300');
foreach($wlBudgets as $budget) {
- array_push($cols,$budget);
+ //debug($budget);die;
+ array_push($cols,$this->Html->link($budget['wl_kurz_bezeichnung'],array('controller' => 'budget', 'action' => 'edit-budget',$budget['id'])));
array_push($col_width,'30');
+ array_push($columns,['renderer' => 'text']);
}
+for($i=0;$iHtml->link($data[$i][1],array('controller' => 'schools', 'action' => 'showbudgets',$data[$i][0]));
+ }
+//debug($columns);
+//debug(json_encode($columns));die;
//debug(json_encode($cols));
?>
-
- Data loaded
-
+