budget performance
This commit is contained in:
@@ -150,30 +150,45 @@ class BudgetController extends AppController
|
||||
|
||||
$this->autoRender = false;
|
||||
$myfile = fopen(WWW_ROOT . DS . 'files' . DS . 'debug.txt', "w");
|
||||
|
||||
$query = $this->Budget->find('all', [
|
||||
'conditions' => array('wl_schooltype_id' => $schooltype_id)
|
||||
]);
|
||||
$count = $query->count();
|
||||
fwrite($myfile,json_encode($count) . PHP_EOL);
|
||||
$dbdata = $query->toArray();
|
||||
$search_arr = array();
|
||||
foreach($dbdata as $entry) {
|
||||
$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'];
|
||||
fwrite($myfile,json_encode($search_arr[$key]) . PHP_EOL);
|
||||
}
|
||||
|
||||
|
||||
$data = $this->request->input('json_decode');
|
||||
//fwrite($myfile,json_encode($data) . PHP_EOL);
|
||||
//fwrite($myfile,json_encode($dbdata) . 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)
|
||||
]);
|
||||
|
||||
if(!($query->isEmpty())) {
|
||||
$budget = $query->first();
|
||||
if($budget['count'] != $line[$i] ) {
|
||||
$key = $line[0] . '_' . ($i+$wl_offset);
|
||||
fwrite($myfile,json_encode($key) . PHP_EOL);
|
||||
if(isset($search_arr[$key])) {
|
||||
if($search_arr[$key]['count'] != $line[$i] ) {
|
||||
$query = $this->Budget->find('all', [
|
||||
'conditions' => array('snr' => $line[0], 'wl_budget_id' => $i+$wl_offset)
|
||||
]);
|
||||
$budget = $query->first();
|
||||
$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];
|
||||
@@ -182,20 +197,15 @@ class BudgetController extends AppController
|
||||
$new_budget['comment'] = 'auto';
|
||||
$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+$wl_offset) . ' ' . $line[$i]. PHP_EOL);
|
||||
$new = $this->Budget->patchEntity($new, $new_budget);
|
||||
$this->Budget->save($new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
@@ -213,7 +223,7 @@ class BudgetController extends AppController
|
||||
$this->Budget->delete($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fclose($myfile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user