This commit is contained in:
2018-12-14 15:37:43 +01:00
parent db6835c5da
commit fde0327de1
19 changed files with 2050 additions and 418 deletions

View File

@@ -16,8 +16,8 @@ class AsdUs extends AsdCurl
$this->error = false;
}
public function save_us_data($ch) {
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl');
public function save_us_data($ch,$env) {
$SCHULPORTAL_ASD_BASE_URL = Configure::read('AsdCurl.asdbaseurl.'.$env);
// Maske US 01 01 vom linken Menü aufrufen
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
@@ -73,9 +73,39 @@ class AsdUs extends AsdCurl
// Auf der Ergebnisseite auf "Alle" Klicken
$viewstate = $this->get_string_between($this->html, 'id="javax.faces.ViewState" value="', '" autocomplete');
$conversationId = $this->get_string_between($this->html, 'name="conversationId" value="', '" />');
$mainform = $this->get_string_between($this->html, '\\\':\\\'', '\\\'},\\\'\\\')\')\;return false\" class=\"ignoreChangeNotification notBold\">ALLE</a>');
//$mainform = $this->get_string_between($this->html, 'j_idt', 'ALLE');
//$mainform = $this->get_string_between($this->html, 'mojarra.jsfcljs(document.getElementById(', 'ALLE');
//echo $this->html;
//debug($mainform);die;
$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;
$xpath = new \DOMXPath($htmlParser);
$elements = $xpath->query("//a[text()='ALLE']/@onclick");
if (!is_null($elements)) {
foreach ($elements as $element) {
//echo "<br/>[". $element->nodeName. "]";
//echo "<br/>[". $element->nodeValue. "]";
$text = $element->nodeValue;
preg_match_all('!\d+!', $text, $matches);
//print_r($matches);
$mainform = $matches[0][0];
}
}
//die;
/*
if($env == 'prod') {
$mainform = '189';
}
else {
$mainform = '184';
}
*/
$post = [
'mainForm' => 'mainForm',
'referenzBaumAnzeigen' => 'false',
@@ -90,12 +120,14 @@ class AsdUs extends AsdCurl
'skipvalidation' => 'true',
'mainForm:istAnzeigeMaske' => 'false',
'javax.faces.ViewState' => $viewstate,
'mainForm:j_idt184' => 'mainForm:j_idt184',
'mainForm:j_idt'.$mainform => 'mainForm:j_idt'.$mainform,
];
$this->exec_curl($ch, $SCHULPORTAL_ASD_BASE_URL . '/asdus/us_01_02.jsf?cid=' . $conversationId, $post);
if(!($this->status)) {
die($this->error);
}
//echo $this->html;die;
// Ergebnisse parsen und in die MySQL - Datenbank schreiben
$htmlParser = new \DOMDocument(); //to parse html using DOMDocument
libxml_use_internal_errors(true); // your HTML gives parser warnings, keep them internal
@@ -103,7 +135,7 @@ class AsdUs extends AsdCurl
$htmlParser->preserveWhiteSpace = false;
$table = $htmlParser->getElementById('mainForm:resultTable');
//debug($table);
//debug($table);die;
$rel = [
'sname' => 0,
'snr' => 1,
@@ -130,7 +162,7 @@ class AsdUs extends AsdCurl
$i++;
}
//debug($data);
//debug($data);die;
$usdates = TableRegistry::get('Usdates');
$usdates->deleteAll('id' > 0);
$entities = $usdates->newEntities($data);
@@ -138,7 +170,7 @@ class AsdUs extends AsdCurl
if(!($result)) {
debug($entities);die;
}
//die;
}
public function save_up_data($ch) {