From ad9bd84844192a88736ada11b9d894016cd1a91c Mon Sep 17 00:00:00 2001
From: Wilfried Trinkl
Date: Mon, 2 Apr 2018 19:37:58 +0200
Subject: [PATCH] budget listBudgets editBudget editajax
---
src/Controller/BudgetController.php | 84 +++++++++++++++++++++++++--
src/Template/Budget/edit_budget.ctp | 53 +++++++++++++++++
src/Template/Budget/list_budgets.ctp | 7 +++
webroot/css/handsontable.costum.css | 6 ++
webroot/files/debug-edit.txt | Bin 0 -> 1930 bytes
5 files changed, 146 insertions(+), 4 deletions(-)
create mode 100644 src/Template/Budget/edit_budget.ctp
create mode 100644 src/Template/Budget/list_budgets.ctp
create mode 100644 webroot/files/debug-edit.txt
diff --git a/src/Controller/BudgetController.php b/src/Controller/BudgetController.php
index 29bb644..e342886 100644
--- a/src/Controller/BudgetController.php
+++ b/src/Controller/BudgetController.php
@@ -13,13 +13,92 @@ use AsdCurl\AsdUp;
*/
class BudgetController extends AppController
{
+ public function listBudgets() {
+ $wlBudgets = $this->Budget->wlBudgets->find('all', [
+ 'conditions' => array('schulart' => 'GY')
+ ]);
+ $this->set('wlBudgets',$wlBudgets);
+ }
+
+ public function editBudget($id = null) {
+ $this->loadModel('Schools');
+ $schools = $this->Schools->find('all');
+ $data = array();
+ foreach($schools as $school) {
+ $line = array();
+ array_push($line,$school['dst_schluessel']);
+ array_push($line,$school['dst_name']);
+ array_push($line,'','');
+ $data[$school['dst_schluessel']] = $line;
+ }
+
+ $budgets = $this->Budget->find('all', [
+ 'conditions' => array('wl_budget_id' => $id)
+ ]);
+
+ foreach($budgets as $budget) {
+ $data[$budget['snr']][2] = $budget['count'];
+ $data[$budget['snr']][3] = $budget['comment'];
+ }
+ $data_arr = array();
+ foreach($data as $entry) {
+ array_push($data_arr,$entry);
+ }
+ $budget = $this->Budget->wlBudgets->get($id);
+ $this->set('budget',$budget);
+ $this->set('data',$data_arr);
+ }
+
+ public function editajax($id = null) {
+ $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');
+
+ foreach($data as $line) {
+ if($line[2] > 0) {
+ $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] ) {
+ $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);
+ }
+ }
+ fclose($myfile);
+ }
+
public function sajax() {
$this->autoRender = false;
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug.txt', "w");
$data = $this->request->input('json_decode');
foreach($data as $line) {
- //fwrite($myfile,json_encode($line). PHP_EOL);
for($i=2;$i < sizeof($line);$i++) {
if($line[$i] > 0) {
$query = $this->Budget->find('all', [
@@ -54,9 +133,6 @@ class BudgetController extends AppController
}
}
fclose($myfile);
- //debug(json_encode($this->request->data));
- //debug($this->request);
- //return(true);
}
public function overview() {
diff --git a/src/Template/Budget/edit_budget.ctp b/src/Template/Budget/edit_budget.ctp
new file mode 100644
index 0000000..d2c28fa
--- /dev/null
+++ b/src/Template/Budget/edit_budget.ctp
@@ -0,0 +1,53 @@
+' . $budget['wl_kurz_bezeichnung'] .'';
+?>
+
+
+
+
+
+
+ Data loaded
+
+
\ No newline at end of file
diff --git a/src/Template/Budget/list_budgets.ctp b/src/Template/Budget/list_budgets.ctp
new file mode 100644
index 0000000..e86e5cd
--- /dev/null
+++ b/src/Template/Budget/list_budgets.ctp
@@ -0,0 +1,7 @@
+' . $this->Html->link($wlBudget['wl_kurz_bezeichnung'],['controller' => 'Budget', 'action' => 'edit_budget' , $wlBudget['id']]) . '
';
+ }
+
+?>
\ No newline at end of file
diff --git a/webroot/css/handsontable.costum.css b/webroot/css/handsontable.costum.css
index f4a4fe6..5379049 100644
--- a/webroot/css/handsontable.costum.css
+++ b/webroot/css/handsontable.costum.css
@@ -11,4 +11,10 @@
.handsontable tr {
line-height: 20px;
+}
+
+div#editbudget.handsontable.htRowHeaders.htColumnHeaders thead th {
+ line-height: 10px;
+ padding: 0px;
+ font-weight: bold;
}
\ No newline at end of file
diff --git a/webroot/files/debug-edit.txt b/webroot/files/debug-edit.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9713e8d29e97d2fe4b7dc4478ac2cd9a8e261551
GIT binary patch
literal 1930
zcmeHHv2NQi5Y6nbFgO-aL5fylou)KMfeuX;cN1X95@QpUNrR*lC_(*M
zeY%=gb*;SDi&n9s0>R_iHL#a(3DcZRj>?t{YY?KolOZvp25)5^2m_#MXnX3|MWq
zCiHnX^c~Ul5xl-r)u9n3I8_C8xM&J&Z5#chk0F7VpWy17K`T!T
zb0UbSiIIjJ8HwMr)i4>b^?-Oe=Ymne2huu@=15wD#JnMCtm43C%7^iNqr-~&97Ygd
zQ!b_y9Zmw3#HzdMrz*dRsVToY`>M=LuN6Zf-eO&YL!-JBX;6=ZPZFMv#SNr62>BUN
z;}db?_yX3xTBGJ9D@}la;;8#L7*&Qozh9@FC#-%x;ITweN!1GIRkeE1gT374z
zQk$wJDREcn1Sdo%E8R584B}!Jf7UK+PYRG971V9z{X>PbEFO?G?hr*AOz)0ePz{P2
z^+J2aF|WT*IcHs5sXdPUecC)%Ep68U;J$}bOYMW}Zd+Ypod*y%{z>buW6A%uBNUE!)aO$g#*kUPG2$VwVrL{ga=FOeCkD
QNH)0;&A(t?+O25bUt8EcT>t<8
literal 0
HcmV?d00001