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

@@ -172,7 +172,7 @@ class AsdCurl
//debug($html);
$login_data = [
'portal_username' => 'asd.trinkl',
'portal_password' => 'HiegTzs!181',
'portal_password' => 'HiegTzs!182',
];
$post = [

View File

@@ -145,26 +145,34 @@ class AsdUp extends AsdCurl
$htmlParser->loadHTML($this->html); //Loaded the html string we took from simple xml
$htmlParser->preserveWhiteSpace = false;
//echo $this->html;
$headers = ['checkbox','herkunft','budget','von','bis','count','comment'];
$table = $htmlParser->getElementById('mainForm:dataTable:zuschlaege');
$rows = $table->getElementsByTagName('tr');
for($i=0;$i < (sizeof($rows)-1);$i++) {
$cols = $rows[$i]->getElementsByTagName('td');
$i=0;
foreach($rows as $row) {
//for($i=0;$i < (sizeof($rows)-1);$i++) {
$cols = $row->getElementsByTagName('td');
$j = 0;
foreach($cols as $col) {
$span = $col->getElementsByTagName('span');
//debug(sizeof($span));
if(sizeof($span) > 0) {
//print_r($span);
// debug($span->length);
if($span->length > 0) {
$data[$i][$headers[$j]] = $span->item(0)->nodeValue;
}
$j++;
}
}
$i++;
}
$cols = $rows[sizeof($rows)-1]->getElementsByTagName('td');
$span = $cols[1]->getElementsByTagName('span');
$sum = $span->item(0)->nodeValue;
//debug($data);
//die;
//$cols = $rows[sizeof($rows)-1]->getElementsByTagName('td');
//$span = $cols[1]->getElementsByTagName('span');
//$sum = $span->item(0)->nodeValue;
//$data['sum'] = $sum;
return($data);
}
@@ -264,6 +272,84 @@ class AsdUp extends AsdCurl
return($to_del);
}
public function del_budget($ch,$snr,$linenr) {
//debug($snr);
//echo($this->html);
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
$htmlParser = new \DOMDocument(); //to parse html using DOMDocument
libxml_use_internal_errors(true); // your HTML gives parser warnings, keep them internal
$htmlParser->loadHTML($this->html); //Loaded the html string we took from simple xml
$htmlParser->preserveWhiteSpace = false;
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
$post = [
'mainForm' => 'mainForm',
'referenzBaumAnzeigen' => 'false',
'conversationId' => $conversationId,
'changeNotification' => 'true',
'mainForm:hasChanged' => 'true',
'mainForm:hasNotReleased' => 'false',
'mainForm:hasPopUpChanged' => 'false',
'mainForm:hasAdresseChanged' => 'false',
'mainForm:confirmedOverride' => 'true',
'mainForm:zuordnungNotification' => 'false',
'skipvalidation' => 'false',
'mainForm:istAnzeigeMaske' => 'false',
'mainForm:schulnr' => '',
'mainForm:schuljahr' => '23',
'mainForm:schulnummer' => $snr,
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:1502',
'mainForm:tab2:datumBis' => '31.07.2019',
'mainForm:tab2:_edit_budget' => '',
'mainForm:tab2:_edit_bemerkung' => '',
'mainForm:loeschen' => 'Löschen',
'javax.faces.ViewState' => $viewstate
];
$post['mainForm:tab2:_' . $linenr .'_select'] = 'on';
//debug($post);die;
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
if(!($this->status)) {
die($this->error);
}
//echo $this->html;
//die;
// Budget speichern
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
$post = [
'mainForm' => 'mainForm',
'referenzBaumAnzeigen' => 'false',
'conversationId' => $conversationId,
'changeNotification' => 'true',
'mainForm:hasChanged' => 'true',
'mainForm:hasNotReleased' => 'false',
'mainForm:hasPopUpChanged' => 'false',
'mainForm:hasAdresseChanged' => 'false',
'mainForm:confirmedOverride' => 'true',
'mainForm:zuordnungNotification' => 'false',
'skipvalidation' => 'false',
'mainForm:istAnzeigeMaske' => 'false',
'mainForm:schulnr' => '',
'mainForm:schuljahr' => '23',
'mainForm:schulnummer' => $snr,
'mainForm:tab2:artZuschlag' => 'com.hp.asd.wl.domain.standard.Budgetform:1502',
'mainForm:tab2:datumBis' => '31.07.2019',
'mainForm:tab2:_edit_budget' => '',
'mainForm:tab2:_edit_bemerkung' => '',
'mainForm:speichern' => 'Speichern',
'javax.faces.ViewState' => $viewstate
];
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdbu/up_07_50.jsf?cid=' . $conversationId, $post);
if(!($this->status)) {
die($this->error);
}
//return($to_del);
}
public function write_budget($ch,$budget) {
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
//debug($budget);die;