Esempio n. 1
0
 public function SCRunSeasonsButtonClicked($sender, $param)
 {
     //Step One, find all relevant IDs
     $FieldstToChange = array();
     //inside this array, the fields that needed to be changed are listed
     $idta_variante = $this->Request['idta_variante'];
     $idta_struktur_type = FeldfunktionRecord::finder()->findByidta_feldfunktion($this->sai_idta_feldfunktion->Text)->idta_struktur_type;
     $idta_feldfunktion = $this->sai_idta_feldfunktion->Text;
     $FieldsToChange[] = $idta_feldfunktion;
     //this value needs always to be included
     $this->load_all_cats();
     $SQLINCondition = $this->subCategory_Inlist($this->subcats, $this->sai_idtm_struktur->Text);
     //the two must be replaced with the value from the usermanager
     $sql = "SELECT idtm_struktur FROM tm_struktur WHERE idtm_struktur IN (" . $SQLINCondition . ") AND idta_struktur_type = " . $idta_struktur_type;
     //here I recieve the array of values containing the elements to be changed
     $ElementsToChange = StrukturRecord::finder()->findAllBySQL($sql);
     //before the change can start, I need to identify the affected rows
     $FieldsToChangeBrutto = CollectorRecord::finder()->findAllBycol_idtafeldfunktion($idta_feldfunktion);
     foreach ($FieldsToChangeBrutto as $TmpField) {
         $FieldsToChange[] = $TmpField->idta_feldfunktion;
     }
     $SeasonToWrite = TTSaisonRecord::finder()->findAllByidta_saisonalisierung($this->sai_idta_saisonalisierung->Text);
     foreach ($ElementsToChange as $Element) {
         foreach ($FieldsToChange as $Field) {
             foreach ($SeasonToWrite as $Season) {
                 $year_idta_periode = PeriodenRecord::finder()->find('idta_perioden = ?', PeriodenRecord::finder()->findByPK($Season->idta_periode)->parent_idta_perioden)->per_intern;
                 $sqlYEAR = "SELECT w_wert FROM tt_werte WHERE w_jahr = " . $year_idta_periode . " AND w_monat = " . $year_idta_periode . " AND idtm_struktur = " . $Element->idtm_struktur . " AND w_id_variante = " . $idta_variante . " AND idta_feldfunktion = " . $Field;
                 $YEARValue = WerteRecord::finder()->findBySQL($sqlYEAR)->w_wert;
                 $newMonthValue = $YEARValue * $Season->sai_wert;
                 //$sqlMONTH = "SELECT w_wert FROM tt_werte WHERE w_jahr = ".$year_idta_periode." AND w_monat = ".PeriodenRecord::finder()->findByPK($Season->idta_periode)->per_intern." AND idtm_struktur = ".$Element->idtm_struktur." AND w_id_variante = ".$idta_variante." AND idta_feldfunktion = ".$Field;
                 if (count(WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_idta_periode, PeriodenRecord::finder()->findByPK($Season->idta_periode)->per_intern, $Element->idtm_struktur, $idta_variante, $Field))) {
                     $RecordToUpdate = WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_idta_periode, PeriodenRecord::finder()->findByPK($Season->idta_periode)->per_intern, $Element->idtm_struktur, $idta_variante, $Field);
                     $RecordToUpdate->w_wert = $newMonthValue;
                     $RecordToUpdate->save();
                 }
             }
         }
     }
 }
 public function FCRunSeasonsButtonClicked($sender, $param)
 {
     //Step One, find all relevant IDs
     $FieldstToChange = array();
     //inside this array, the fields that needed to be changed are listed
     $FieldsToKeep = array();
     //inside this array, the fields that needed to be keept are listed
     $idta_variante = $this->Request['idta_variante'];
     $to_idta_variante = $this->for_idta_variante->Text;
     $this->load_ta_perioden($this->for_from_idta_periode->Text, $this->for_to_idta_periode->Text);
     $idta_struktur_type = FeldfunktionRecord::finder()->findByidta_feldfunktion($this->for_idta_feldfunktion->Text)->idta_struktur_type;
     $idta_feldfunktion = $this->for_idta_feldfunktion->Text;
     $FieldsToChange[] = $idta_feldfunktion;
     //this value needs always to be included
     $this->load_all_cats();
     $SQLINCondition = $this->subCategory_Inlist($this->subcats, $this->for_idtm_struktur->Text);
     //the two must be replaced with the value from the usermanager
     $sql = "SELECT idtm_struktur FROM tm_struktur WHERE idtm_struktur IN (" . $SQLINCondition . ") AND idta_struktur_type = " . $idta_struktur_type;
     //here I recieve the array of values containing the elements to be changed
     $ElementsToChange = StrukturRecord::finder()->findAllBySQL($sql);
     //before the change can start, I need to identify the affected rows
     $FieldsToChangeBrutto = CollectorRecord::finder()->findAllBycol_idtafeldfunktion($idta_feldfunktion);
     foreach ($FieldsToChangeBrutto as $TmpField) {
         $FieldsToChange[] = $TmpField->idta_feldfunktion;
     }
     $FieldsToKeepBrutto = FeldfunktionRecord::finder()->findAllByidta_struktur_type($idta_struktur_type);
     foreach ($FieldsToKeepBrutto as $MyTmpField) {
         if (!in_array($MyTmpField->idta_feldfunktion, $FieldsToChange)) {
             $FieldsToKeep[] = $MyTmpField->idta_feldfunktion;
         }
     }
     foreach ($ElementsToChange as $Element) {
         foreach ($this->Perioden as $key => $value) {
             foreach ($FieldsToChange as $Field) {
                 $year_idta_periode = $this->getYearByMonth($key);
                 $sqlYEAR = "SELECT w_wert FROM tt_werte WHERE w_jahr = " . $year_idta_periode . " AND w_monat = " . $key . " AND idtm_struktur = " . $Element->idtm_struktur . " AND w_id_variante = " . $idta_variante . " AND idta_feldfunktion = " . $Field;
                 $YEARValue = WerteRecord::finder()->findBySQL($sqlYEAR)->w_wert;
                 $newValue = $YEARValue * (1 + $this->for_for_faktor->Text / 100);
                 //$sqlMONTH = "SELECT w_wert FROM tt_werte WHERE w_jahr = ".$year_idta_periode." AND w_monat = ".PeriodenRecord::finder()->findByPK($Season->idta_periode)->per_intern." AND idtm_struktur = ".$Element->idtm_struktur." AND w_id_variante = ".$idta_variante." AND idta_feldfunktion = ".$Field;
                 $year_to_idta_periode = $this->getYearByMonth($value);
                 if (count(WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_to_idta_periode, $value, $Element->idtm_struktur, $to_idta_variante, $Field))) {
                     $RecordToUpdate = WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_to_idta_periode, $value, $Element->idtm_struktur, $to_idta_variante, $Field);
                     if ($RecordToUpdate->w_wert != $newValue) {
                         $RecordToUpdate->w_wert = $newValue;
                         $RecordToUpdate->save();
                     }
                 } else {
                     $RecordToWrite = new WerteRecord();
                     $RecordToWrite->w_jahr = $year_to_idta_periode;
                     $RecordToWrite->w_monat = $value;
                     $RecordToWrite->idtm_struktur = $Element->idtm_struktur;
                     $RecordToWrite->w_id_variante = $to_idta_variante;
                     $RecordToWrite->w_wert = $newValue;
                     $RecordToWrite->idta_feldfunktion = $Field;
                     $RecordToWrite->w_dimkey = $this->build_DIMKEY($Element->idtm_struktur);
                     $RecordToWrite->save();
                 }
             }
             foreach ($FieldsToKeep as $Field) {
                 $year_idta_periode = $this->getYearByMonth($key);
                 $sqlYEAR = "SELECT w_wert FROM tt_werte WHERE w_jahr = " . $year_idta_periode . " AND w_monat = " . $key . " AND idtm_struktur = " . $Element->idtm_struktur . " AND w_id_variante = " . $idta_variante . " AND idta_feldfunktion = " . $Field;
                 $YEARValue = WerteRecord::finder()->findBySQL($sqlYEAR)->w_wert;
                 $newValue = $YEARValue;
                 //$sqlMONTH = "SELECT w_wert FROM tt_werte WHERE w_jahr = ".$year_idta_periode." AND w_monat = ".PeriodenRecord::finder()->findByPK($Season->idta_periode)->per_intern." AND idtm_struktur = ".$Element->idtm_struktur." AND w_id_variante = ".$idta_variante." AND idta_feldfunktion = ".$Field;
                 $year_to_idta_periode = $this->getYearByMonth($value);
                 if (count(WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_to_idta_periode, $value, $Element->idtm_struktur, $to_idta_variante, $Field))) {
                     $RecordToUpdate = WerteRecord::finder()->find('w_jahr = ? AND w_monat = ? AND idtm_struktur = ? AND w_id_variante = ? AND idta_feldfunktion = ?', $year_to_idta_periode, $value, $Element->idtm_struktur, $to_idta_variante, $Field);
                     $RecordToUpdate->w_wert = $newValue;
                     $RecordToUpdate->save();
                 } else {
                     $RecordToWrite = new WerteRecord();
                     $RecordToWrite->w_jahr = $year_to_idta_periode;
                     $RecordToWrite->w_monat = $value;
                     $RecordToWrite->idtm_struktur = $Element->idtm_struktur;
                     $RecordToWrite->w_id_variante = $to_idta_variante;
                     $RecordToWrite->w_wert = $newValue;
                     $RecordToWrite->idta_feldfunktion = $Field;
                     $RecordToWrite->w_dimkey = $this->build_DIMKEY($Element->idtm_struktur);
                     $RecordToWrite->save();
                 }
             }
         }
     }
 }
 public function COLSavedButtonClicked($sender, $param)
 {
     $tempus = 'COLed' . $this->COLprimarykey;
     if ($this->COLedcollector_edit_status->Text == '1') {
         $COLeditRecord = CollectorRecord::finder()->findByPK($this->{$tempus}->Text);
     } else {
         $COLeditRecord = new CollectorRecord();
     }
     //HIDDEN
     foreach ($this->COLhiddenfields as $recordfield) {
         $edrecordfield = 'COLed' . $recordfield;
         $COLeditRecord->{$recordfield} = $this->{$edrecordfield}->Value;
     }
     //DATUM
     foreach ($this->COLatfields as $recordfield) {
         $edrecordfield = 'COLed' . $recordfield;
         $COLeditRecord->{$recordfield} = date('Y-m-d', $this->{$edrecordfield}->TimeStamp);
     }
     //BOOL
     foreach ($this->COLboolfields as $recordfield) {
         $edrecordfield = 'COLed' . $recordfield;
         $COLeditRecord->{$recordfield} = $this->{$edrecordfield}->Checked ? 1 : 0;
     }
     foreach ($this->COLfields as $recordfield) {
         $edrecordfield = 'COLed' . $recordfield;
         $COLeditRecord->{$recordfield} = $this->{$edrecordfield}->Text;
     }
     $COLeditRecord->save();
     $this->bindListCollectorValue();
 }
