<?php
/**
  * @var \App\View\AppView $this
  */
?>
<div>
    <?= $this->Form->create($employment, ['type' => 'file']) ?>
    <fieldset>
        <legend><?= __('Bitte XML-Datei hochladen.') ?></legend>
        <?php
            echo $this->Form->input('xmldata',['type' => 'file']) ;

        ?>
    </fieldset>
    <?= $this->Form->button(__('Submit')) ?>
    <?= $this->Form->end() ?>
</div>

<?php
//debug($rows_eas);
//debug($data_eas);
if(isset($data))  {
echo '<div style="margin-left:30px">';
$bgcolors = ['ASD' => '#ffcccc', 'ASV' => '#cceeff', 'VIVA' => '#bbccee', 'RELIS' => '#eeeebb', 'EAS' => '#dddddd' ];
//debug($rows);
foreach ($data as $pkz => $parts) {
    echo '<h2>Lehrer PKZ: ' . $pkz . '</h2>';
    echo '<table>';
    $partsize = sizeof($parts);
    $rowsize = sizeof($rows);
    for($i=0;$i<$rowsize;$i++) {
        echo '<tr><td width="280">' . $rows[$i] . '</td>';
        for($j=0;$j<$partsize;$j++) {
            if(isset($parts[$j][$rows[$i]])) {
                if(isset($parts[$j]['IST_NEBENTAETIGKEIT'])  && $parts[$j]['IST_NEBENTAETIGKEIT'] == 0 ) {
                    echo '<td style="width:100px;background-color:' . $bgcolors[$parts[$j]['TYP']] .'"><b>' . $parts[$j][$rows[$i]] . '</b></td>';
                }
                else {
                    echo '<td style="width:100px;background-color:' . $bgcolors[$parts[$j]['TYP']] .'">' . $parts[$j][$rows[$i]] . '</td>';
                }
            }
            else {
                echo '<td style="width:100px;background-color:' . $bgcolors[$parts[$j]['TYP']] .'"></td>';
            }
        }
        echo '</tr>';
    }
    echo '</table>';
    
    if(isset($data_eas[$pkz])) {
        //debug($data_eas[$pkz]);
        echo '<p>EAS</p>';
        echo '<table>';
        $partsize = sizeof($data_eas[$pkz]);
        $rowsize = sizeof($rows_eas);
        for($i=0;$i<$rowsize;$i++) {
            echo '<tr><td width="280">' . $rows_eas[$i] . '</td>';
            for($j=0;$j<$partsize;$j++) {
                //debug($data_eas[$pkz][$j][$rows_eas[$i]]);
                if(isset($data_eas[$pkz][$j][$rows_eas[$i]])) {
                    
                     echo '<td style="width:100px;background-color:' . $bgcolors['EAS'] .'">' . $data_eas[$pkz][$j][$rows_eas[$i]] . '</td>';
                }
                else {
                    echo '<td></td>';
                }
            }
            echo '</tr>';
        }
        echo '</table>';
    }
    echo '<hr style="height:5px;background-color:#efefef" />';
}
echo '</div>';
}
//debug($data);

?>