Delete Budgets
This commit is contained in:
@@ -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 = "<a\s[^>]*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 = "<a\s[^>]*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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user