Esempio n. 4
0
 private function check_collector($ffid, $field, $local_prefix, $month, $local_jahr, $local_id)
 {
     $myfieldfunk = '';
     $myfieldfunkrev = '';
     $tresult = CollectorRecord::finder()->findAllBySql("SELECT ta_collector.idta_feldfunktion,col_idtafeldfunktion,col_operator,ta_feldfunktion.ff_type AS ff_type FROM ta_collector INNER JOIN ta_feldfunktion ON ta_collector.idta_feldfunktion = ta_feldfunktion.idta_feldfunktion WHERE ta_collector.col_idtafeldfunktion = '" . $ffid . "'");
     foreach ($tresult as $trecord) {
         if (FeldfunktionRecord::finder()->findByPK($trecord->idta_feldfunktion)->ff_calcopening) {
             $this->calcOB = 1;
             $this->calcOBID = $trecord->idta_feldfunktion;
         }
         if ($trecord->ff_type == 6) {
             $this->calcPayables($this->piq_idta_struktur_type, $trecord->idta_feldfunktion, $local_id, $local_jahr, $local_prefix);
         } elseif ($trecord->ff_type == 4) {
             $this->calcOpeningBalance($this->piq_idta_struktur_type, $trecord->idta_feldfunktion, $local_id);
         } else {
             $this->run_collector($trecord->idta_feldfunktion, $field, $local_prefix, $month, $local_jahr, $local_id);
             $myfieldfunk = $trecord->idta_feldfunktion;
             if ($myfieldfunk != '') {
                 //AND $myfieldfunk!='3'){
                 if (FeldfunktionRecord::finder()->findByPK($myfieldfunk)->ff_type == 5) {
                     $mymonth = $this->getMaxPerIntern($local_jahr);
                     $previousField = "RLIQXXX" . $local_jahr . "XXX" . $mymonth . "XXX" . $this->piq_idta_struktur_type . "XXX" . $myfieldfunk . "XXX" . $local_id;
                     $valuefillin = $this->page->ACTPanel->FindControl($previousField)->Text;
                     $this->update_w_wert($local_jahr, $local_jahr, $this->piq_idta_struktur_type, $myfieldfunk, $local_id, $valuefillin);
                     $resultField = "RLIQXXX" . $local_jahr . "XXX" . $local_jahr . "XXX" . $this->piq_idta_struktur_type . "XXX" . $myfieldfunk . "XXX" . $local_id;
                     $this->page->ACTPanel->FindControl($resultField)->Text = number_format($valuefillin, $this->NumberOfDigits, '.', '');
                 } else {
                     if ($this->SinglePeriode == 0) {
                         $this->update_w_wert($local_jahr, $local_jahr, $this->piq_idta_struktur_type, $myfieldfunk, $local_id, $this->sum_up($local_jahr, $month, $myfieldfunk, $local_id));
                         //hier muss ich definieren, ob der wert in summe oben an kommt, oder nur der absolute wert
                         $resultField = "RLIQXXX" . $local_jahr . "XXX" . $local_jahr . "XXX" . $this->piq_idta_struktur_type . "XXX" . $myfieldfunk . "XXX" . $local_id;
                         $this->page->ACTPanel->FindControl($resultField)->Text = number_format($this->sum_up($local_jahr, $month, $myfieldfunk, $local_id), $this->NumberOfDigits, '.', '');
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
 private function run_collector($local_ff, $local_monat, $local_jahr, $local_id)
 {
     $tresult = CollectorRecord::finder()->findAllBySql("SELECT col_idtafeldfunktion,col_operator FROM ta_collector WHERE idta_feldfunktion = '" . $local_ff . "'");
     $fields = array();
     $operators = array();
     $tempresult = 0;
     $i = 0;
     foreach ($tresult as $trecord) {
         $myWerteString = $local_jahr . "xxx" . $local_monat . "xxx" . $trecord->col_idtafeldfunktion . "xxx" . $local_id;
         $fields[$i] = isset($this->TTWERTE[$myWerteString]) ? $this->TTWERTE[$myWerteString] : 0;
         $operators[$i] = $trecord->col_operator;
         $i++;
     }
     $j = 0;
     foreach ($fields as $myfield) {
         switch ($operators[$j++]) {
             case '+':
                 $tempresult += $myfield;
                 break;
             case '-':
                 $tempresult -= $myfield;
                 break;
             case '*':
                 $tempresult *= $myfield;
                 break;
             case '/':
                 $tempresult /= $myfield;
                 break;
             default:
                 $tempresult = $myfield;
                 break;
         }
     }
     //echo "Sp10x";
     $this->update_w_wert($local_jahr, $local_monat, $local_ff, $local_id, $tempresult);
 }