Overwrite Budgets

This commit is contained in:
2018-07-13 17:41:01 +02:00
parent f419ce6c23
commit 0996682d8b
5 changed files with 428 additions and 317 deletions

View File

@@ -486,37 +486,60 @@ class BudgetController extends AppController
}
public function writeBudgetById($budget_id) {
//debug($budget_id);die;
public function writeBudgetById() {
$budget_id = $this->request->params['?']['id'];
$overwrite = $this->request->params['?']['overwrite'];
$curl = new AsdUp();
$ch = $curl->init_curl_params();
$curl->login_school($ch); //Login Schulportal
$curl->login_asd($ch); //Login ASD Applikation
$budget_typ = $this->Budget->wlBudgets->get($budget_id);
//debug($budget_typ);
$curl->goto_budget($ch,$budget_typ['schulart']);
//debug($curl->html);
$output = array();
$budgets = $this->Budget->find('all',[
'conditions' => ['wl_budget_id' => $budget_id,'asd' => 0],
'limit' => 100
]);
foreach ($budgets as $budget) {
$curl->change_school($ch,$budget['snr']);
$budget['wl_werteliste_nr'] = $budget_typ['wl_werteliste_nr'];
//echo $curl->html;
$pos = strpos($curl->html,'class="hideOverflow200px" title="'. $budget_typ['wl_kurz_bezeichnung']. '"'); //ist das Budget schon eingetragen?
//debug($pos);
if(!$pos) {
if(!$overwrite) {
$data = $curl->read_budget($ch,$budget['snr']);
foreach($data as $key => $line) {
if(isset($line['budget'])) {
if ($line['budget'] == $budget_typ['wl_kurz_bezeichnung']) {
debug($key);
$curl->del_budget($ch,$budget['snr'],$key);
$budget['count'] = $budget['count'] + $line['count'];
$budget['comment'] = $line['comment'] . '; ' . $budget['comment'] ;
}
}
}
debug($budget);
$curl->write_budget($ch,$budget);
$budget->asd = true;
$this->Budget->save($budget);
array_push($output,$budget);
}
}
else {
if(!$pos) {
$curl->write_budget($ch,$budget);
$budget->asd = true;
$this->Budget->save($budget);
array_push($output,$budget);
}
}
}
$this->set('output',$output);
}
public function writeAsd()