示例#1
0
 function constrByMask($pvdzID)
 {
     $tmp_rowCount = 1;
     $tilpums_bruto_KOPA = 0;
     $tilpums_virsmers_KOPA = 0;
     $tilpums_redukcija_KOPA = 0;
     $tilpums_neto_KOPA = 0;
     $tilpums_brakis_KOPA = 0;
     $tmp_balkuSkaits = 0;
     $tilpums_skaits_brakis_KOPA = 0;
     $bbq_temp = false;
     $tmp_arrCollName['nosaukums'] = 1;
     $tmp_arrCollName['suga'] = "Suga";
     $tmp_arrCollName['skira'] = "Šķira";
     $tmp_arrCollName['diametrs'] = "Diametrs";
     $tmp_arrCollName['garums'] = "Garums";
     $tmp_arrCollName['brakis_kods'] = "Brāķa iemesls";
     $tmp_arrCollName['skaits'] = "Skaits";
     $tmp_arrCollName['bruto'] = "Bruto";
     $tmp_arrCollName['virsmers'] = "Virsmērs";
     $tmp_arrCollName['redukcija'] = "Redukcija";
     $tmp_arrCollName['redukcija_un_virsmers'] = "Red. un virsm.";
     $tmp_arrCollName['brakis'] = "Brāķis";
     $tmp_arrCollName['neto'] = "Neto";
     $tmp_arrCollName['brakis_un_neto'] = "Brāķis un Neto";
     $tmp_getDataQuery_txt = "SELECT * FROM " . $this->tblName . "balkis_temp WHERE pavadzime = " . $pvdzID . " ORDER BY mind_pirms_red";
     if (!$pvdzID) {
         $tmp_getDataQuery_txt = "SELECT * FROM " . $this->tblName . "balkis_temp ORDER BY mind_pirms_red";
         $bbq_temp = true;
     }
     $tmp_getDataQuery_query = mysql_query($tmp_getDataQuery_txt);
     /*  
       While($tmp_getDataQuery_arr_tmp = mysql_fetch_assoc($tmp_getDataQuery_query)){
         $tmp_getDataQuery_arr_tmp_first[] = $tmp_getDataQuery_arr_tmp;
         $tmp_getDataQuery_arr_tmp_second[] = $tmp_getDataQuery_arr_tmp;
       }
       
       $tmp_getDataQuery_arr_tmp_third = array_chunk($tmp_getDataQuery_arr_tmp_second,500);
       foreach($tmp_getDataQuery_arr_tmp_third as $item_ttt){
            
       foreach($item_ttt as $tmp_getDataQuery_arr){
     */
     /*
       $part_count = 0;
       $tmp_getDataQuery_txt_temp = run_mysql_by_partitions($part_count,$tmp_getDataQuery_txt);
       $tmp_getDataQuery_query = mysql_query($tmp_getDataQuery_txt_temp);
     
       while(mysql_num_rows($tmp_getDataQuery_query) > 1){
       $tmp_getDataQuery_txt_temp = run_mysql_by_partitions($part_count,$tmp_getDataQuery_txt);
       $tmp_getDataQuery_query = mysql_query($tmp_getDataQuery_txt_temp);
       
         $part_count++;
     */
     while ($tmp_getDataQuery_arr = mysql_fetch_assoc($tmp_getDataQuery_query)) {
         $tilpums_bruto = 0;
         $tilpums_virsmers = 0;
         $tilpums_redukcija = 0;
         $tilpums_neto = 0;
         $tilpums_brakis = 0;
         $isBrakaVirsmOn = $this->MyPOST['braka_virsmers'];
         if ($tmp_getDataQuery_arr['pavadzime'] == 76806 && $this->firmCode == 2) {
             $isBrakaVirsmOn = 'off';
         }
         //-#001-FUNC-START--Nepieciešamo datu kolekcionēšana no datubāzes------------------------------------------------------------------------------------
         $tmp_ident_balkis = $tmp_getDataQuery_arr['id'];
         $var_Suga = $tmp_getDataQuery_arr['suga'];
         $tmp_tilpumsBruto = $tmp_getDataQuery_arr['tilpums'];
         $tmp_tilpumsNeto = $tmp_getDataQuery_arr['tilpums_scan'];
         $tmp_garums_pirms_red = $tmp_getDataQuery_arr['garums'];
         $tmp_garums_pec_red = $tmp_getDataQuery_arr['gar_pec_red'];
         $tmp_tievgalis_pirms_red = $tmp_getDataQuery_arr['mind_pirms_red'];
         $tmp_tievgalis_pec_red = $tmp_getDataQuery_arr['mind_pec_red'];
         $tmp_vidusdiametrs_pirms_red = $tmp_getDataQuery_arr['mind_miza'];
         $tmp_vidusdiametrs_pec_red = $tmp_getDataQuery_arr['mind_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
         $tmp_resgalis_pirms_red = $tmp_getDataQuery_arr['maxd_miza'];
         $tmp_resgalis_pec_red = $tmp_getDataQuery_arr['maxd_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
         //-#001-FUNC-END------------------------------------------------------------------------------------------------------------------------------------
         //-#002-FUNC-START--Nepieciešamās grupas atrašana---------------------------------------------------------------------------------------------------
         $igc = 1;
         // Grupu skaits
         $init_Group = false;
         while ($igc < 9 && $init_Group == false) {
             $tmp_igcCheck = 0;
             for ($igo = 1; $igo < 6; $igo++) {
                 //Grupēšanas nosacījumus cikls
                 for ($subcount = 0; $subcount < 3; $subcount++) {
                     if ($this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount]) {
                         $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount];
                         if (!$this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][0]) {
                             $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$var_Suga];
                         }
                         $tmp_ALLbResult = $this->getMaskGroup($tmp_SubResult, $tmp_getDataQuery_arr[$this->GroupOrder[$igo]], $this->GroupOrder[$igo]);
                         $tmp_inputArrVal[$this->GroupOrder[$igo]] = $tmp_ALLbResult;
                         if ($tmp_ALLbResult != '') {
                             $tmp_igcCheck = $tmp_igcCheck + 1;
                         }
                     } else {
                         $tmp_igcCheck = $tmp_igcCheck + 1;
                     }
                 }
                 if ($igo == 5 && $tmp_igcCheck == 15) {
                     // Grupas noteikšana līdz pirmajiem sakritības rezultātiem (rekursija ar limitētu ciklu skaitu)
                     $init_Group = true;
                     $globalGroupIdent = $igc;
                 }
             }
             $igc++;
         }
         //-#002-FUNC-END-------------------------------------------------------------------------------------------------------------------------------------
         //-#003-FUNC-START--Tilpuma aprēķināšana-------------------------------------------------------------------------------------------------------------
         $prnt_Nosaukums = 0;
         $prnt_Suga = $this->sugas[$var_Suga]['LAT'];
         $prnt_Skira = $tmp_getDataQuery_arr['skira'];
         $prnt_Brakis = $this->braki[$tmp_getDataQuery_arr['brakis']]['LAT'];
         $prnt_Diametrs = $tmp_inputArrVal['mind_pirms_red'];
         $prnt_Garums = $tmp_inputArrVal['garums'];
         //---------------------------------------------------------------------------------------------------------------------------------------------------
         if ($this->firmCode == 35 && $prnt_Skira == 3) {
             $prnt_Skira = 9;
             $prnt_Brakis = $this->braki['010']['LAT'];
         }
         //---------------------------------------------------------------------------------------------------------------------------------------------------
         if ($this->MyPOST['noapalot_garumu'] == '1') {
             $tmp_garums_pirms_red = floor($tmp_garums_pirms_red / 10) * 10;
         } elseif ($this->MyPOST['noapalot_garumu'] == '2') {
             $tmp_garums_pirms_red = (floor($tmp_garums_pirms_red / 10) + 0.5) * 10;
         }
         $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][0];
         if (!$tmp_raukumaRinda) {
             $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][$var_Suga];
         }
         $raukums = raukums_2_array($tmp_raukumaRinda);
         $rauk_koef = get_raukums_no_diam($raukums, $tmp_tievgalis_pirms_red);
         $tmp_DiamRedukcija = $tmp_tievgalis_pirms_red - $tmp_tievgalis_pec_red;
         $tilpums_bruto = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
         if ($this->MyPOST['noapalot_diametru'] == 'on') {
             $tmp_tievgalis_pec_red = (floor($tmp_tievgalis_pec_red / 10) + 0.5) * 100;
         }
         $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][0];
         if (!$tmp_virsmeraRinda) {
             $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][$var_Suga];
         }
         $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][0];
         if (!$tmp_virsmeraRindaBrakis) {
             $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][$var_Suga];
         }
         if ($tmp_virsmeraRindaBrakis) {
             $virsmeri_brakim = explode(',', $tmp_virsmeraRindaBrakis);
             for ($i = 0; $i < count($virsmeri_brakim); $i++) {
                 $virsmeri_brakim[$i] = $virsmeri_brakim[$i];
             }
         }
         $virsmeri = explode(',', $tmp_virsmeraRinda);
         for ($i = 0; $i < count($virsmeri); $i++) {
             $virsmeri[$i] = $virsmeri[$i];
         }
         $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][0];
         if (!$tmp_mini_virsmeraRinda) {
             $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][$var_Suga];
         }
         $tmp_nom_garums_pirms_red = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri, $tmp_mini_virsmeraRinda);
         $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
         if ($this->MyPOST['is_vika'] == 'on') {
             $tmp_garums_pec_red = $tmp_garums_pec_red + $tmp_mini_virsmeraRinda;
             $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
             $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
             $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
         } else {
             $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
             $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
         }
         if ($this->MyPOST['metode'] == 4) {
             if ($this->firmCode == 27) {
                 $tilpums_bruto = floor($tmp_tilpumsBruto / 10) / 1000;
                 $tilpums_neto = floor($tmp_tilpumsNeto / 10) / 1000;
                 $tilpums_bruto_virsmeram = floor($tmp_tilpumsNeto / 10) / 1000;
                 $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                 $tilpums_redukcija = 0;
             } else {
                 $tilpums_bruto = $tmp_tilpumsBruto;
                 $tilpums_neto = $tmp_tilpumsNeto;
                 $tilpums_bruto_virsmeram = $tmp_tilpumsNeto;
                 $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                 $tilpums_redukcija = 0;
             }
         }
         if ($tilpums_virsmers < 0) {
             $tilpums_virsmers = 0;
         }
         if ($tilpums_bruto_virsmeram == 0) {
             $tilpums_virsmers = 0;
         }
         if ($tilpums_redukcija < 0) {
             $tilpums_redukcija = 0;
         }
         //-#003-FUNC-END--------------------------------------------------------------------------------------------------------------------------------------
         //-#004-FUNC-START--Papildus dimensijas brāķa priešķiršana--------------------------------------------------------------------------------------------
         $takeReCallOn4 = false;
         if ($tmp_nom_garums_pec_red < 1 && !$prnt_Brakis) {
             $prnt_Skira = 9;
             $prnt_Brakis = $this->braki['899']['LAT'];
             $takeReCallOn4 = true;
         }
         if (substr($prnt_Diametrs, 0, 1) == 'b' && !$prnt_Brakis) {
             $prnt_Skira = 9;
             $prnt_Brakis = $this->braki['899']['LAT'];
             $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
             $takeReCallOn4 = true;
         }
         if (substr($prnt_Garums, 0, 1) == 'b' && !$prnt_Brakis) {
             $prnt_Skira = 9;
             $prnt_Brakis = $this->braki['899']['LAT'];
             $prnt_Garums = str_replace('b', '', $prnt_Garums);
             $takeReCallOn4 = true;
         }
         if ($prnt_Brakis == 'D') {
             // XML nobrāķēšana ar 4 kodu
             $takeReCallOn4 = true;
         }
         if ($takeReCallOn4) {
             $tmp_is4 = mod_ResignLVMRejectCode($this->firmCode, $tmp_getDataQuery_arr['garums'], $tmp_getDataQuery_arr['mind_pirms_red'], $tmp_getDataQuery_arr['suga'], $tmp_getDataQuery_arr['skira']);
             if ($tmp_is4) {
                 $prnt_Brakis = $this->braki['856']['LAT'];
             }
         }
         //-#004-FUNC-END-----------------------------------------------------------------------------------------------------
         //-#005-FUNC-START--Brāķa tilpuma aprēķināšana---------------------------------------------------------------------------------------------------
         if ($prnt_Brakis) {
             $tilpums_neto = 0;
             $tilpums_redukcija = 0;
             if ($isBrakaVirsmOn == 'on') {
                 if ($virsmeri_brakim) {
                     $tmp_nom_garums_pirms_red_brakim = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri_brakim, $tmp_mini_virsmeraRinda);
                     $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red_brakim, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                     if ($tilpums_bruto_virsmeram > 0) {
                         $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                         $tilpums_brakis = $tilpums_bruto_virsmeram;
                     } else {
                         $tilpums_virsmers = 0;
                         $tilpums_brakis = $tilpums_bruto;
                     }
                 } else {
                     if ($tilpums_bruto_virsmeram > 0) {
                         $tilpums_brakis = $tilpums_bruto_virsmeram;
                     } else {
                         $tilpums_virsmers = 0;
                         $tilpums_brakis = $tilpums_bruto;
                     }
                 }
             } else {
                 $tilpums_virsmers = 0;
                 $tilpums_brakis = $tilpums_bruto;
             }
         }
         $tmp_inputArrVal['mind_pirms_red'] = str_replace('b', '', $tmp_inputArrVal['mind_pirms_red']);
         $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
         $tmp_inputArrVal['garums'] = str_replace('b', '', $tmp_inputArrVal['garums']);
         $prnt_Garums = str_replace('b', '', $prnt_Garums);
         //-#005-FUNC-END-----------------------------------------------------------------------------------------------------
         //-#006-FUNC-START--Vienādo grupēšanu pāskats---------------------------------------------------------------------------------------------------
         $pilnaGrupesana = false;
         if ($this->report_XML) {
             $pilnaGrupesana = true;
         }
         if (($this->firmCode == 16 || $this->firmCode == 18 || $this->isAllReport) && !$this->report_PDF) {
             $pilnaGrupesana = true;
         }
         $rowExist = 0;
         if (!$pilnaGrupesana) {
             for ($protoKey = $tmp_rowCount - 1; $protoKey > 0; $protoKey--) {
                 if ($this->arrPrintOut[$protoKey]['suga'] == $prnt_Suga) {
                     if ($this->arrPrintOut[$protoKey]['skira'] == $prnt_Skira) {
                         if ($this->arrPrintOut[$protoKey]['diametrs'] == $prnt_Diametrs) {
                             if ($this->arrPrintOut[$protoKey]['brakis_kods'] == $prnt_Brakis) {
                                 $rowExist = $protoKey;
                             }
                         }
                     }
                 }
             }
         } else {
             for ($protoKey = $tmp_rowCount - 1; $protoKey > 0; $protoKey--) {
                 if ($this->arrPrintOut[$protoKey]['suga'] == $prnt_Suga) {
                     if ($this->arrPrintOut[$protoKey]['skira'] == $prnt_Skira) {
                         if ($this->arrPrintOut[$protoKey]['diametrs'] == $prnt_Diametrs) {
                             if ($this->arrPrintOut[$protoKey]['garums'] == $prnt_Garums) {
                                 if ($this->arrPrintOut[$protoKey]['brakis_kods'] == $prnt_Brakis) {
                                     $rowExist = $protoKey;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //-#006-FUNC-END-----------------------------------------------------------------------------------------------------
         //-#007-FUNC-START--Statisko vērtību ievietošana---------------------------------------------------------------------------------------------------
         $insertRow = $tmp_rowCount;
         if ($rowExist != 0) {
             $insertRow = $rowExist;
         }
         $this->arrPrintOut[$insertRow]['nosaukums'] = 0;
         $this->arrPrintOut[$insertRow]['suga'] = $prnt_Suga;
         $this->arrPrintOut[$insertRow]['skira'] = $prnt_Skira;
         $this->arrPrintOut[$insertRow]['diametrs'] = $prnt_Diametrs;
         $this->arrPrintOut[$insertRow]['garums'] = $prnt_Garums;
         $this->arrPrintOut[$insertRow]['brakis_kods'] = $prnt_Brakis;
         if ($this->report_XML) {
             $this->arrPrintOut[$insertRow]['diametrs_tmp'] = $tmp_getDataQuery_arr['mind_pirms_red'];
             $this->arrPrintOut[$insertRow]['garums_tmp'] = $tmp_getDataQuery_arr['garums'];
         }
         $this->arrPrintOut[$insertRow]['skaits'] += 1;
         if ($this->arrPrintOut[$insertRow]['brakis_kods'] != '') {
             $tilpums_skaits_brakis_KOPA += 1;
         }
         //-#007-FUNC-END-----------------------------------------------------------------------------------------------------
         //-#008-FUNC-START--Dinamisko vērtību piešķiršana---------------------------------------------------------------------------------------------------
         $this->arrPrintOut[$insertRow]['bruto'] += $tilpums_bruto;
         $this->arrPrintOut[$insertRow]['virsmers'] += $tilpums_virsmers;
         $this->arrPrintOut[$insertRow]['redukcija'] += $tilpums_redukcija;
         $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] += $tilpums_bruto - $tilpums_neto;
         $this->arrPrintOut[$insertRow]['brakis'] += $tilpums_brakis;
         $this->arrPrintOut[$insertRow]['neto'] += $tilpums_neto;
         $this->arrPrintOut[$insertRow]['brakis_un_neto'] += $tilpums_neto + $tilpums_brakis;
         //------------------------------------------------------------------------------------------------------
         if ($this->arrPrintOut[$insertRow]['bruto'] != '') {
             $this->arrPrintOut[$insertRow]['bruto'] = number_format($this->arrPrintOut[$insertRow]['bruto'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['bruto'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['virsmers'] != '') {
             $this->arrPrintOut[$insertRow]['virsmers'] = number_format($this->arrPrintOut[$insertRow]['virsmers'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['virsmers'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['redukcija'] != '') {
             $this->arrPrintOut[$insertRow]['redukcija'] = number_format($this->arrPrintOut[$insertRow]['redukcija'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['redukcija'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] != '') {
             $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = number_format($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['brakis'] != '') {
             $this->arrPrintOut[$insertRow]['brakis'] = number_format($this->arrPrintOut[$insertRow]['brakis'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['brakis'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['neto'] != '') {
             $this->arrPrintOut[$insertRow]['neto'] = number_format($this->arrPrintOut[$insertRow]['neto'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['neto'] = '';
         }
         if ($this->arrPrintOut[$insertRow]['brakis_un_neto'] != '') {
             $this->arrPrintOut[$insertRow]['brakis_un_neto'] = number_format($this->arrPrintOut[$insertRow]['brakis_un_neto'], 3, '.', '');
         } else {
             $this->arrPrintOut[$insertRow]['brakis_un_neto'] = '';
         }
         //------------------------------------------------------------------------------------------------------
         $tilpums_bruto_KOPA = $tilpums_bruto_KOPA + $tilpums_bruto;
         $tilpums_virsmers_KOPA = $tilpums_virsmers_KOPA + $tilpums_virsmers;
         $tilpums_redukcija_KOPA = $tilpums_redukcija_KOPA + $tilpums_redukcija;
         $tilpums_neto_KOPA = $tilpums_neto_KOPA + $tilpums_neto;
         $tilpums_brakis_KOPA = $tilpums_brakis_KOPA + $tilpums_brakis;
         $tmp_balkuSkaits++;
         $tmp_rowCount++;
     }
     //  }
     //-#008-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#009-FUNC-START--Rindu pārgrupēšana masīvā---------------------------------------------------------------------------------------------------
     if (($this->firmCode == 16 || $this->firmCode == 20 || $this->isAllReport) && !$this->report_PDF && !$this->report_XML) {
         $this->arrPrintOut = array_orderby($this->arrPrintOut, 'suga', SORT_ASC, 'skira', SORT_ASC, 'diametrs', SORT_ASC, 'garums', SORT_ASC, 'brakis_kods', SORT_ASC);
     } else {
         $this->arrPrintOut = array_orderby($this->arrPrintOut, 'suga', SORT_ASC, 'skira', SORT_ASC, 'diametrs', SORT_ASC, 'brakis_kods', SORT_ASC);
     }
     array_unshift($this->arrPrintOut, $tmp_arrCollName);
     //-#009-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#010-FUNC-START--Kopsummas rindas pievienošana---------------------------------------------------------------------------------------------------
     $this->arrPrintOut[$tmp_rowCount]['nosaukums'] = 1;
     $this->arrPrintOut[$tmp_rowCount]['suga'] = "";
     $this->arrPrintOut[$tmp_rowCount]['skira'] = "";
     $this->arrPrintOut[$tmp_rowCount]['diametrs'] = "";
     $this->arrPrintOut[$tmp_rowCount]['garums'] = "";
     $this->arrPrintOut[$tmp_rowCount]['brakis_kods'] = "";
     $this->arrPrintOut[$tmp_rowCount]['skaits'] = $tmp_balkuSkaits;
     $this->arrPrintOut[$tmp_rowCount]['bruto'] = number_format($tilpums_bruto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['virsmers'] = number_format($tilpums_virsmers_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['redukcija'] = number_format($tilpums_redukcija_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['redukcija_un_virsmers'] = number_format($tilpums_bruto_KOPA - $tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['brakis'] = number_format($tilpums_brakis_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['neto'] = number_format($tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['brakis_un_neto'] = number_format($tilpums_brakis_KOPA + $tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->regSuperSum['bruto'] = $tilpums_bruto_KOPA;
     $this->regSuperSum['virsmers'] = $tilpums_virsmers_KOPA;
     $this->regSuperSum['redukcija'] = $tilpums_redukcija_KOPA;
     $this->regSuperSum['brakis'] = $tilpums_brakis_KOPA;
     $this->regSuperSum['neto'] = $tilpums_neto_KOPA;
     $this->regSuperSum['skaits'] = $tmp_balkuSkaits;
     $this->regSuperSum['skaits_brakis'] = $tilpums_skaits_brakis_KOPA;
     //-#010-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#011-FUNC-START-END-Rezultāts---------------------------------------------------------------------------------------------------
     //    fb($this->arrPrintOut,'arrPrintOut');
     //  break;
     return true;
 }
示例#2
0
 function constrByMask($pvdzID)
 {
     $tmp_rowCount = 1;
     $tilpums_bruto_KOPA = 0;
     $tilpums_virsmers_KOPA = 0;
     $tilpums_redukcija_KOPA = 0;
     $tilpums_neto_KOPA = 0;
     $tilpums_brakis_KOPA = 0;
     $tmp_balkuSkaits = 0;
     $tilpums_skaits_brakis_KOPA = 0;
     $bbq_temp = false;
     $liguma_matrica = '';
     $tmp_arrCollName['nosaukums'] = 1;
     $tmp_arrCollName['suga'] = "Suga";
     $tmp_arrCollName['skira'] = "Šķira";
     $tmp_arrCollName['diametrs'] = "Diametrs";
     $tmp_arrCollName['garums'] = "Garums";
     $tmp_arrCollName['brakis_kods'] = "Brāķa iemesls";
     $tmp_arrCollName['skaits'] = "Skaits";
     $tmp_arrCollName['bruto'] = "Bruto";
     $tmp_arrCollName['virsmers'] = "Virsmērs";
     $tmp_arrCollName['redukcija'] = "Redukcija";
     $tmp_arrCollName['redukcija_un_virsmers'] = "Red. un virsm.";
     $tmp_arrCollName['brakis'] = "Brāķis";
     $tmp_arrCollName['neto'] = "Neto";
     $tmp_arrCollName['brakis_un_neto'] = "Brāķis un Neto";
     $tmp_lig_matrica_txt = "SELECT `cenu_matrica` FROM " . $this->tblName . "pavadzime WHERE `id` = {$pvdzID}";
     $tmp_lig_matrica_mysql = mysql_query($tmp_lig_matrica_txt);
     while ($tmp_lig_matrica_arr = mysql_fetch_assoc($tmp_lig_matrica_mysql)) {
         $liguma_matrica = trim($tmp_lig_matrica_arr['cenu_matrica']);
     }
     $tmp_getDataQuery_txt = "SELECT * FROM " . $this->tblName . "balkis_temp WHERE pavadzime = " . $pvdzID . " ORDER BY mind_pirms_red";
     if (!$pvdzID) {
         $tmp_getDataQuery_txt = "SELECT * FROM " . $this->tblName . "balkis_temp ORDER BY mind_pirms_red";
         $bbq_temp = true;
         $trunc_SQL = "DELETE FROM `global_kops_atsk`";
         mysql_query($trunc_SQL);
     }
     $tmp_getDataQuery_query = mysql_query($tmp_getDataQuery_txt);
     if ($bbq_temp == false) {
         while ($tmp_getDataQuery_arr = mysql_fetch_assoc($tmp_getDataQuery_query)) {
             $tilpums_bruto = 0;
             $tilpums_virsmers = 0;
             $tilpums_redukcija = 0;
             $tilpums_neto = 0;
             $tilpums_brakis = 0;
             $apmaksas_garums = 0;
             $isBrakaVirsmOn = $this->MyPOST['braka_virsmers'];
             if ($tmp_getDataQuery_arr['pavadzime'] == 76806 && $this->firmCode == 2) {
                 $isBrakaVirsmOn = 'off';
             }
             //-#001-FUNC-START--Nepieciešamo datu kolekcionēšana no datubāzes------------------------------------------------------------------------------------
             $tmp_ident_balkis = $tmp_getDataQuery_arr['id'];
             $var_Suga = (string) $tmp_getDataQuery_arr['suga'];
             //      if($var_Suga == 0){$var_Suga = '0';}
             //      die('test');
             $varDateTime = $tmp_getDataQuery_arr['datums_laiks'];
             $tmp_tilpumsBruto = $tmp_getDataQuery_arr['tilpums'];
             $tmp_tilpumsNeto = $tmp_getDataQuery_arr['tilpums_scan'];
             $tmp_garums_pirms_red = $tmp_getDataQuery_arr['garums'];
             $tmp_garums_pec_red = $tmp_getDataQuery_arr['gar_pec_red'];
             $tmp_tievgalis_pirms_red = $tmp_getDataQuery_arr['mind_pirms_red'];
             $tmp_tievgalis_pec_red = $tmp_getDataQuery_arr['mind_pec_red'];
             $tmp_vidusdiametrs_pirms_red = $tmp_getDataQuery_arr['mind_miza'];
             $tmp_vidusdiametrs_pec_red = $tmp_getDataQuery_arr['mind_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
             $tmp_resgalis_pirms_red = $tmp_getDataQuery_arr['maxd_miza'];
             $tmp_resgalis_pec_red = $tmp_getDataQuery_arr['maxd_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
             //-#001-FUNC-END------------------------------------------------------------------------------------------------------------------------------------
             if ($this->firmCode == 26 && $liguma_matrica == 'AC' && $tmp_getDataQuery_arr['skira'] == 'E' && $tmp_getDataQuery_arr['mind_pirms_red'] > 130 && $tmp_getDataQuery_arr['mind_pirms_red'] < 180) {
                 $tmp_getDataQuery_arr['skira'] = 'B';
             }
             //  fb($this->GroupOrder,'GroupOrder');
             //-#002-FUNC-START--Nepieciešamās grupas atrašana---------------------------------------------------------------------------------------------------
             $igc = 1;
             // Grupu skaits
             $init_Group = false;
             while ($igc < 9 && $init_Group == false) {
                 $tmp_igcCheck = 0;
                 for ($igo = 1; $igo < 6; $igo++) {
                     //Grupēšanas nosacījumus cikls
                     for ($subcount = 0; $subcount < 3; $subcount++) {
                         if ($this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount]) {
                             $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount];
                             if (!$this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][0]) {
                                 $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$var_Suga];
                             }
                             //              echo $this->GroupOrder[$igo].'<br />';
                             $tmp_ALLbResult = $this->getMaskGroup($tmp_SubResult, $tmp_getDataQuery_arr[$this->GroupOrder[$igo]], $this->GroupOrder[$igo]);
                             $tmp_inputArrVal[$this->GroupOrder[$igo]] = $tmp_ALLbResult;
                             if ($tmp_ALLbResult != '') {
                                 $tmp_igcCheck = $tmp_igcCheck + 1;
                             }
                         } else {
                             $tmp_igcCheck = $tmp_igcCheck + 1;
                         }
                     }
                     if ($igo == 5 && $tmp_igcCheck == 15) {
                         // Grupas noteikšana līdz pirmajiem sakritības rezultātiem (rekursija ar limitētu ciklu skaitu)
                         $init_Group = true;
                         $globalGroupIdent = $igc;
                     }
                 }
                 $igc++;
             }
             //      echo $globalGroupIdent.'<br/>';
             //-#002-FUNC-END-------------------------------------------------------------------------------------------------------------------------------------
             //-#003-FUNC-START--Tilpuma aprēķināšana-------------------------------------------------------------------------------------------------------------
             $prnt_Nosaukums = 0;
             $prnt_Suga = $this->sugas[$var_Suga]['LAT'];
             $prnt_Skira = $tmp_getDataQuery_arr['skira'];
             $prnt_Brakis = $this->braki[$tmp_getDataQuery_arr['brakis']]['LAT'];
             $prnt_Diametrs = $tmp_inputArrVal['mind_pirms_red'];
             $prnt_Garums = $tmp_inputArrVal[$this->garGrupa];
             //      echo $prnt_Garums.'<br/>';
             //      echo $this->garGrupa;
             //      $prnt_Garums = $tmp_inputArrVal['garums'];
             //---------------------------------------------------------------------------------------------------------------------------------------------------
             if ($this->firmCode == 35 && $prnt_Skira == 3) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['010']['LAT'];
             }
             if ($this->firmCode == 37 && $prnt_Skira == 3) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['011']['LAT'];
             }
             //---------------------------------------------------------------------------------------------------------------------------------------------------
             if ($this->MyPOST['noapalot_garumu'] == '1') {
                 $tmp_garums_pirms_red = floor($tmp_garums_pirms_red / 10) * 10;
             } elseif ($this->MyPOST['noapalot_garumu'] == '2') {
                 $tmp_garums_pirms_red = (floor($tmp_garums_pirms_red / 10) + 0.5) * 10;
             }
             $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][0];
             if (!$tmp_raukumaRinda) {
                 $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][$var_Suga];
             }
             $raukums = raukums_2_array($tmp_raukumaRinda);
             $rauk_koef = get_raukums_no_diam($raukums, $tmp_tievgalis_pirms_red);
             $tmp_DiamRedukcija = $tmp_tievgalis_pirms_red - $tmp_tievgalis_pec_red;
             $tilpums_bruto = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             if ($this->MyPOST['noapalot_diametru'] == 'on') {
                 $tmp_tievgalis_pec_red = (floor($tmp_tievgalis_pec_red / 10) + 0.5) * 100;
             }
             $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][0];
             if (!$tmp_virsmeraRinda) {
                 $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][$var_Suga];
             }
             $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][0];
             if (!$tmp_virsmeraRindaBrakis) {
                 $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][$var_Suga];
             }
             if ($tmp_virsmeraRindaBrakis) {
                 $virsmeri_brakim = explode(',', $tmp_virsmeraRindaBrakis);
                 for ($i = 0; $i < count($virsmeri_brakim); $i++) {
                     $virsmeri_brakim[$i] = $virsmeri_brakim[$i];
                 }
             }
             $virsmeri = explode(',', $tmp_virsmeraRinda);
             for ($i = 0; $i < count($virsmeri); $i++) {
                 $virsmeri[$i] = $virsmeri[$i];
             }
             $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][0];
             if (!$tmp_mini_virsmeraRinda) {
                 $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][$var_Suga];
             }
             $tmp_nom_garums_pirms_red = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri, $tmp_mini_virsmeraRinda);
             $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
             if ($this->MyPOST['is_vika'] == 'on') {
                 $tmp_garums_pec_red = $tmp_garums_pec_red + $tmp_mini_virsmeraRinda;
                 $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
                 $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
                 $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
             } else {
                 $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
                 $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
             }
             if ($this->MyPOST['metode'] == 4) {
                 if ($this->firmCode == 27) {
                     $tilpums_bruto = floor($tmp_tilpumsBruto / 10) / 1000;
                     $tilpums_neto = floor($tmp_tilpumsNeto / 10) / 1000;
                     $tilpums_bruto_virsmeram = floor($tmp_tilpumsNeto / 10) / 1000;
                     $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                     $tilpums_redukcija = 0;
                 } else {
                     $tilpums_bruto = $tmp_tilpumsBruto;
                     $tilpums_neto = $tmp_tilpumsNeto;
                     $tilpums_bruto_virsmeram = $tmp_tilpumsNeto;
                     $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                     if ($this->firmCode == 26) {
                     }
                     $tilpums_redukcija = 0;
                 }
             }
             $apmaksas_garums = $tmp_nom_garums_pec_red;
             if ($tilpums_virsmers < 0) {
                 $tilpums_virsmers = 0;
             }
             if ($tilpums_bruto_virsmeram == 0) {
                 $tilpums_virsmers = 0;
             }
             if ($tilpums_redukcija < 0) {
                 $tilpums_redukcija = 0;
             }
             //-#003-FUNC-END--------------------------------------------------------------------------------------------------------------------------------------
             //-#004-FUNC-START--Papildus dimensijas brāķa piešķiršana--------------------------------------------------------------------------------------------
             $takeReCallOn4 = false;
             if ($tmp_nom_garums_pec_red < 1 && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $takeReCallOn4 = true;
             }
             if (substr($prnt_Diametrs, 0, 1) == 'b' && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
                 $takeReCallOn4 = true;
             }
             if (substr($prnt_Garums, 0, 1) == 'b' && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $prnt_Garums = str_replace('b', '', $prnt_Garums);
                 $takeReCallOn4 = true;
             }
             if ($prnt_Brakis == 'D') {
                 // XML nobrāķēšana ar 4 kodu
                 $takeReCallOn4 = true;
             }
             if ($this->firmCode == 26 && $tmp_getDataQuery_arr['brakis'] == '017' && $liguma_matrica == 'AC') {
                 $tmp_is4 = mod_ResignLVMRejectCode($this->firmCode, $liguma_matrica, $tmp_getDataQuery_arr['garums'], $tmp_getDataQuery_arr['mind_pirms_red'], $tmp_getDataQuery_arr['suga'], $tmp_getDataQuery_arr['skira'], $tmp_getDataQuery_arr['brakis']);
                 if ($tmp_is4) {
                     $prnt_Brakis = $this->braki['702']['LAT'];
                 }
             }
             if ($takeReCallOn4) {
                 $tmp_is4 = mod_ResignLVMRejectCode($this->firmCode, $liguma_matrica, $tmp_getDataQuery_arr['garums'], $tmp_getDataQuery_arr['mind_pirms_red'], $tmp_getDataQuery_arr['suga'], $tmp_getDataQuery_arr['skira'], $tmp_getDataQuery_arr['brakis']);
                 if ($tmp_is4) {
                     $prnt_Brakis = $this->braki['856']['LAT'];
                 }
             }
             if ($this->firmCode == 25) {
                 if ($tmp_getDataQuery_arr['brakis'] == '003') {
                     $prnt_Brakis = $this->braki['003']['LAT'];
                 }
             }
             //-#004-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#005-FUNC-START--Brāķa tilpuma aprēķināšana---------------------------------------------------------------------------------------------------
             if ($prnt_Brakis) {
                 $tilpums_neto = 0;
                 $tilpums_redukcija = 0;
                 if ($isBrakaVirsmOn == 'on') {
                     if ($virsmeri_brakim) {
                         $tmp_nom_garums_pirms_red_brakim = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri_brakim, $tmp_mini_virsmeraRinda);
                         $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red_brakim, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                         $apmaksas_garums = $tmp_nom_garums_pirms_red_brakim;
                         if ($tilpums_bruto_virsmeram > 0) {
                             $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                             $tilpums_brakis = $tilpums_bruto_virsmeram;
                             $apmaksas_garums = $tmp_garums_pirms_red;
                         } else {
                             $tilpums_virsmers = 0;
                             $tilpums_brakis = $tilpums_bruto;
                             $apmaksas_garums = $tmp_garums_pirms_red;
                         }
                     } else {
                         if ($tilpums_bruto_virsmeram > 0) {
                             $tilpums_brakis = $tilpums_bruto_virsmeram;
                             $apmaksas_garums = $tmp_nom_garums_pirms_red;
                         } else {
                             $tilpums_virsmers = 0;
                             $tilpums_brakis = $tilpums_bruto;
                             $apmaksas_garums = $tmp_garums_pirms_red;
                         }
                     }
                 } else {
                     $tilpums_virsmers = 0;
                     $tilpums_brakis = $tilpums_bruto;
                     $apmaksas_garums = $tmp_garums_pirms_red;
                 }
             }
             $tmp_inputArrVal['mind_pirms_red'] = str_replace('b', '', $tmp_inputArrVal['mind_pirms_red']);
             $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
             $tmp_inputArrVal['garums'] = str_replace('b', '', $tmp_inputArrVal['garums']);
             $prnt_Garums = str_replace('b', '', $prnt_Garums);
             //-#005-FUNC-END-----------------------------------------------------------------------------------------------------
             if ($this->genGlobalRegister_id > 0) {
                 $datumsRegNow = date("Y-m-d H:i:s");
                 $subInsertRegisterBool = $this->regSubGlobalRegisters($datumsRegNow, $varDateTime, $this->genGlobalRegister_id, $this->tmp_pavadzimeInsert, $prnt_Suga, $prnt_Skira, $tmp_getDataQuery_arr['mind_pirms_red'], $prnt_Diametrs, $tmp_getDataQuery_arr['garums'], $prnt_Garums, $prnt_Brakis, $tilpums_bruto, $tilpums_brakis, $tilpums_neto);
             }
             //-#006-FUNC-START--Vienādo grupēšanu pāskats---------------------------------------------------------------------------------------------------
             $pilnaGrupesana = false;
             if ($this->report_XML) {
                 $pilnaGrupesana = true;
             }
             if (($this->firmCode == 16 || $this->firmCode == 666 || $this->isAllReport) && !$this->report_PDF) {
                 $pilnaGrupesana = true;
             }
             $rowExist = 0;
             if (!$pilnaGrupesana) {
                 for ($protoKey = $tmp_rowCount - 1; $protoKey > 0; $protoKey--) {
                     if ($this->arrPrintOut[$protoKey]['suga'] == $prnt_Suga) {
                         if ($this->arrPrintOut[$protoKey]['skira'] == $prnt_Skira) {
                             if ($this->arrPrintOut[$protoKey]['diametrs'] == $prnt_Diametrs) {
                                 if ($this->arrPrintOut[$protoKey]['brakis_kods'] == $prnt_Brakis) {
                                     $rowExist = $protoKey;
                                 }
                             }
                         }
                     }
                 }
             } else {
                 for ($protoKey = $tmp_rowCount - 1; $protoKey > 0; $protoKey--) {
                     if ($this->arrPrintOut[$protoKey]['suga'] == $prnt_Suga) {
                         if ($this->arrPrintOut[$protoKey]['skira'] == $prnt_Skira) {
                             if ($this->arrPrintOut[$protoKey]['diametrs'] == $prnt_Diametrs) {
                                 if ($this->arrPrintOut[$protoKey]['garums'] == $prnt_Garums) {
                                     if ($this->arrPrintOut[$protoKey]['brakis_kods'] == $prnt_Brakis) {
                                         $rowExist = $protoKey;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             //-#006-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#007-FUNC-START--Statisko vērtību ievietošana---------------------------------------------------------------------------------------------------
             $insertRow = $tmp_rowCount;
             if ($rowExist != 0) {
                 $insertRow = $rowExist;
             }
             $this->arrPrintOut[$insertRow]['nosaukums'] = 0;
             $this->arrPrintOut[$insertRow]['suga'] = $prnt_Suga;
             $this->arrPrintOut[$insertRow]['skira'] = $prnt_Skira;
             $this->arrPrintOut[$insertRow]['diametrs'] = $prnt_Diametrs;
             $this->arrPrintOut[$insertRow]['garums'] = $prnt_Garums;
             $this->arrPrintOut[$insertRow]['brakis_kods'] = $prnt_Brakis;
             if ($this->report_XML) {
                 $this->arrPrintOut[$insertRow]['diametrs_tmp'] = $tmp_getDataQuery_arr['mind_pirms_red'];
                 //        $this->arrPrintOut[$insertRow]['garums_tmp'] = $tmp_getDataQuery_arr['garums'];
                 $this->arrPrintOut[$insertRow]['garums_tmp'] = $apmaksas_garums;
             }
             $this->arrPrintOut[$insertRow]['skaits'] += 1;
             if ($this->arrPrintOut[$insertRow]['brakis_kods'] != '') {
                 $tilpums_skaits_brakis_KOPA += 1;
             }
             //-#007-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#008-FUNC-START--Dinamisko vērtību piešķiršana---------------------------------------------------------------------------------------------------
             $this->arrPrintOut[$insertRow]['bruto'] += $tilpums_bruto;
             $this->arrPrintOut[$insertRow]['virsmers'] += $tilpums_virsmers;
             $this->arrPrintOut[$insertRow]['redukcija'] += $tilpums_redukcija;
             $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] += $tilpums_bruto - $tilpums_neto;
             $this->arrPrintOut[$insertRow]['brakis'] += $tilpums_brakis;
             $this->arrPrintOut[$insertRow]['neto'] += $tilpums_neto;
             $this->arrPrintOut[$insertRow]['brakis_un_neto'] += $tilpums_neto + $tilpums_brakis;
             //------------------------------------------------------------------------------------------------------
             if ($this->arrPrintOut[$insertRow]['bruto'] != '') {
                 $this->arrPrintOut[$insertRow]['bruto'] = number_format($this->arrPrintOut[$insertRow]['bruto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['bruto'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['virsmers'] != '') {
                 $this->arrPrintOut[$insertRow]['virsmers'] = number_format($this->arrPrintOut[$insertRow]['virsmers'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['virsmers'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['redukcija'] != '') {
                 $this->arrPrintOut[$insertRow]['redukcija'] = number_format($this->arrPrintOut[$insertRow]['redukcija'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['redukcija'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] != '') {
                 $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = number_format($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['brakis'] != '') {
                 $this->arrPrintOut[$insertRow]['brakis'] = number_format($this->arrPrintOut[$insertRow]['brakis'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['brakis'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['neto'] != '') {
                 $this->arrPrintOut[$insertRow]['neto'] = number_format($this->arrPrintOut[$insertRow]['neto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['neto'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['brakis_un_neto'] != '') {
                 $this->arrPrintOut[$insertRow]['brakis_un_neto'] = number_format($this->arrPrintOut[$insertRow]['brakis_un_neto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['brakis_un_neto'] = '';
             }
             //------------------------------------------------------------------------------------------------------
             $tilpums_bruto_KOPA = $tilpums_bruto_KOPA + $tilpums_bruto;
             $tilpums_virsmers_KOPA = $tilpums_virsmers_KOPA + $tilpums_virsmers;
             $tilpums_redukcija_KOPA = $tilpums_redukcija_KOPA + $tilpums_redukcija;
             $tilpums_neto_KOPA = $tilpums_neto_KOPA + $tilpums_neto;
             $tilpums_brakis_KOPA = $tilpums_brakis_KOPA + $tilpums_brakis;
             $tmp_balkuSkaits++;
             $tmp_rowCount++;
         }
     } else {
         while ($tmp_getDataQuery_arr = mysql_fetch_assoc($tmp_getDataQuery_query)) {
             $tilpums_bruto = 0;
             $tilpums_virsmers = 0;
             $tilpums_redukcija = 0;
             $tilpums_neto = 0;
             $tilpums_brakis = 0;
             $isBrakaVirsmOn = $this->MyPOST['braka_virsmers'];
             if ($tmp_getDataQuery_arr['pavadzime'] == 76806 && $this->firmCode == 2) {
                 $isBrakaVirsmOn = 'off';
             }
             //-#001-FUNC-START--Nepieciešamo datu kolekcionēšana no datubāzes------------------------------------------------------------------------------------
             $tmp_ident_balkis = $tmp_getDataQuery_arr['id'];
             $var_Suga = $tmp_getDataQuery_arr['suga'];
             $tmp_tilpumsBruto = $tmp_getDataQuery_arr['tilpums'];
             $tmp_tilpumsNeto = $tmp_getDataQuery_arr['tilpums_scan'];
             $tmp_garums_pirms_red = $tmp_getDataQuery_arr['garums'];
             $tmp_garums_pec_red = $tmp_getDataQuery_arr['gar_pec_red'];
             $tmp_tievgalis_pirms_red = $tmp_getDataQuery_arr['mind_pirms_red'];
             $tmp_tievgalis_pec_red = $tmp_getDataQuery_arr['mind_pec_red'];
             $tmp_vidusdiametrs_pirms_red = $tmp_getDataQuery_arr['mind_miza'];
             $tmp_vidusdiametrs_pec_red = $tmp_getDataQuery_arr['mind_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
             $tmp_resgalis_pirms_red = $tmp_getDataQuery_arr['maxd_miza'];
             $tmp_resgalis_pec_red = $tmp_getDataQuery_arr['maxd_miza'] - ($tmp_getDataQuery_arr['mind_pirms_red'] - $tmp_getDataQuery_arr['mind_pec_red']);
             //-#001-FUNC-END------------------------------------------------------------------------------------------------------------------------------------
             //-#002-FUNC-START--Nepieciešamās grupas atrašana---------------------------------------------------------------------------------------------------
             $igc = 1;
             // Grupu skaits
             $init_Group = false;
             while ($igc < 9 && $init_Group == false) {
                 $tmp_igcCheck = 0;
                 for ($igo = 1; $igo < 6; $igo++) {
                     //Grupēšanas nosacījumus cikls
                     for ($subcount = 0; $subcount < 3; $subcount++) {
                         if ($this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount]) {
                             $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$subcount];
                             if (!$this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][0]) {
                                 $tmp_SubResult = $this->tmpAllGroup[$igc][$this->GroupOrder[$igo]][$var_Suga];
                             }
                             $tmp_ALLbResult = $this->getMaskGroup($tmp_SubResult, $tmp_getDataQuery_arr[$this->GroupOrder[$igo]], $this->GroupOrder[$igo]);
                             $tmp_inputArrVal[$this->GroupOrder[$igo]] = $tmp_ALLbResult;
                             if ($tmp_ALLbResult != '') {
                                 $tmp_igcCheck = $tmp_igcCheck + 1;
                             }
                         } else {
                             $tmp_igcCheck = $tmp_igcCheck + 1;
                         }
                     }
                     if ($igo == 5 && $tmp_igcCheck == 15) {
                         // Grupas noteikšana līdz pirmajiem sakritības rezultātiem (rekursija ar limitētu ciklu skaitu)
                         $init_Group = true;
                         $globalGroupIdent = $igc;
                     }
                 }
                 $igc++;
             }
             //-#002-FUNC-END-------------------------------------------------------------------------------------------------------------------------------------
             //-#003-FUNC-START--Tilpuma aprēķināšana-------------------------------------------------------------------------------------------------------------
             $prnt_Nosaukums = 0;
             $prnt_Suga = $this->sugas[$var_Suga]['LAT'];
             $prnt_Skira = $tmp_getDataQuery_arr['skira'];
             $prnt_Brakis = $this->braki[$tmp_getDataQuery_arr['brakis']]['LAT'];
             $prnt_Diametrs = $tmp_inputArrVal['mind_pirms_red'];
             $prnt_Garums = $tmp_inputArrVal['garums'];
             //---------------------------------------------------------------------------------------------------------------------------------------------------
             if ($this->firmCode == 35 && $prnt_Skira == 3) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['010']['LAT'];
             }
             if ($this->firmCode == 37 && $prnt_Skira == 3) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['011']['LAT'];
             }
             //---------------------------------------------------------------------------------------------------------------------------------------------------
             if ($this->MyPOST['noapalot_garumu'] == '1') {
                 $tmp_garums_pirms_red = floor($tmp_garums_pirms_red / 10) * 10;
             } elseif ($this->MyPOST['noapalot_garumu'] == '2') {
                 $tmp_garums_pirms_red = (floor($tmp_garums_pirms_red / 10) + 0.5) * 10;
             }
             $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][0];
             if (!$tmp_raukumaRinda) {
                 $tmp_raukumaRinda = $this->tmpRaukGroup[$globalGroupIdent][$var_Suga];
             }
             $raukums = raukums_2_array($tmp_raukumaRinda);
             $rauk_koef = get_raukums_no_diam($raukums, $tmp_tievgalis_pirms_red);
             $tmp_DiamRedukcija = $tmp_tievgalis_pirms_red - $tmp_tievgalis_pec_red;
             $tilpums_bruto = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
             if ($this->MyPOST['noapalot_diametru'] == 'on') {
                 $tmp_tievgalis_pec_red = (floor($tmp_tievgalis_pec_red / 10) + 0.5) * 100;
             }
             $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][0];
             if (!$tmp_virsmeraRinda) {
                 $tmp_virsmeraRinda = $this->tmpNomGarGroup[$globalGroupIdent][$var_Suga];
             }
             $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][0];
             if (!$tmp_virsmeraRindaBrakis) {
                 $tmp_virsmeraRindaBrakis = $this->tmpNomGarBrakGroup[$globalGroupIdent][$var_Suga];
             }
             if ($tmp_virsmeraRindaBrakis) {
                 $virsmeri_brakim = explode(',', $tmp_virsmeraRindaBrakis);
                 for ($i = 0; $i < count($virsmeri_brakim); $i++) {
                     $virsmeri_brakim[$i] = $virsmeri_brakim[$i];
                 }
             }
             $virsmeri = explode(',', $tmp_virsmeraRinda);
             for ($i = 0; $i < count($virsmeri); $i++) {
                 $virsmeri[$i] = $virsmeri[$i];
             }
             $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][0];
             if (!$tmp_mini_virsmeraRinda) {
                 $tmp_mini_virsmeraRinda = $this->tmpVirsmGroup[$globalGroupIdent][$var_Suga];
             }
             $tmp_nom_garums_pirms_red = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri, $tmp_mini_virsmeraRinda);
             $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
             if ($this->MyPOST['is_vika'] == 'on') {
                 $tmp_garums_pec_red = $tmp_garums_pec_red + $tmp_mini_virsmeraRinda;
                 $tmp_nom_garums_pec_red = nominalGarums($tmp_garums_pec_red, $virsmeri, $tmp_mini_virsmeraRinda);
                 $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
                 $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
             } else {
                 $tilpums_neto = $this->calc_Volume($tmp_tievgalis_pec_red, $tmp_vidusdiametrs_pec_red, $tmp_resgalis_pec_red, $tmp_nom_garums_pec_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                 $tilpums_virsmers = ROUND($tilpums_bruto - $tilpums_bruto_virsmeram, 3);
                 $tilpums_redukcija = $tilpums_bruto_virsmeram - $tilpums_neto;
             }
             if ($this->MyPOST['metode'] == 4) {
                 if ($this->firmCode == 27) {
                     $tilpums_bruto = floor($tmp_tilpumsBruto / 10) / 1000;
                     $tilpums_neto = floor($tmp_tilpumsNeto / 10) / 1000;
                     $tilpums_bruto_virsmeram = floor($tmp_tilpumsNeto / 10) / 1000;
                     $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                     $tilpums_redukcija = 0;
                 } else {
                     $tilpums_bruto = $tmp_tilpumsBruto;
                     $tilpums_neto = $tmp_tilpumsNeto;
                     $tilpums_bruto_virsmeram = $tmp_tilpumsNeto;
                     $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                     $tilpums_redukcija = 0;
                 }
             }
             if ($tilpums_virsmers < 0) {
                 $tilpums_virsmers = 0;
             }
             if ($tilpums_bruto_virsmeram == 0) {
                 $tilpums_virsmers = 0;
             }
             if ($tilpums_redukcija < 0) {
                 $tilpums_redukcija = 0;
             }
             //-#003-FUNC-END--------------------------------------------------------------------------------------------------------------------------------------
             //-#004-FUNC-START--Papildus dimensijas brāķa priešķiršana--------------------------------------------------------------------------------------------
             $takeReCallOn4 = false;
             if ($tmp_nom_garums_pec_red < 1 && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $takeReCallOn4 = true;
             }
             if (substr($prnt_Diametrs, 0, 1) == 'b' && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
                 $takeReCallOn4 = true;
             }
             if (substr($prnt_Garums, 0, 1) == 'b' && !$prnt_Brakis) {
                 $prnt_Skira = 9;
                 $prnt_Brakis = $this->braki['899']['LAT'];
                 $prnt_Garums = str_replace('b', '', $prnt_Garums);
                 $takeReCallOn4 = true;
             }
             if ($this->firmCode == 26 && $tmp_getDataQuery_arr['brakis'] == '017' && $liguma_matrica == 'AC') {
                 $tmp_is4 = mod_ResignLVMRejectCode($this->firmCode, $liguma_matrica, $tmp_getDataQuery_arr['garums'], $tmp_getDataQuery_arr['mind_pirms_red'], $tmp_getDataQuery_arr['suga'], $tmp_getDataQuery_arr['skira'], $tmp_getDataQuery_arr['brakis']);
                 if ($tmp_is4) {
                     $prnt_Brakis = $this->braki['702']['LAT'];
                 }
             }
             if ($prnt_Brakis == 'D') {
                 // XML nobrāķēšana ar 4 kodu
                 $takeReCallOn4 = true;
             }
             if ($takeReCallOn4) {
                 $tmp_is4 = mod_ResignLVMRejectCode($this->firmCode, $liguma_matrica, $tmp_getDataQuery_arr['garums'], $tmp_getDataQuery_arr['mind_pirms_red'], $tmp_getDataQuery_arr['suga'], $tmp_getDataQuery_arr['skira'], $tmp_getDataQuery_arr['brakis']);
                 if ($tmp_is4) {
                     $prnt_Brakis = $this->braki['856']['LAT'];
                 }
             }
             //-#004-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#005-FUNC-START--Brāķa tilpuma aprēķināšana---------------------------------------------------------------------------------------------------
             if ($prnt_Brakis) {
                 $tilpums_neto = 0;
                 $tilpums_redukcija = 0;
                 if ($isBrakaVirsmOn == 'on') {
                     if ($virsmeri_brakim) {
                         $tmp_nom_garums_pirms_red_brakim = nominalGarums($tmp_getDataQuery_arr['garums'], $virsmeri_brakim, $tmp_mini_virsmeraRinda);
                         $tilpums_bruto_virsmeram = $this->calc_Volume($tmp_tievgalis_pirms_red, $tmp_vidusdiametrs_pirms_red, $tmp_resgalis_pirms_red, $tmp_nom_garums_pirms_red_brakim, $rauk_koef, $koeficients, $gostu_tabula, $this->MyPOST['metode']);
                         if ($tilpums_bruto_virsmeram > 0) {
                             $tilpums_virsmers = $tilpums_bruto - $tilpums_bruto_virsmeram;
                             $tilpums_brakis = $tilpums_bruto_virsmeram;
                         } else {
                             $tilpums_virsmers = 0;
                             $tilpums_brakis = $tilpums_bruto;
                         }
                     } else {
                         if ($tilpums_bruto_virsmeram > 0) {
                             $tilpums_brakis = $tilpums_bruto_virsmeram;
                         } else {
                             $tilpums_virsmers = 0;
                             $tilpums_brakis = $tilpums_bruto;
                         }
                     }
                 } else {
                     $tilpums_virsmers = 0;
                     $tilpums_brakis = $tilpums_bruto;
                 }
             }
             $tmp_inputArrVal['mind_pirms_red'] = str_replace('b', '', $tmp_inputArrVal['mind_pirms_red']);
             $prnt_Diametrs = str_replace('b', '', $prnt_Diametrs);
             $tmp_inputArrVal['garums'] = str_replace('b', '', $tmp_inputArrVal['garums']);
             $prnt_Garums = str_replace('b', '', $prnt_Garums);
             //-#005-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#006-FUNC-START--Vienādo grupēšanu pāskats---------------------------------------------------------------------------------------------------
             $pilnaGrupesana = false;
             if ($this->report_XML) {
                 $pilnaGrupesana = true;
             }
             if (($this->firmCode == 16 || $this->firmCode == 666 || $this->isAllReport) && !$this->report_PDF) {
                 $pilnaGrupesana = true;
             }
             //-#006-FUNC-END-----------------------------------------------------------------------------------------------------
             //-#007-FUNC-START--Statisko vērtību ievietošana---------------------------------------------------------------------------------------------------
             /*
                   $insertRow = $tmp_rowCount;
                   if($rowExist != 0){$insertRow = $rowExist;}
             
                   $this->arrPrintOut[$insertRow]['nosaukums'] = 0;
                   $this->arrPrintOut[$insertRow]['suga'] = $prnt_Suga;
                   $this->arrPrintOut[$insertRow]['skira'] = $prnt_Skira;
                   $this->arrPrintOut[$insertRow]['diametrs'] = $prnt_Diametrs;
                   $this->arrPrintOut[$insertRow]['garums'] = $prnt_Garums;
                   $this->arrPrintOut[$insertRow]['brakis_kods'] = $prnt_Brakis;
                   if($this->report_XML){
                     $this->arrPrintOut[$insertRow]['diametrs_tmp'] = $tmp_getDataQuery_arr['mind_pirms_red'];
                     $this->arrPrintOut[$insertRow]['garums_tmp'] = $tmp_getDataQuery_arr['garums'];
                   }
                   $this->arrPrintOut[$insertRow]['skaits'] += 1;
             
                   if($this->arrPrintOut[$insertRow]['brakis_kods'] != ''){
                     $tilpums_skaits_brakis_KOPA += 1;
                   }
             */
             $tmp_skaits = 1;
             $querySub_text = "INSERT INTO `global_kops_atsk` (`group_suga`,`group_skira`,`group_diametrs`,`group_garums`,`group_brakis`,`group_tilp_neto`,`group_tilp_bruto`,`group_tilp_brakis`,`group_tilp_neto_un_brakis`,`group_tilp_redukcija`,`group_tilp_virsmers`,`group_skaits`) VALUES ('{$prnt_Suga}','{$prnt_Skira}','{$prnt_Diametrs}','{$prnt_Garums}','{$prnt_Brakis}',{$tilpums_neto},{$tilpums_bruto},{$tilpums_brakis},{$tilpums_neto} + {$tilpums_brakis},{$tilpums_redukcija},{$tilpums_virsmers},{$tmp_skaits})";
             mysql_query($querySub_text);
             //-#007-FUNC-END-----------------------------------------------------------------------------------------------------
             /*
              //-#008-FUNC-START--Dinamisko vērtību piešķiršana---------------------------------------------------------------------------------------------------    
                  $this->arrPrintOut[$insertRow]['bruto'] += $tilpums_bruto;
                  $this->arrPrintOut[$insertRow]['virsmers'] += $tilpums_virsmers;
                  $this->arrPrintOut[$insertRow]['redukcija'] += $tilpums_redukcija;
                  $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] += $tilpums_bruto - $tilpums_neto;
                  $this->arrPrintOut[$insertRow]['brakis'] += $tilpums_brakis;
                  $this->arrPrintOut[$insertRow]['neto'] += $tilpums_neto;
                  $this->arrPrintOut[$insertRow]['brakis_un_neto'] += $tilpums_neto + $tilpums_brakis;
              //------------------------------------------------------------------------------------------------------
                  if($this->arrPrintOut[$insertRow]['bruto'] != ''){$this->arrPrintOut[$insertRow]['bruto'] = number_format($this->arrPrintOut[$insertRow]['bruto'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['bruto'] = '';}
                  if($this->arrPrintOut[$insertRow]['virsmers'] != ''){$this->arrPrintOut[$insertRow]['virsmers'] = number_format($this->arrPrintOut[$insertRow]['virsmers'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['virsmers'] = '';}
                  if($this->arrPrintOut[$insertRow]['redukcija'] != ''){$this->arrPrintOut[$insertRow]['redukcija'] = number_format($this->arrPrintOut[$insertRow]['redukcija'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['redukcija'] = '';}
                  if($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] != ''){$this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = number_format($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = '';}
                  if($this->arrPrintOut[$insertRow]['brakis'] != ''){$this->arrPrintOut[$insertRow]['brakis'] = number_format($this->arrPrintOut[$insertRow]['brakis'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['brakis'] = '';}
                  if($this->arrPrintOut[$insertRow]['neto'] != ''){$this->arrPrintOut[$insertRow]['neto'] = number_format($this->arrPrintOut[$insertRow]['neto'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['neto'] = '';}
                  if($this->arrPrintOut[$insertRow]['brakis_un_neto'] != ''){$this->arrPrintOut[$insertRow]['brakis_un_neto'] = number_format($this->arrPrintOut[$insertRow]['brakis_un_neto'], 3, '.', '');}else{$this->arrPrintOut[$insertRow]['brakis_un_neto'] = '';}
              //------------------------------------------------------------------------------------------------------
             
                  $tilpums_bruto_KOPA = $tilpums_bruto_KOPA + $tilpums_bruto;
                  $tilpums_virsmers_KOPA = $tilpums_virsmers_KOPA + $tilpums_virsmers;
                  $tilpums_redukcija_KOPA = $tilpums_redukcija_KOPA + $tilpums_redukcija;
                  $tilpums_neto_KOPA = $tilpums_neto_KOPA + $tilpums_neto;
                  $tilpums_brakis_KOPA = $tilpums_brakis_KOPA + $tilpums_brakis;
             
                  $tmp_balkuSkaits++;
                  $tmp_rowCount++;
             */
         }
         $mysqlGlobalSelect_text = "SELECT `group_suga`, `group_skira`, `group_diametrs`, `group_garums`, `group_brakis`, SUM(`group_skaits`) as skaits, SUM(`group_tilp_bruto`) as bruto, SUM(`group_tilp_virsmers`) as virsmers, SUM(`group_tilp_redukcija`) as redukcija, SUM(`group_tilp_brakis`) as brakis_tilp, SUM(`group_tilp_neto`) as neto FROM `global_kops_atsk` GROUP BY `group_suga`, `group_skira`, `group_diametrs`, `group_garums`, `group_brakis` ORDER BY `group_suga`, `group_skira`, `group_diametrs`, `group_garums`, `group_brakis`";
         //    echo $mysqlGlobalSelect_text.'<br />';
         $mysqlGlobalSelect = mysql_query($mysqlGlobalSelect_text);
         $insertRow = $tmp_rowCount;
         while ($mysqlGlobalSelect_arr = mysql_fetch_assoc($mysqlGlobalSelect)) {
             $this->arrPrintOut[$insertRow]['nosaukums'] = 0;
             $this->arrPrintOut[$insertRow]['suga'] = $mysqlGlobalSelect_arr['group_suga'];
             $this->arrPrintOut[$insertRow]['skira'] = $mysqlGlobalSelect_arr['group_skira'];
             $this->arrPrintOut[$insertRow]['diametrs'] = $mysqlGlobalSelect_arr['group_diametrs'];
             $this->arrPrintOut[$insertRow]['garums'] = $mysqlGlobalSelect_arr['group_garums'];
             $this->arrPrintOut[$insertRow]['brakis_kods'] = $mysqlGlobalSelect_arr['group_brakis'];
             $this->arrPrintOut[$insertRow]['skaits'] = $mysqlGlobalSelect_arr['skaits'];
             $this->arrPrintOut[$insertRow]['bruto'] = $mysqlGlobalSelect_arr['bruto'];
             $this->arrPrintOut[$insertRow]['virsmers'] = $mysqlGlobalSelect_arr['virsmers'];
             $this->arrPrintOut[$insertRow]['redukcija'] = $mysqlGlobalSelect_arr['redukcija'];
             $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = $mysqlGlobalSelect_arr['redukcija'] + $mysqlGlobalSelect_arr['virsmers'];
             $this->arrPrintOut[$insertRow]['brakis'] = $mysqlGlobalSelect_arr['brakis_tilp'];
             $this->arrPrintOut[$insertRow]['neto'] = $mysqlGlobalSelect_arr['neto'];
             $this->arrPrintOut[$insertRow]['brakis_un_neto'] = $mysqlGlobalSelect_arr['brakis'] + $mysqlGlobalSelect_arr['neto'];
             if ($this->arrPrintOut[$insertRow]['bruto'] != '' && $this->arrPrintOut[$insertRow]['bruto'] != 0) {
                 $this->arrPrintOut[$insertRow]['bruto'] = number_format($this->arrPrintOut[$insertRow]['bruto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['bruto'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['virsmers'] != '' && $this->arrPrintOut[$insertRow]['virsmers'] != 0) {
                 $this->arrPrintOut[$insertRow]['virsmers'] = number_format($this->arrPrintOut[$insertRow]['virsmers'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['virsmers'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['redukcija'] != '' && $this->arrPrintOut[$insertRow]['redukcija'] != 0) {
                 $this->arrPrintOut[$insertRow]['redukcija'] = number_format($this->arrPrintOut[$insertRow]['redukcija'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['redukcija'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] != '' && $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] != 0) {
                 $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = number_format($this->arrPrintOut[$insertRow]['redukcija_un_virsmers'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['redukcija_un_virsmers'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['brakis'] != '' && $this->arrPrintOut[$insertRow]['brakis'] != 0) {
                 $this->arrPrintOut[$insertRow]['brakis'] = number_format($this->arrPrintOut[$insertRow]['brakis'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['brakis'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['neto'] != '' && $this->arrPrintOut[$insertRow]['neto'] != 0) {
                 $this->arrPrintOut[$insertRow]['neto'] = number_format($this->arrPrintOut[$insertRow]['neto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['neto'] = '';
             }
             if ($this->arrPrintOut[$insertRow]['brakis_un_neto'] != '' && $this->arrPrintOut[$insertRow]['brakis_un_neto'] != 0) {
                 $this->arrPrintOut[$insertRow]['brakis_un_neto'] = number_format($this->arrPrintOut[$insertRow]['brakis_un_neto'], 3, '.', '');
             } else {
                 $this->arrPrintOut[$insertRow]['brakis_un_neto'] = '';
             }
             $tilpums_bruto_KOPA = $tilpums_bruto_KOPA + $mysqlGlobalSelect_arr['bruto'];
             $tilpums_virsmers_KOPA = $tilpums_virsmers_KOPA + $mysqlGlobalSelect_arr['virsmers'];
             $tilpums_redukcija_KOPA = $tilpums_redukcija_KOPA + $mysqlGlobalSelect_arr['redukcija'];
             $tilpums_neto_KOPA = $tilpums_neto_KOPA + $mysqlGlobalSelect_arr['neto'];
             $tilpums_brakis_KOPA = $tilpums_brakis_KOPA + $mysqlGlobalSelect_arr['brakis_tilp'];
             $tmp_balkuSkaits = $tmp_balkuSkaits + $mysqlGlobalSelect_arr['skaits'];
             $tmp_rowCount++;
             $insertRow++;
         }
     }
     //  }
     //-#008-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#009-FUNC-START--Rindu pārgrupēšana masīvā---------------------------------------------------------------------------------------------------
     if (($this->firmCode == 16 || $this->firmCode == 20 || $bbq_temp == true || $this->isAllReport) && !$this->report_PDF && !$this->report_XML) {
         $this->arrPrintOut = array_orderby($this->arrPrintOut, 'suga', SORT_ASC, 'skira', SORT_ASC, 'diametrs', SORT_ASC, 'garums', SORT_ASC, 'brakis_kods', SORT_ASC);
     } else {
         $this->arrPrintOut = array_orderby($this->arrPrintOut, 'suga', SORT_ASC, 'skira', SORT_ASC, 'diametrs', SORT_ASC, 'brakis_kods', SORT_ASC);
     }
     array_unshift($this->arrPrintOut, $tmp_arrCollName);
     //-#009-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#010-FUNC-START--Kopsummas rindas pievienošana---------------------------------------------------------------------------------------------------
     $this->arrPrintOut[$tmp_rowCount]['nosaukums'] = 1;
     $this->arrPrintOut[$tmp_rowCount]['suga'] = "";
     $this->arrPrintOut[$tmp_rowCount]['skira'] = "";
     $this->arrPrintOut[$tmp_rowCount]['diametrs'] = "";
     $this->arrPrintOut[$tmp_rowCount]['garums'] = "";
     $this->arrPrintOut[$tmp_rowCount]['brakis_kods'] = "";
     $this->arrPrintOut[$tmp_rowCount]['skaits'] = $tmp_balkuSkaits;
     $this->arrPrintOut[$tmp_rowCount]['bruto'] = number_format($tilpums_bruto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['virsmers'] = number_format($tilpums_virsmers_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['redukcija'] = number_format($tilpums_redukcija_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['redukcija_un_virsmers'] = number_format($tilpums_bruto_KOPA - $tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['brakis'] = number_format($tilpums_brakis_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['neto'] = number_format($tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->arrPrintOut[$tmp_rowCount]['brakis_un_neto'] = number_format($tilpums_brakis_KOPA + $tilpums_neto_KOPA, 3, '.', '') . "*";
     $this->regSuperSum['bruto'] = $tilpums_bruto_KOPA;
     $this->regSuperSum['virsmers'] = $tilpums_virsmers_KOPA;
     $this->regSuperSum['redukcija'] = $tilpums_redukcija_KOPA;
     $this->regSuperSum['brakis'] = $tilpums_brakis_KOPA;
     $this->regSuperSum['neto'] = $tilpums_neto_KOPA;
     $this->regSuperSum['skaits'] = $tmp_balkuSkaits;
     $this->regSuperSum['skaits_brakis'] = $tilpums_skaits_brakis_KOPA;
     //-#010-FUNC-END-----------------------------------------------------------------------------------------------------
     //-#011-FUNC-START-END-Rezultāts---------------------------------------------------------------------------------------------------
     //    fb($this->arrPrintOut,'arrPrintOut');
     //  break;
     return true;
 }