private function build_difference_zwischenergebnisse($idta_struktur_bericht_zeilen, $label = "TTResult")
 {
     $tempResult = array();
     //the inital result-array, that is used for further calculations
     $ttResults = SBZCollectorRecord::finder()->findAllByidta_struktur_bericht_zeilen($idta_struktur_bericht_zeilen);
     if (count($ttResults) >= 2) {
         //this makes only sence, if we have more than one value...
         foreach ($ttResults as $tResult) {
             $myCalcField = StrukturBerichtZeilenRecord::finder()->findByPK($tResult->row_idta_struktur_bericht_zeilen);
             if (isset($this->zwischenergebnisse[$myCalcField->sbz_label])) {
                 $counter = count($this->zwischenergebnisse[$myCalcField->sbz_label]);
                 for ($ii = 0; $ii < $counter; $ii++) {
                     if (!isset($tempResult[$ii])) {
                         $tempResult[$ii] = 0;
                     }
                     $PreFaktor = 0;
                     $PreFaktor = isset($this->zwischenergebnisse[$myCalcField->sbz_label][$ii]) ? $this->zwischenergebnisse[$myCalcField->sbz_label][$ii] : 0;
                     switch ($tResult->sbz_collector_operator) {
                         case '+':
                             $tempResult[$ii] += $PreFaktor;
                             break;
                         case '-':
                             $tempResult[$ii] -= $PreFaktor;
                             break;
                         case '*':
                             $tempResult[$ii] *= $PreFaktor;
                             break;
                         case '/':
                             $tempResult[$ii] /= $PreFaktor;
                             break;
                         default:
                             $tempResult[$ii] = $PreFaktor;
                             break;
                     }
                 }
             }
         }
         $FirstRow = new TActiveTableRow();
         //after the calculation is done, we need to draw it
         $FirstRow->setID("R" . $this->sheetrow . "G");
         //new for grouping
         $this->resulttable->Rows[] = $FirstRow;
         $ControlListCell = array();
         //clean the children
         $cell = new TActiveTableCell();
         $cell->setID("R" . $this->sheetrow . "C1");
         $cell->Text = $label;
         $cell->EnableViewState = true;
         $ControlListCell[] = array("class" => "TActiveTableCell", "id" => "R" . $this->sheetrow . "C1", "OnCallback" => "", "CommandParameter" => "", "children" => "");
         $FirstRow->Cells[] = $cell;
         $counter = count($tempResult);
         for ($ii = 0; $ii < $counter; $ii++) {
             $cell = new TActiveTableCell();
             $cell->setID("R" . $this->sheetrow . "C" . ($ii + 2));
             $cell->Text = number_format($tempResult[$ii], 0, ',', '.');
             $cell->EnableViewState = true;
             $tempResult[$ii] < 0 ? $cell->setCssClass('negativecell') : '';
             $FirstRow->Cells[] = $cell;
             $ControlListCell[] = array("class" => "TActiveTableCell", "id" => "R" . $this->sheetrow . "C" . ($ii + 2), "OnCallback" => "", "CommandParameter" => "", "children" => "");
         }
         $FirstRow->setCssClass('calculated');
         $this->dynamicControlList[] = array("class" => "TActiveTableRow", "id" => "R" . $this->sheetrow . "G", "OnCallback" => "", "CommandParameter" => "", "children" => $ControlListCell);
         $this->zwischenergebnisse[$label] = $tempResult;
     }
     $this->sheetrow++;
     //now all cells are fixed, so i can count the row up
 }
 public function SBZCOLSavedButtonClicked($sender, $param)
 {
     $tempus = 'SBZCOLed' . $this->SBZCOLprimarykey;
     if ($this->SBZCOLedsbzcollector_edit_status->Text == '1') {
         $SBZCOLeditRecord = SBZCollectorRecord::finder()->findByPK($this->{$tempus}->Text);
     } else {
         $SBZCOLeditRecord = new SBZCollectorRecord();
     }
     //HIDDEN
     foreach ($this->SBZCOLhiddenfields as $recordfield) {
         $edrecordfield = 'SBZCOLed' . $recordfield;
         $SBZCOLeditRecord->{$recordfield} = $this->{$edrecordfield}->Value;
     }
     //DATUM
     foreach ($this->SBZCOLatfields as $recordfield) {
         $edrecordfield = 'SBZCOLed' . $recordfield;
         $SBZCOLeditRecord->{$recordfield} = date('Y-m-d', $this->{$edrecordfield}->TimeStamp);
     }
     //BOOL
     foreach ($this->SBZCOLboolfields as $recordfield) {
         $edrecordfield = 'SBZCOLed' . $recordfield;
         $SBZCOLeditRecord->{$recordfield} = $this->{$edrecordfield}->Checked ? 1 : 0;
     }
     foreach ($this->SBZCOLfields as $recordfield) {
         $edrecordfield = 'SBZCOLed' . $recordfield;
         $SBZCOLeditRecord->{$recordfield} = $this->{$edrecordfield}->Text;
     }
     $SBZCOLeditRecord->save();
     $this->bindListSBZCollectorValue();
 }
 private function build_difference_zwischenergebnisse($idta_struktur_bericht_zeilen, $label = "TTResult")
 {
     $tempResult = array();
     //the inital result-array, that is used for further calculations
     $ttResults = SBZCollectorRecord::finder()->findAllByidta_struktur_bericht_zeilen($idta_struktur_bericht_zeilen);
     if (count($ttResults) >= 2) {
         //this makes only sence, if we have more than one value...
         foreach ($ttResults as $tResult) {
             $myCalcField = StrukturBerichtZeilenRecord::finder()->findByPK($tResult->row_idta_struktur_bericht_zeilen);
             if (isset($this->zwischenergebnisse[$myCalcField->sbz_label])) {
                 $counter = count($this->zwischenergebnisse[$myCalcField->sbz_label]);
                 for ($ii = 0; $ii < $counter; $ii++) {
                     if (!isset($tempResult[$ii])) {
                         $tempResult[$ii] = 0;
                     }
                     $PreFaktor = 0;
                     $PreFaktor = isset($this->zwischenergebnisse[$myCalcField->sbz_label][$ii]) ? $this->zwischenergebnisse[$myCalcField->sbz_label][$ii] : 0;
                     switch ($tResult->sbz_collector_operator) {
                         case '+':
                             $tempResult[$ii] += $PreFaktor;
                             break;
                         case '-':
                             $tempResult[$ii] -= $PreFaktor;
                             break;
                         case '*':
                             $tempResult[$ii] *= $PreFaktor;
                             break;
                         case '/':
                             $tempResult[$ii] /= $PreFaktor;
                             break;
                         default:
                             $tempResult[$ii] = $PreFaktor;
                             break;
                     }
                 }
             }
         }
         $local_column = $this->sheetleftgap;
         $local_cell = '';
         $local_cell = $this->ColumnArray[$local_column] . $this->sheetrow;
         $local_column++;
         $this->sheet->setCellValue($local_cell, $label);
         $this->sheet->getStyle($local_cell)->getNumberFormat()->setFormatCode("_-* #.##0_-;-* #.##0_-;_-* " - "_-;_-@_-");
         $this->workbook->getActiveSheet()->getStyle($local_cell)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
         $this->workbook->getActiveSheet()->getStyle($local_cell)->getFill()->getStartColor()->setRGB('898989');
         $this->workbook->getActiveSheet()->getStyle($local_cell)->getFont()->setSize(10);
         $this->workbook->getActiveSheet()->getStyle($local_cell)->getFont()->getColor()->setRGB('ffffff');
         $counter = count($tempResult);
         //$counter += $local_column; //hier kann es auch verkehrt sein... evtl minus eins
         for ($ii = 0; $ii < $counter; $ii++) {
             $local_cell = $this->ColumnArray[$local_column] . $this->sheetrow;
             $local_column++;
             $this->sheet->setCellValue($local_cell, number_format($tempResult[$ii], 0, '.', ''));
             $this->sheet->getStyle($local_cell)->getNumberFormat()->setFormatCode("_-* #.##0_-;-* #.##0_-;_-* " - "_-;_-@_-");
             $this->workbook->getActiveSheet()->getStyle($local_cell)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
             $tempResult[$ii] < 0 ? $this->workbook->getActiveSheet()->getStyle($local_cell)->getFill()->getStartColor()->setRGB('ff4444') : $this->workbook->getActiveSheet()->getStyle($local_cell)->getFill()->getStartColor()->setRGB('898989');
             $this->workbook->getActiveSheet()->getStyle($local_cell)->getFont()->setSize(10);
             $this->workbook->getActiveSheet()->getStyle($local_cell)->getFont()->getColor()->setRGB('ffffff');
         }
         //$FirstRow->setCssClass('calculated');
         $this->sheetrow++;
         $this->zwischenergebnisse[$label] = $tempResult;
     }
 }