コード例 #1
0
/**
 * 对二维数组进行按字段排序
 * @param array $array 要排序的二维数组
 * @param bool $orderby 根据该字段(二维数组单个元素中的键名)排序
 * @param string $order 排序方式,asc:升序;desc:降序(默认)
 * @param string $children 子元素字段(键名),当元素含有该字段时,进行递归排序
 * @return array
 */
function array_orderby(&$array, $orderby = null, $order = 'desc', $children = false)
{
    if ($orderby == null) {
        return $array;
    }
    $key_value = $new_array = array();
    foreach ($array as $k => $v) {
        $key_value[$k] = $v[$orderby];
    }
    if ($order == 'asc') {
        asort($key_value);
    } else {
        arsort($key_value);
    }
    reset($key_value);
    foreach ($key_value as $k => $v) {
        $new_array[$k] = $array[$k];
        // 如果有children
        if ($children && isset($new_array[$k][$children])) {
            $new_array[$k][$children] = array_orderby($new_array[$k][$children], $orderby, $order, $children);
        }
    }
    $new_array = array_values($new_array);
    // 使键名为0,1,2,3...
    $array = $new_array;
    return $new_array;
}
コード例 #2
0
function searchWorksheets($searchTerms)
{
    $searchArray = convertSearchTerms($searchTerms);
    if (count($searchArray) === 0) {
        returnToPageNoResults();
    }
    $query = "SELECT `Version ID`, `WName` Name FROM `TWORKSHEETVERSION` WHERE ";
    foreach ($searchArray as $key => $searchTerm) {
        if ($key != 0) {
            $query .= " OR ";
        }
        $query .= "`WName` LIKE '%{$searchTerm}%' ";
    }
    $query .= "ORDER BY `WName`";
    try {
        $worksheets = db_select_exception($query);
        if (count($worksheets) === 0) {
            returnToPageNoResults();
        }
    } catch (Exception $ex) {
        returnToPageError($ex, "There was an error running the search query");
    }
    $fullSearchArray = getFullSearchArray($searchArray);
    // Score the worksheets
    foreach ($worksheets as $key => $worksheet) {
        $worksheets[$key] = scoreWorksheet($worksheet, $fullSearchArray);
    }
    $sorted = array_orderby($worksheets, 'Score', SORT_DESC, 'Name', SORT_ASC);
    $response = array("success" => TRUE, "vids" => $sorted);
    echo json_encode($response);
    exit;
}
コード例 #3
0
 public function getUnspentOutputsWith($minbitcoin, $minmastercoin, $mintestcoin)
 {
     $unspentoutputs = $this->getUnspentOutputs();
     $filterbalanace = function ($var) use($minbitcoin, $minmastercoin, $mintestcoin) {
         $bitcoin = floatval($var["amount"]);
         $mastercoin = floatval($var["mastercoin"]);
         $testcoin = floatval($var["testcoin"]);
         return $minbitcoin <= $bitcoin && $minmastercoin <= $mastercoin && $mintestcoin <= $testcoin;
     };
     $unspentoutputs = array_orderby($unspentoutputs, "confirmations", ORDER_BY_DESC);
     return array_filter($unspentoutputs, $filterbalanace);
 }
コード例 #4
0
ファイル: feed.php プロジェクト: soengle/BringIt
function returnOrderedFeed($t, $s, $f, $c)
{
    if ($t == -1 | $s == -1 | $c == -1) {
        return "";
    }
    $service = DB::queryOneRow("SELECT id FROM categories WHERE id=%s", $s);
    $companies = DB::query("SELECT name, id, category_id FROM category_items WHERE category_id=%s AND id=%d", $service["id"], $c);
    $orders = array();
    $now = new DateTime("now");
    $addressCache = array();
    foreach ($companies as $company) {
        if ($company["name"]) {
            $q = DB::query("SELECT * FROM orders WHERE service_id=%s AND category_id=%s", $company["category_id"], $company["id"]);
        }
        foreach ($q as $order) {
            if (!array_key_exists($order["user_id"], $addressCache)) {
                $addressCache[$order["user_id"]] = UserManager::getAddressFor($order["user_id"]);
            }
            $addr = refineArray(array($addressCache[$order["user_id"]]), array("street", "apartment", "city", "state", "zip"))[0];
            $di = $now->diff(new DateTime($order["time"]));
            if ($di->d <= $t) {
                $items = UserManager::getItemsForCart($order["user_id"], $order["id"]);
                //$order["cart_id"]);
                $userdata = DB::queryOneRow("SELECT * FROM accounts WHERE uid=%s", $order["user_id"]);
                $userdata = refineArray(array($userdata), array("name", "email", "phone"))[0];
                $nonOrderedOrder = array_merge($order, array_merge(array("compName" => $company["name"], "items" => $items["html"], "price" => $items["price"]), $addr, $userdata));
                $sortOrder = array("time", "compName", 5, 6, 7, 0, 1, 2, 3, 4, "items", "price");
                $nonOrderedOrder_trimmed = refineArray(array($nonOrderedOrder), $sortOrder)[0];
                //                time, restname, username, email, phone, street, apt, city, state, zip, items, total
                //                               array_multisort($nonOrderedOrder_trimmed, $sortOrder);
                $orderedOrder = $nonOrderedOrder_trimmed;
                $orderedOrder["category_id"] = $nonOrderedOrder["category_id"];
                $orderedOrder["campus"] = $nonOrderedOrder["campus"];
                $orderedOrder["timeSince"] = $di->d;
                $orders[] = $orderedOrder;
            }
        }
    }
    $keys = array("category_id", "timeSince", "campus");
    $orders = array_orderby($orders, $keys[$f - 1], SORT_ASC);
    $orders = refineArrayReductively($orders, array("category_id", "campus", "timeSince"));
    return $orders;
    // t = time, s = service, f = filter, c = company
}
コード例 #5
0
                         $tmp[$key] = $row[$field];
                     }
                     $args[$n] = $tmp;
                 }
             }
             $args[] =& $data;
             call_user_func_array('array_multisort', $args);
             return array_pop($args);
         }
     }
     // ��� ����� � ����������� � ����...
     $mSortBy = SORT_ASC;
     if (strtolower($GLOBALS[$oSort->ord_name]) == "desc") {
         $mSortBy = SORT_DESC;
     }
     $aFilteredCat = array_orderby($aFilteredCat, substr($GLOBALS[$oSort->by_name], 2), $mSortBy, 'GEM', SORT_ASC);
 }
 $rsData->InitFromArray($aFilteredCat);
 $rsData = new CAdminResult($rsData, $sTableID);
 $rsData->NavStart();
 $lAdmin->NavText($rsData->GetNavPrint("BitrixGems"));
 while ($arRes = $rsData->NavNext(true, "f_")) {
     $row =& $lAdmin->AddRow($f_NAME, $arRes);
     $bCanBeInstalled = BitrixGems::checkRequirements($arRes);
     $row->AddViewField("TYPE", GetMessage('GEM_TYPE_' . $f_TYPE));
     if (empty($f_PICTURE)) {
         $f_PICTURE = '/bitrix/images/iv.bitrixgems/ruby.png';
     }
     $row->AddViewField("PICTURE", '<div style="text-align:center;"><img src="' . $f_PICTURE . '" alt="' . $f_NAME . '" title="' . $f_NAME . '"/></div>');
     $row->AddViewField("DESCRIPTION", nl2br($f_DESCRIPTION));
     $row->AddViewField("REQUIREMENTS", '<font style="color:' . ($bCanBeInstalled ? 'green' : 'red') . '">' . $f_REQUIREMENTS . GetMessage('TR_REQ_MODULE_VERSION') . $f_REQUIRED_MIN_MODULE_VERSION . (!empty($f_REQUIRED_MODULES) ? GetMessage('TR_REQ_MODULES') . implode(', ', $f_REQUIRED_MODULES) : '') . (!empty($f_REQUIRED_GEMS) ? GetMessage('TR_REQ_GEMS') . implode(', ', $f_REQUIRED_GEMS) : '') . '</font>');
コード例 #6
0
ファイル: modal.php プロジェクト: wgviana/SaudeNaCopa
            $novoArray["campo7"] = 0;
            $novoArray["campo8"] = 0;
            $novoArray["campo9"] = 0;
            $novoArray["campo10"] = 0;
            $novoArray["campo11"] = 0;
            $novoArray["campo12"] = 0;
            $novoArray["sentimento"] = 0;
            $novoArray["total"] = 0;
            $novoArray["nome"] = $arrayCidadeSedes[$i];
            $dadoAtual = array();
            $dadoAtual[0] = $novoArray;
            for ($j = 0; $j < count($dados); $j++) {
                $dadoAtual[] = $dados[$j];
            }
            //var_dump($dadoAtual);
            $dados = array_orderby($dadoAtual, 'nome', SORT_ASC);
        }
    }
}
foreach ($dados as $dado) {
    //echo ucwords($dado["nome"]) . "<br>";
    $key = array_search(ucwords(replaceChars($dado["nome"])), $arrayCidadeSedesLimpo);
    //echo "<pre>";
    //var_dump($key);
    if ($key !== false) {
        $total += (int) $dado["total"];
        //print_r($total);
        $arrayCampo1["valor"][] = $dado["campo1"];
        $campo1 += $dado["campo1"];
        $arrayCampo2["valor"][] = $dado["campo2"];
        $campo2 += $dado["campo2"];
コード例 #7
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;
 }
コード例 #8
0
     if (!isset($review_nl[0])) {
         $temp = array();
         $temp[] = $review_nl;
         $review_nl = $temp;
     }
     $sorted = array_merge($sorted, $review_nl);
 }
 if (count($review_en) > 0) {
     if (!isset($review_en[0])) {
         $temp = array();
         $temp[] = $review_en;
         $review_en = $temp;
     }
     $sorted = array_merge($sorted, $review_en);
 }
 $sorted = array_orderby($sorted, 'reviewId', SORT_DESC);
 $reviews = $sorted;
 $result = file_get_contents('http://resto.fr/api/business/getDetails/v1/?apiToken=' . _apiToken . '&language=nl&businessId=' . $id_resto . '');
 $xml = simplexml_load_string($result);
 $xml = json_decode(json_encode((array) simplexml_load_string($result)), 1);
 $details = $xml['businesses']['business'];
 // print_r($details);
 $businessName = $details['businessName'];
 $cleanbusinessName = og_clean_url($businessName);
 $businessType = $details['businessTypeId'];
 switch ($businessType) {
     case '1':
         $businessTypeName = 'restaurant';
         break;
     case '2':
         $businessTypeName = 'caterer';
コード例 #9
0
         		}*/
         if (!$export) {
             $data[$i]["remarks"] = '<input type="text" name="remarks' . $course->id . '" size="" value="">';
         } elseif ($export) {
             if ($form = data_submitted()) {
                 $formarr = (array) $form;
                 $data[$i]["remarks"] = array_key_exists('remarks' . $course->id, $formarr) ? $formarr['remarks' . $course->id] : '';
             }
         }
         $i++;
     }
     if ($fromform->{'c' . $course->id} == 'true' and !$export) {
         $export_courses .= $course->id . ",";
     }
 }
 $data = array_orderby($data, $sortby, constant($sortorder));
 for ($i = 0; $i < sizeof($data); $i++) {
     if ($data[$i]["totalmissed"] == 0) {
         if (!$export) {
             $data[$i]["totalmissed"] = '<div style="background: white;">' . $data[$i]["totalmissed"] . '</div>';
         } else {
             $data[$i]["totalmissed"] = '!!g' . $data[$i]["totalmissed"];
         }
     } elseif ($data[$i]["totalmissed"] <= -3) {
         if (!$export) {
             $data[$i]["totalmissed"] = '<div style="background: red;">' . $data[$i]["totalmissed"] . '</div>';
         } else {
             $data[$i]["totalmissed"] = '!!r' . $data[$i]["totalmissed"];
         }
     } elseif ($data[$i]["totalmissed"] < 0 && $data[$i]["totalmissed"] > -3) {
         if (!$export) {
コード例 #10
0
ファイル: index.php プロジェクト: ssuhss/radioTrikan
        foreach ($album->showFiles() as $album => $musics) {
            $albuns[] = array('id' => "parent_{$parent}", 'parent' => '#', 'text' => strtoupper($album));
            if (is_array($musics) && count($musics)) {
                foreach ($musics as $music) {
                    $albunsM["parent_{$parent}"][] = array('id' => "children_{$children}", 'parent' => "parent_{$parent}", 'text' => basename($music['music']), 'icon' => 'glyphicon glyphicon-music', 'a_attr' => array('href' => $music['music']));
                    $children++;
                }
            }
            $parent++;
        }
        $albumSorted = array_orderby($albuns, 'text', SORT_ASC);
        $cont = 0;
        foreach ($albumSorted as $alb) {
            $arrayzudo[] = $alb;
            $t = $albunsM[$alb['id']];
            $sorted = array_orderby($t, 'text', SORT_ASC);
            foreach ($sorted as $sort) {
                $sort['id'] = "children_{$cont}";
                $arrayzudo[] = $sort;
                $cont++;
            }
        }
        $c->store($nameCache, $arrayzudo);
        $response->body(json_encode($arrayzudo));
    }
});
$app->get('/download/:music', function ($musica) {
    $arquivo = $musica;
    switch (strtolower(substr(strrchr(basename($arquivo), "."), 1))) {
        case "mp3":
            $tipo = "audio/mpeg";
コード例 #11
0
ファイル: share.php プロジェクト: eauland/ShareMe
                 switch ($ext) {
                     case 'gif':
                     case 'jpg':
                     case 'jpeg':
                     case 'png':
                         $lightbox = ' data-lightbox="' . $idfile . '" data-title=" "';
                         break;
                     default:
                         $lightbox = '';
                         break;
                 }
             }
             $data[] = ['type' => $type, 'name_lowercase' => strtolower($name), 'name' => $name, 'path' => $path, 'link' => $link . $arg, 'size' => $size, 'thumb' => $thumb, 'ext' => $ext, 'lightbox' => $lightbox];
         }
     }
     $data = array_orderby($data, 'type', SORT_DESC, 'name_lowercase', SORT_ASC);
     require_once THEME_PATH . '/share/pages/tree.php';
     break;
 } while (0);
 // fin de page des dossiers
 echo '<script type="text/javascript" src="inc/js/qr.js"></script>' . "\n" . '<div class="dialog" id="qrcode">' . "\n" . '<figure>' . "\n" . '<a href="#" class="closemsg"></a>' . "\n" . '<figcaption>' . "\n" . '<h1>' . e('QR Code', false) . '</h1>' . "\n" . '<img src="null" id="qrcode_img" alt="" />' . "\n" . '</figcaption>' . "\n" . '</figure>' . "\n" . '</div>' . "\n" . '<div id="p2p">' . "\n" . '<p>' . e('Show Qrcode of the page:', false) . ' <a href="#qrcode" onclick="qrcode(\'' . $id . '\')"><img alt="" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wgARCAAQABADAREAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAABgUH/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB00IE8YH/xAAZEAEBAQADAAAAAAAAAAAAAAAGBQQCAwf/2gAIAQEAAQUCmSSvnwPZiOJAkXeJ1lTUzl2VP//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EACAQAAMAAgIDAAMAAAAAAAAAAAQFBgIDAQcSFRYAExf/2gAIAQEABj8CdN2+sfVq1J+r0Busjqar6+F17APW/WL3Np/MmNJVzF+0TbPfcNp4gXbrLGnj8gdtAHv/ADQPTHz6OjkV9pBU5VT1jiRmwb0LizlISneX3I9NxMeNcqaUNNUoaByk2WRjjWe3wMI1cbiHKpUPoqFkx0oGkLQdrnVbn9Z1XENC1S+QZ49mt5NPDW/qg+FBMs9KP48l68Xneblht1IabtRfhfEeGUh2UeFOUP0k/iRoGlY4LhruczhLAYxN1T3EON7DdX7/ALbPNfgvYuHNUw//xAAYEAEBAAMAAAAAAAAAAAAAAAABABARIf/aAAgBAQABPyE7jNuFps3j+56lqc9hKy4Nzamf9JrMw1YyO1gosYQE81J//9oADAMBAAIAAwAAABCAD//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8QH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8QH//EABUQAQEAAAAAAAAAAAAAAAAAABAR/9oACAEBAAE/EIMXHJa24g0MdY6ENOwF2VHGt8bENEEzwTJK2VtE5lIf/9k%3D" /></a></p>' . "\n";
 if ($view_rss == true || $view_json == true) {
     echo '<p>' . e('Show this page in:', false) . " \n";
 }
 if ($view_rss == true) {
     echo '<a href="' . $_SESSION['home'] . '?f=' . $_GET['f'] . '&amp;rss">Rss</a>' . "\n";
 }
 if ($view_rss == true && $view_json == true) {
     echo ' | ' . "\n";
 }
 if ($view_json == true) {
            $tmp = array();
            foreach ($data as $key => $row) {
                $tmp[$key] = $row[$field];
            }
            $args[$n] = $tmp;
        }
    }
    $args[] =& $data;
    call_user_func_array('array_multisort', $args);
    return array_pop($args);
}
$counts = json_decode(json_encode($counts), true);
$total = array_sum(array_column($counts, 'count'));
$percent = intval($total) / 5;
$sortcount = $counts;
$sortcount = array_orderby($counts, 'count', SORT_DESC, 'role', SORT_ASC);
$full = $sortcount[0]['count'];
$barcount = count($counts);
$incr = 0;
ob_start();
?>
<ul id="wcp-role-distro">
    <?php 
foreach ($sortcount as $role) {
    if (in_array($role['role'], $roles)) {
        $role_img = explode('/', $role['role']);
        $role_img = strtolower(trim(str_replace(' ', '-', $role_img[0])));
        ?>
            <li style="height:<?php 
        echo round($role['count'] / $full * 100 * 3 / 4, 2);
        ?>
コード例 #13
0
ファイル: mycode.php プロジェクト: shadowjohn/mycode
                 $m = array();
                 $m['filename'] = "{$az[$i]}:";
                 $m['isdir'] = '1';
                 array_push($mWinDisk, $m);
             }
         }
     }
 }
 for ($i = 0, $max_i = count($dirfiles); $i < $max_i; $i++) {
     $m = array();
     $m['filename'] = $dirfiles[$i];
     $m['isdir'] = is_dir($dirfiles[$i]) ? '1' : '0';
     array_push($mDatas, $m);
 }
 $mSortedDatas = array();
 $mDirs = array_orderby($mDatas, 'isdir', SORT_DESC, 'filename', SORT_ASC);
 $mSortedDatas = array_merge($mWinDisk, $mDirs);
 ?>
 <table border="0" width="100%" cellpadding="0" cellspacing="0">
   <?php 
 for ($i = 0, $max_i = count($mSortedDatas); $i < $max_i; $i++) {
     //echo realpath($mSortedDatas[$i]['filename'])."<br>";
     $realpath = realpath($mSortedDatas[$i]['filename']);
     //$realpath=$mSortedDatas[$i]['filename'];
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         $b_realpath = str_replace("\\\\", "\\", $mSortedDatas[$i]['filename']);
         $b_realpath = mb_convert_encoding($b_realpath, 'UTF-8', 'BIG5');
     } else {
         $b_realpath = $mSortedDatas[$i]['filename'];
     }
     $m_basename = explode(DIRECTORY_SEPARATOR, $b_realpath);
コード例 #14
0
ファイル: DataSet.php プロジェクト: faizan31/datagrid
 /**
  * flush events, build pagination and sort items
  * 
  * @return $this
  */
 public function build()
 {
     BurpEvent::flush('dataset.sort');
     BurpEvent::flush('dataset.page');
     $this->paginator = Paginator::make($this->total_rows, $this->per_page, $this->page);
     $offset = $this->paginator->offset();
     $this->limit($this->per_page, $offset);
     if (is_array($this->source)) {
         //orderby
         if (isset($this->orderby)) {
             list($field, $direction) = $this->orderby;
             array_orderby($this->source, $field, $direction);
         }
         //limit-offset
         if (isset($this->limit)) {
             $this->source = array_slice($this->source, $this->limit[1], $this->limit[0]);
         }
         $this->data = $this->source;
     } else {
         //orderby
         if (isset($this->orderby)) {
             $this->query = $this->query->orderBy($this->orderby[0], $this->orderby[1]);
         }
         //limit-offset
         if (isset($this->per_page)) {
             $this->query = $this->query->skip($offset)->take($this->per_page);
         }
         $this->data = $this->query->get();
     }
     return $this;
 }
コード例 #15
0
ファイル: GenCLS_report.php プロジェクト: EdijsMuiznieks/Test
 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;
 }
コード例 #16
0
 /**
  * Returns an array of data used for the CMS's list view
  *
  * @access	public
  * @param	int		limit
  * @param	string	offset
  * @param	string	column
  * @param	string	order
  * @return	array
  */
 public function list_items($limit = null, $offset = 0, $col = 'name', $order = 'asc')
 {
     $CI =& get_instance();
     $CI->load->helper('array');
     $CI->load->helper('convert');
     if (!isset($this->filters['group_id'])) {
         return array();
     }
     $group_id = $this->filters['group_id'];
     // not encoded yet... then decode
     if (!$this->_encoded) {
         $this->filters['group_id'] = uri_safe_encode($group_id);
         // to pass the current folder
         $this->_encoded = TRUE;
     } else {
         $group_id = uri_safe_decode($group_id);
     }
     $asset_dir = $CI->fuel->assets->dir($group_id);
     $assets_path = $CI->asset->assets_server_path() . $asset_dir . DIRECTORY_SEPARATOR;
     $exclude = $CI->fuel->config('assets_excluded_dirs');
     $exclude[] = 'index.html';
     $tmpfiles = directory_to_array($assets_path, TRUE, $exclude, FALSE);
     $files = get_dir_file_info($assets_path, FALSE, TRUE);
     $cnt = count($tmpfiles);
     $return = array();
     $asset_type_path = WEB_PATH . $CI->config->item('assets_path') . $asset_dir . '/';
     //for ($i = $offset; $i < $cnt - 1; $i++)
     for ($i = 0; $i < $cnt; $i++) {
         if (!empty($tmpfiles[$i]) and !empty($files[$tmpfiles[$i]])) {
             $key = $tmpfiles[$i];
             if (empty($this->filters['name']) || (!empty($this->filters['name']) and stripos($files[$key]['name'], $this->filters['name']) !== FALSE || stripos($key, $this->filters['name']) !== FALSE)) {
                 $file['id'] = uri_safe_encode(assets_server_to_web_path($files[$tmpfiles[$i]]['server_path'], TRUE));
                 //$file['filename'] = $files[$key]['name'];
                 $file['name'] = $key;
                 $file['preview/kb'] = $files[$key]['size'];
                 $file['link'] = NULL;
                 $file['last_updated'] = date('Y-m-d H:i:s', $files[$key]['date']);
                 $return[] = $file;
             }
         }
     }
     $order = $order == 'desc' ? SORT_DESC : SORT_ASC;
     $return = array_orderby($return, $col, $order);
     //$return = array_sorter($return, $col, $order, TRUE);
     // do a check for empty limit values to prevent issues found where an empty $limit value would return nothing in 5.16
     $return = empty($limit) ? array_slice($return, $offset) : array_slice($return, $offset, $limit);
     // after sorting add the images
     foreach ($return as $key => $val) {
         if (is_image_file($return[$key]['name'])) {
             $return[$key]['preview/kb'] = $return[$key]['preview/kb'] . ' kb <div class="img_crop"><a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank"><img src="' . $asset_type_path . $return[$key]['name'] . '?c=' . time() . '" border="0"></a></div>';
             $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>';
         } else {
             $return[$key]['preview/kb'] = $return[$key]['preview/kb'];
             $return[$key]['link'] = '<a href="' . $asset_type_path . $return[$key]['name'] . '" target="_blank">' . $asset_dir . '/' . $return[$key]['name'] . '</a>';
         }
     }
     return $return;
 }
コード例 #17
0
ファイル: process.php プロジェクト: unrealord/TorrentzRSS
function run($p, $r, $q)
{
    $channel = array();
    $params = explode('-', $p);
    $cin = array("ñ", "Ñ", "ç", "Ç", " ", ">", "<");
    $cout = array("%C3%B1", "%C3%91", "%C3%A7", "%C3%87", "+", "%3E", "%3C");
    $q = str_replace($cin, $cout, $q);
    //General settings
    if (isset($params[2])) {
        if ($GLOBALS['SQI'] == 0) {
            //set TTL to main search query, skip nested ones.
            $GLOBALS['userTTL'] = intval(substr($params[2], 1));
            $GLOBALS['linksSource'] = isset($params[5]) && strlen($params[5]) >= 2 ? substr($params[5], 1) : 'm';
        }
        $GLOBALS['session'][$GLOBALS['SQI']]['duplicatesDelay'] = intval(substr($params[3], 1));
        $GLOBALS['session'][$GLOBALS['SQI']]['duplicatesDelayOnlyRSS'] = strpos($params[4], 'r') !== false;
        $GLOBALS['session'][$GLOBALS['SQI']]['keepPreviousResults'] = strpos($params[4], 'k') !== false;
    }
    $left = rand(1, 100) / 100;
    logThis($left, 'left');
    $using_remote_node = false;
    if (RSSZ_MULTIPLE_NODES && $left > RSSZ_RATIO) {
        //HANDLING RSSZ_MULTIPLE_NODES:
        $left -= RSSZ_RATIO;
        foreach ($GLOBALS['_NODES'] as $slave) {
            if (($left -= $slave[1]) <= 0) {
                //remote request
                $using_remote_node = true;
                if (RSSZ_SET_TIMEOUT) {
                    ini_set('default_socket_timeout', max(round($slave[2] * $params[1]), 1));
                }
                $query = $slave[0] . "?f=json&p=" . $p . "&r=&q=" . $q;
                if (($sum = @remote_process_url($query, $channel)) === null) {
                    logThis("FALLBACK FROM REMOTE NODE! {$query}", "FALLBACK!");
                    $using_remote_node = false;
                } else {
                    $GLOBALS['results'] += $sum;
                }
                logThis($query, 'Query');
                logThis(ini_get('default_socket_timeout'), 'Timeout');
                break;
            }
        }
    }
    if (!$using_remote_node) {
        if (RSSZ_SET_TIMEOUT) {
            ini_set('default_socket_timeout', intval(RSSZ_TIMEOUT_PER_PAGE));
        }
        $query = "http://torrentz.eu/" . $params[0] . "?q=" . $q;
        $page = 0;
        while (($sum = process_url($query . '&p=' . $page, $channel_aux)) != 0 && $params[1] * 2 > $page) {
            $channel = array_merge($channel, $channel_aux);
            $GLOBALS['results'] += $sum;
            $channel_aux = array();
            $page += 2;
        }
        logThis(ini_get('default_socket_timeout'), 'Timeout');
    }
    $r = explode('-', $r);
    foreach ($r as $rule) {
        switch (substr($rule, 0, 1)) {
            case 'l':
                //limit results
                if (count($channel) > intval(substr($rule, 1))) {
                    $channel = array_slice($channel, 0, intval(substr($rule, 1)));
                }
                break;
            case 'm':
                //merge
                $tiny = substr($rule, 1);
                if (strlen($tiny) > 10 && file_exists("data/" . $tiny)) {
                    $request = unserialize(file_get_contents("data/" . $tiny));
                    $GLOBALS['SQI']++;
                    //Initialize session for this nested search query and load hashes
                    $GLOBALS['session'][$GLOBALS['SQI']] = array('duplicatesDelay' => 0, 'duplicatesDelayOnlyRSS' => false, 'keepPreviousResults' => false, 'priority_hashes' => isset($request['hashes']) ? $request['hashes'] : array());
                    //$GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'] = (isset($request['hashes'])) ? $request['hashes'] : array();
                    $aux = run($request['p'], $request['r'], $request['q']);
                    //save hashes back
                    $bdata = unserialize(file_get_contents("data/" . $tiny));
                    $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'] = array();
                    foreach ($aux as $result) {
                        $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'][$result['hash']] = true;
                    }
                    $bdata['hashes'] = $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'];
                    file_put_contents("data/" . $tiny, serialize($bdata));
                    //end save
                    $GLOBALS['SQI']--;
                    $channel = array_merge($channel, $aux);
                }
                break;
            case 'i':
                //intersection
                $tiny = substr($rule, 1);
                if (strlen($tiny) > 10 && file_exists("data/" . $tiny)) {
                    $request = unserialize(file_get_contents("data/" . $tiny));
                    $GLOBALS['SQI']++;
                    //Initialize session for this nested search query and load hashes
                    $GLOBALS['session'][$GLOBALS['SQI']] = array('duplicatesDelay' => 0, 'duplicatesDelayOnlyRSS' => false, 'keepPreviousResults' => false, 'priority_hashes' => isset($request['hashes']) ? $request['hashes'] : array());
                    //$GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'] = (isset($request['hashes'])) ? $request['hashes'] : array();
                    $aux = run($request['p'], $request['r'], $request['q']);
                    //save hashes back
                    $bdata = unserialize(file_get_contents("data/" . $tiny));
                    $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'] = array();
                    foreach ($aux as $result) {
                        $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'][$result['hash']] = true;
                    }
                    $bdata['hashes'] = $GLOBALS['session'][$GLOBALS['SQI']]['priority_hashes'];
                    file_put_contents("data/" . $tiny, serialize($bdata));
                    //end save
                    $GLOBALS['SQI']--;
                    $channel = array_uintersect($channel, $aux, 'compareHash');
                }
                break;
            case 's':
                //sort
                $arg = substr($rule, 2, 1) == 'A' ? SORT_ASC : SORT_DESC;
                $field = '';
                switch (substr($rule, 1, 1)) {
                    case 't':
                        $field = 'title_lowercase';
                        break;
                    case 'd':
                        $field = 'pubtimestamp';
                        break;
                    case 's':
                        $field = 'size_raw';
                        break;
                    case 'p':
                        $field = 'peers';
                        break;
                    case 'e':
                        $field = 'seeds';
                        break;
                    case 'l':
                        $field = 'leechers';
                        break;
                    case 'm':
                        $field = 'seeds-leechers';
                        break;
                }
                $channel = array_orderby($channel, $field, $arg);
                break;
            case 'd':
                //Handle duplicates as movies
                $hashes = handleDuplicatesAsMovies($channel, $rule);
                $i = 0;
                $channels = count($channel);
                while ($i < $channels) {
                    if (isset($hashes[$channel[$i]['hash']])) {
                        unset($hashes[$channel[$i]['hash']]);
                    } else {
                        unset($channel[$i]);
                    }
                    ++$i;
                }
                $channel = array_values($channel);
                //reindex
                break;
            case 't':
                //Handle duplicates as TV shows
                $hashes = handleDuplicatesAsTVShows($channel, $rule);
                $i = 0;
                $channels = count($channel);
                while ($i < $channels) {
                    if (isset($hashes[$channel[$i]['hash']])) {
                        unset($hashes[$channel[$i]['hash']]);
                    } else {
                        unset($channel[$i]);
                    }
                    ++$i;
                }
                $channel = array_values($channel);
                //reindex
                break;
            case 'e':
                //Exclude
                $pos = strpos($rule, 'p');
                $args = substr($rule, 0, $pos);
                //r=regexp, m=matching, t=title
                $isRegExp = strpos($args, 'r');
                $matching = strpos($args, 'm');
                $fromTitle = strpos($args, 't');
                $pattern = base64_decode(substr($rule, $pos + 1));
                //strtolower(base64_decode(substr($rule, $pos + 1)), ENT_COMPAT, "UTF-8");
                if (!$isRegExp) {
                    $pattern = getPatternsFromString($pattern);
                }
                logThis($pattern, "Pattern");
                $i = 0;
                $channels = count($channel);
                while ($i < $channels) {
                    $field = $fromTitle ? $channel[$i]['title_lowercase'] : $channel[$i]['category'][0];
                    $match = true;
                    if ($isRegExp) {
                        $match = preg_match("/" . $pattern . "/", $field);
                    } else {
                        foreach ($pattern as $pattern_) {
                            if (!preg_match("/" . $pattern_ . "/i", $field)) {
                                $match = false;
                                break;
                            }
                        }
                    }
                    if ($match && $matching) {
                        unset($channel[$i]);
                    } else {
                        if (!$match && !$matching) {
                            unset($channel[$i]);
                        }
                    }
                    ++$i;
                }
                $channel = array_values($channel);
                //reindex
                break;
            case 'c':
                //Evaluate condition
                $unsafe = base64_decode(substr($rule, 1));
                $condition = preg_replace('/[^(?:seeds)(?:peers)(?:leechers)(?:size)\\+\\-\\*\\/%(?:==)(?:!=)<>(?:<=)(?:>=)!&\\|\\^\\~\\(\\)\\s0-9\\.]/', '', $unsafe);
                if (!strlen($condition)) {
                    break;
                }
                if ($unsafe != $condition) {
                    $GLOBALS['errors'][] = "Input from 'Evaluate condition' rule was reinterpreted as: " . $condition;
                }
                $i = 0;
                $channels = count($channel);
                while ($i < $channels) {
                    $condition_i = str_replace(array('seeds', 'peers', 'leechers', 'size'), array(strval($channel[$i]['seeds']), strval($channel[$i]['peers']), strval($channel[$i]['leechers']), strval($channel[$i]['size_raw'])), $condition);
                    $condition_i = preg_replace('/[^\\+\\-\\*\\/%(?:==)(?:!=)<>(?:<=)(?:>=)!&\\|\\^\\~\\(\\)\\s0-9\\.]/', '', $condition_i);
                    if (!@eval("return (" . $condition_i . ");")) {
                        unset($channel[$i]);
                    }
                    ++$i;
                }
                $channel = array_values($channel);
                //reindex
                break;
        }
    }
    return $channel;
}
コード例 #18
0
ファイル: getWall.php プロジェクト: storres93/comuBackup
            }
            $resFile->close();
        }
        if ($msgId != "") {
            $resMsg = $db->query("SELECT * FROM tblnews WHERE newsId IN (" . $msgId . ") ORDER BY date DESC");
            while ($row = $resMsg->fetch_array()) {
                $cats = array();
                $row["type"] = 2;
                $resName = $db->query("SELECT user FROM tblusers WHERE userId='" . $row['fromId'] . "'");
                $userA = $resName->fetch_assoc();
                $row["user"] = $userA["user"];
                $resNoti = $db->query("SELECT readd FROM tblnotif WHERE type=2 AND targetId='" . $row['newsId'] . "'");
                $notiA = $resNoti->fetch_assoc();
                $row["readd"] = $notiA["readd"];
                $resCat = $db->query("SELECT category FROM tblcategories WHERE type=2 AND targetId='" . $row['newsId'] . "'");
                while ($rowCat = $resCat->fetch_assoc()) {
                    $cats[] = $rowCat;
                }
                $row["cats"] = $cats;
                $row['text'] = txt2link($row['text']);
                $data[] = $row;
            }
            $resMsg->close();
        }
        $sorted = array_orderby($data, 'date', SORT_DESC);
        echo json_encode($sorted);
    } else {
        echo 0;
    }
    $result->close();
}
コード例 #19
0
 public function getColaboradores($busca = null)
 {
     $sql = "SELECT \n\t\t\t\t\tcol.cod_colaborador, \n\t\t\t\t    col.num_matricula, \n\t\t\t\t    col.nme_colaborador, \n\t\t\t\t    CAST(col.flg_portador_necessidades_especiais AS UNSIGNED) AS flg_portador_necessidades_especiais,\n\t\t\t\t    col.cod_empresa_contratante,\n\t\t\t\t    col.cod_contrato,\n\t\t\t\t    emp.nme_fantasia,\n\t\t\t\t    col.cod_contrato,\n\t\t\t\t    org.dsc_origem,\n\t\t\t\t    col.cod_regime_contratacao,\n\t\t\t\t    trc.dsc_regime_contratacao,\n\t\t\t\t\tcol.cod_departamento,\n\t\t\t\t    dpt.nme_departamento,\n\t\t\t\t    col.flg_cm, \n\t\t\t\t    col.cod_local_trabalho,\n\t\t\t\t    ltr.nme_local_trabalho,\n\t\t\t\t    col.cod_grade_horario,\n\t\t\t\t    grh.nme_grade_horario,\n\t\t\t\t    CAST(col.flg_ativo AS UNSIGNED) AS flg_ativo,\n\t\t\t\t    CAST(col.flg_trabalho_fim_semana AS UNSIGNED) AS flg_trabalho_fim_semana,\n\t\t\t\t    CAST(col.flg_trabalho_feriado AS UNSIGNED) AS flg_trabalho_feriado,\n\t\t\t\t    CAST(col.flg_ajusta_folha_ponto AS UNSIGNED) AS flg_ajusta_folha_ponto,\n\t\t\t\t    col.dta_admissao,\n\t\t\t\t    col.dta_demissao,\n\t\t\t\t    col.num_ctps,\n\t\t\t\t    col.num_serie_ctps,\n\t\t\t\t    col.cod_estado_ctps,\n\t\t\t\t    est_ctps.sgl_estado as sgl_estado_ctps,\n\t\t\t\t    est_ctps.nme_estado as nme_estado_ctps,\n\t\t\t\t    col.dta_emissao_ctps,\n\t\t\t\t\tcol.num_rg,\n\t\t\t\t\tcol.num_cpf,\n\t\t\t\t    col.num_pis,\n\t\t\t\t    col.num_titulo_eleitor,\n\t\t\t\t    col.num_zona_eleitoral,\n\t\t\t\t    col.num_secao_eleitoral,\n\t\t\t\t    col.num_reservista,\n\t\t\t\t    col.dsc_endereco,\n\t\t\t\t    col.num_endereco,\n\t\t\t\t    col.nme_bairro,\n\t\t\t\t    col.dsc_complemento,\n\t\t\t\t    cid_mor.nme_cidade as nme_cidade_moradia,\n\t\t\t\t    col.cod_cidade_moradia,\n\t\t\t\t    col.cod_estado_moradia,\n\t\t\t\t    est_mor.sgl_estado as sgl_estado_moradia,\n\t\t\t\t    est_mor.nme_estado as nme_estado_moradia,\n\t\t\t\t    col.cod_cidade_naturalidade,\n\t\t\t\t    col.cod_estado_naturalidade,\n\t\t\t\t    col.cod_estado_moradia,\n\t\t\t\t    col.num_cep,\n\t\t\t\t    col.dta_nascimento,\n\t\t\t\t    cid_nat.nme_cidade as nme_cidade_naturalidade,\n\t\t\t\t    est_nat.sgl_estado as sgl_estado_naturalidade,\n\t\t\t\t    est_nat.nme_estado as nme_estado_naturalidade,\n\t\t\t\t    col.num_cnh,\n\t\t\t\t    col.nme_categoria_cnh,\n\t\t\t\t    col.dta_validade_cnh,\n\t\t\t\t    col.flg_sexo,\n\t\t\t\t    col.cod_banco,\n\t\t\t\t    bnc.nme_banco,\n\t\t\t\t    col.num_agencia,\n\t\t\t\t    col.num_digito_agencia,\n\t\t\t\t    col.num_conta_corrente,\n\t\t\t\t    col.num_digito_conta_corrente,\n\t\t\t\t\tcol.cod_sindicato,\n\t\t\t\t    sdc.nme_sindicato,\n\t\t\t\t    col.pth_arquivo_cnh,\n\t\t\t\t    col.pth_arquivo_rg,\n\t\t\t\t    col.pth_arquivo_foto,\n\t\t\t\t    col.pth_arquivo_cpf,\n\t\t\t\t    col.pth_arquivo_entidade,\n\t\t\t\t    col.pth_arquivo_curriculo,\n\t\t\t\t    col.pth_arquivo_reservista,\n\t\t\t\t    col.cod_entidade,\n\t\t\t\t    ent.nme_entidade,\n\t\t\t\t    col.num_entidade,\n\t\t\t\t    col.qtd_horas_contratadas,\n\t\t\t\t    CAST(col.flg_hora_extra AS UNSIGNED) AS flg_hora_extra,\n\t\t\t\t    CAST(col.flg_ensino_superior AS UNSIGNED) AS flg_ensino_superior,\n\t\t\t\t    vfm.nme_funcao as nme_funcao_medicao,\n\t\t\t\t    vfc.nme_funcao as nme_funcao_clt,\n\t\t\t\t    vfc.vlr_salario as vlr_slario_clt,\n\t\t\t\t    col.cod_estado_civil,\n\t\t\t\t    tec.nme_estado_civil\n\n\t\t\t\tFROM tb_colaborador \t\t\tAS col\n\t\t\t\tLEFT JOIN tb_estado_civil \t\tAS tec \t\t\tON tec.cod_estado_civil \t\t\t\t= col.cod_estado_civil\n\t\t\t\tLEFT JOIN tb_empresa \t\t\tAS emp \t\t\tON emp.cod_empresa \t\t\t\t\t\t= col.cod_empresa_contratante\n\t\t\t\tLEFT JOIN tb_origem \t\t\tAS org\t\t\tON org.cod_origem \t\t\t\t\t\t= col.cod_contrato\n\t\t\t\tLEFT JOIN tb_regime_contratacao AS trc \t\t\tON trc.cod_regime_contratacao \t\t\t= col.cod_regime_contratacao\n\t\t\t\tLEFT JOIN tb_departamento \t\tAS dpt\t\t\tON dpt.cod_departamento \t\t\t\t= col.cod_departamento\n\t\t\t\tLEFT JOIN tb_local_trabalho   \tAS ltr \t\t\tON ltr.cod_local_trabalho \t\t\t\t= col.cod_local_trabalho\n\t\t\t\tLEFT JOIN tb_grade_horario\t\tAS grh \t\t\tON grh.cod_grade_horario\t\t\t\t= col.cod_grade_horario\n\t\t\t\tLEFT JOIN tb_estado\t\t\t\tAS est_ctps\t \tON est_ctps.cod_estado \t\t\t\t\t= col.cod_estado_ctps\n\t\t\t\tLEFT JOIN tb_cidade\t\t\t\tAS cid_mor \t\tON cid_mor.cod_cidade\t\t\t\t\t= col.cod_cidade_moradia\n\t\t\t\tLEFT JOIN tb_estado\t\t\t\tAS est_mor  \tON est_mor.cod_estado\t\t\t\t\t= col.cod_estado_moradia\n\t\t\t\tLEFT JOIN tb_cidade\t\t\t\tAS cid_nat\t\tON cid_nat.cod_cidade\t\t\t\t\t= col.cod_cidade_naturalidade\n\t\t\t\tLEFT JOIN tb_estado\t\t\t\tAS est_nat\t\tON est_nat.cod_estado\t\t\t\t\t= col.cod_estado_naturalidade\n\t\t\t\tLEFT JOIN tb_banco\t\t\t\tAS bnc\t\t\tON bnc.cod_banco\t\t\t\t\t\t= col.cod_banco\n\t\t\t\tLEFT JOIN tb_sindicato\t\t\tAS sdc\t\t\tON sdc.cod_sindicato\t\t\t\t\t= col.cod_sindicato\n\t\t\t\tLEFT JOIN tb_entidade\t\t\tAS ent\t\t\tON ent.cod_entidade\t\t\t\t\t\t= col.cod_entidade\n\t\t\t\tLEFT JOIN vw_funcao_medicao \tas vfm \t\t\tON vfm.cod_colaborador\t\t\t\t\t= col.cod_colaborador\n\t\t\t\tLEFT JOIN vw_funcao_clt \t\tas vfc \t\t\tON vfc.cod_colaborador\t\t\t\t\t= col.cod_colaborador";
     $nolimit = false;
     $limit = 5;
     $offset = 0;
     $sort = "";
     $order = "asc";
     $search = "";
     if (is_array($busca) && count($busca) > 0) {
         if (isset($busca['nolimit'])) {
             $nolimit = true;
             unset($busca['nolimit']);
         }
         if (isset($busca['limit'])) {
             $limit = $busca['limit'];
             unset($busca['limit']);
         }
         if (isset($busca['offset'])) {
             $offset = $busca['offset'];
             unset($busca['offset']);
         }
         if (isset($busca['sort'])) {
             $sort = $busca['sort'];
             unset($busca['sort']);
         }
         if (isset($busca['order'])) {
             $order = $busca['order'];
             unset($busca['order']);
             if ($order == "asc") {
                 $order = SORT_ASC;
             } else {
                 if ($order == "desc") {
                     $order = SORT_DESC;
                 }
             }
         }
         if (isset($busca['search'])) {
             $search = $busca['search'];
             unset($busca['search']);
         }
         if ($search != "") {
             $sql .= " WHERE col.flg_excluido = 0 AND nme_colaborador LIKE '%{$search}%' OR nme_fantasia LIKE '%{$search}%' OR nme_departamento LIKE '%{$search}%'";
             if (count($busca) > 0) {
                 $where = prepareWhere($busca);
                 $sql .= " AND " . $where;
             }
         } else {
             if (count($busca) > 0) {
                 $where = prepareWhere($busca);
                 $sql .= " WHERE " . $where;
                 $sql .= " AND col.flg_excluido = 0";
             } else {
                 $sql .= " WHERE col.flg_excluido = 0";
             }
         }
     }
     $sql .= " ORDER BY col.nme_colaborador ASC";
     $select = $this->conn->prepare($sql);
     if ($select->execute()) {
         if ($select->rowCount() > 0) {
             if ($sort != "") {
                 $result = array_orderby($select->fetchALL(PDO::FETCH_ASSOC), $sort, $order);
             } else {
                 $result = $select->fetchALL(PDO::FETCH_ASSOC);
             }
             $sizeOfResult = count($result);
             if (!$nolimit) {
                 $result = array_slice($result, $offset, $limit);
             }
             $data = array();
             $data['total'] = $sizeOfResult;
             $data['rows'] = $result;
             return $data;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #20
0
function webdictionary_search($where, $orderby, $offset, $max)
{
    global $DB;
    global $website;
    global $theme;
    $theme_translations = array();
    if (!empty($theme)) {
        $theme_translations = $theme->get_translations();
        // force load theme dictionary in all languages available
        // search filters for theme strings (ONLY ENABLED FOR QUICKSEARCH)
        // $where example = 'website = 1 AND ( node_id LIKE "%design%" OR lang LIKE "%design%" OR text LIKE "%design%")'
        // extract the pattern
        $qsearch = substr($where, strpos($where, ' LIKE "%') + 8);
        $qsearch = mb_strtolower(substr($qsearch, 0, strpos($qsearch, '%" OR')));
        $qsearch = trim($qsearch);
        // remove theme strings that do not match the search query
        if (!empty($qsearch)) {
            for ($trs = 0; $trs < count($theme_translations); $trs++) {
                $tt_text = mb_strtolower($theme_translations[$trs]['text']);
                $tt_theme = mb_strtolower($theme_translations[$trs]['theme']);
                $tt_id = mb_strtolower($theme_translations[$trs]['node_id']);
                $tt_lang = $theme_translations[$trs]['lang'];
                if (strpos($tt_text, $qsearch) === false && strpos($tt_theme, $qsearch) === false && strpos($tt_id, $qsearch) === false && strpos($tt_lang, $qsearch) === false) {
                    $theme_translations[$trs] = NULL;
                }
            }
        }
        $theme_translations = array_filter($theme_translations);
        sort($theme_translations);
    }
    $extensions_translations = array();
    $extensions = extension::list_installed();
    if (!is_array($extensions)) {
        $extensions = array();
    }
    foreach ($extensions as $extension) {
        $ext = new extension();
        $ext->load($extension['code']);
        $extension_translations = $ext->get_translations();
        // load all translations of the extension
        // remove extension strings that do not match the search query
        if (!empty($qsearch)) {
            for ($trs = 0; $trs < count($extension_translations); $trs++) {
                $tt_text = mb_strtolower($extension_translations[$trs]['text']);
                $tt_extension = mb_strtolower($extension_translations[$trs]['extension']);
                $tt_id = mb_strtolower($extension_translations[$trs]['node_id']);
                $tt_lang = $extension_translations[$trs]['lang'];
                if (strpos($tt_text, $qsearch) === false && strpos($tt_extension, $qsearch) === false && strpos($tt_id, $qsearch) === false && strpos($tt_lang, $qsearch) === false) {
                    $extension_translations[$trs] = NULL;
                }
            }
            $extension_translations = array_filter($extension_translations);
        }
        if (!empty($extension_translations)) {
            $extensions_translations = array_merge($extensions_translations, $extension_translations);
        }
    }
    $DB->query('
		SELECT id, theme, node_id, node_type, lang, `text`, CONCAT_WS(".", node_type, "" , subtype) AS source
		  FROM nv_webdictionary
		 WHERE ' . $where . '
		   AND node_type = "global"
		
		UNION 
		
		SELECT id, theme, subtype AS node_id, node_type, lang, `text`, CONCAT_WS(".", node_type, theme, subtype) AS source
		  FROM nv_webdictionary
		 WHERE ' . $where . '
		   AND node_type = "theme"', 'array');
    $resultset = $DB->result();
    // remove from theme_translations the strings already present (customized) in database
    for ($dbrs = 0; $dbrs < count($resultset); $dbrs++) {
        for ($trs = 0; $trs < count($theme_translations); $trs++) {
            if ($resultset[$dbrs]['node_type'] == "theme" && $resultset[$dbrs]['node_id'] == $theme_translations[$trs]['node_id'] && $resultset[$dbrs]['lang'] == $theme_translations[$trs]['lang']) {
                unset($theme_translations[$trs]);
                break;
            }
        }
    }
    $dataset = array_merge($resultset, $theme_translations);
    $DB->query('
		SELECT id, extension, node_type, subtype AS node_id, lang, `text`, CONCAT_WS(".", node_type, extension, subtype) AS source
		  FROM nv_webdictionary
		 WHERE ' . $where . '
		   AND node_type = "extension"', 'array');
    $resultset = $DB->result();
    // remove from extension translations the strings already present (customized) in database
    for ($dbrs = 0; $dbrs < count($resultset); $dbrs++) {
        for ($trs = 0; $trs < count($extensions_translations); $trs++) {
            if ($resultset[$dbrs]['node_type'] == "extension" && $resultset[$dbrs]['extension'] == $extensions_translations[$trs]['extension'] && $resultset[$dbrs]['node_id'] == $extensions_translations[$trs]['node_id'] && $resultset[$dbrs]['lang'] == $extensions_translations[$trs]['lang']) {
                unset($extensions_translations[$trs]);
                break;
            }
        }
    }
    $dataset = array_merge($dataset, $resultset, $extensions_translations);
    $total = count($dataset);
    // reorder dataset
    $orderby = explode(' ', $orderby);
    // [0] -> column, [1] -> asc | desc
    $dataset = array_orderby($dataset, $orderby[0], $orderby[1] == 'desc' ? SORT_DESC : SORT_ASC);
    $dataset = array_slice($dataset, $offset, $max);
    return array($dataset, $total);
}
コード例 #21
0
ファイル: class_weg.php プロジェクト: BerlusGmbH/Berlussimo
 function hga_einzeln($p_id = '0')
 {
     $this->get_hga_profil_infos($p_id);
     /* Tage im Jahr */
     $jahr = $this->p_jahr;
     $bk = new bk();
     if (empty($this->p_von) or empty($this->p_bis)) {
         $tj = $bk->tage_im_jahr($jahr);
     } else {
         $bk = new bk();
         $tj = $bk->diff_in_tagen($this->p_von, $this->p_bis) + 1;
     }
     /* Art = Ausgaben, Einnahmen, Mittelverwendung */
     $_umlage_ktos = $this->get_hgkonten_arr($p_id, 'Ausgaben/Einnahmen', false);
     $_umlage_ktos_sort = array_sortByIndex($_umlage_ktos, 'GRUPPE', 'DESC');
     $_umlage_ktos = $_umlage_ktos_sort;
     unset($_umlage_ktos_sort);
     $anz_k = count($_umlage_ktos);
     if (!$anz_k) {
         die('Keine Kosten im Profil. Bitte Kostenkonten hinzufügen');
     }
     $znr = 0;
     for ($a = 0; $a < $anz_k; $a++) {
         $konto = $_umlage_ktos[$a]['KONTO'];
         $gruppe = $_umlage_ktos[$a]['GRUPPE'];
         $betraege_arr[] = $this->get_betraege_arr($p_id, $konto);
     }
     $einheiten_arr = $this->einheiten_weg_tabelle_arr($this->p_objekt_id);
     /* Alle Einheiten durchlaufen um die Eigentümer und Tage zu Sammeln */
     $anz_einheiten = count($einheiten_arr);
     for ($b = 0; $b < $anz_einheiten; $b++) {
         $einheit_id = $einheiten_arr[$b]['EINHEIT_ID'];
         $eig_arr = $this->get_eigentuemer_arr_jahr($einheit_id, $this->p_jahr);
         // print_r($eig_arr);
         $anz_eig = count($eig_arr);
         /* Eigentuemer untereinander */
         for ($c = 0; $c < $anz_eig; $c++) {
             $eig_arr_1 = $eig_arr[$c];
             $einheiten_arr_eig[] = $eig_arr_1;
         }
     }
     unset($einheiten_arr);
     $anz_eig = count($einheiten_arr_eig);
     /* Kontenrahmen vom Geldkonto holen */
     $k = new kontenrahmen();
     $kontenrahmen_id = $k->get_kontenrahmen('Geldkonto', $this->p_gk_id);
     /**
      * **********PROGRAMMABBRUCH OHNE KONTENRAHMEN**************
      */
     if (!$kontenrahmen_id) {
         die('Kontenrahmen zum Geldkonto fehlt, bitte zuweisen!');
     }
     /* Jeden Eigentuemer für alle Konten durchlaufen */
     $anz_b = count($betraege_arr);
     // Anzahl Konten
     for ($a = 0; $a < $anz_eig; $a++) {
         $eigentuemer_id = $einheiten_arr_eig[$a]['ID'];
         $tab_arr[$a]['EIG_ID'] = $eigentuemer_id;
         $tab_arr[$a]['EINHEIT_ID'] = $einheiten_arr_eig[$a]['EINHEIT_ID'];
         $tab_arr[$a]['VON'] = $einheiten_arr_eig[$a]['VON'];
         $tab_arr[$a]['BIS'] = $einheiten_arr_eig[$a]['BIS'];
         $tab_arr[$a]['TAGE'] = $einheiten_arr_eig[$a]['TAGE'];
         /* Jedes Konto durchlaufen, Daten in Tab und für Eigentuemer berechnen */
         $g_summe_aller_kosten = 0;
         $hndl_z = 0;
         for ($b = 0; $b < $anz_b; $b++) {
             $konto = $betraege_arr[$b]['0']['KONTO'];
             $k->konto_informationen2($konto, $kontenrahmen_id);
             $gen_key_id = $betraege_arr[$b]['0']['GEN_KEY_ID'];
             $bk = new bk();
             $bk->get_genkey_infos($gen_key_id);
             $betrag = $betraege_arr[$b]['0']['BETRAG'];
             $betrag = number_format($betrag, 2, '.', '');
             $g_summe_aller_kosten += $betrag;
             $hndl_betrag = $betraege_arr[$b]['0']['HNDL_BETRAG'];
             $kos_typ = $betraege_arr[$b]['0']['KOS_TYP'];
             $kos_id = $betraege_arr[$b]['0']['KOS_ID'];
             $tab_arr[$a]['ZEILEN'][$b]['KONTO'] = $konto;
             $tab_arr[$a]['ZEILEN'][$b]['KONTO_BEZ'] = $k->konto_bezeichnung;
             $tab_arr[$a]['ZEILEN'][$b]['KONTO_ART'] = $k->konto_art_bezeichnung;
             $tab_arr[$a]['ZEILEN'][$b]['GRUPPE'] = $k->konto_gruppen_bezeichnung;
             $tab_arr[$a]['ZEILEN'][$b]['BETRAG'] = nummer_punkt2komma_t($betrag);
             $tab_arr[$a]['ZEILEN'][$b]['HNDL_BETRAG'] = nummer_punkt2komma($hndl_betrag);
             $tab_arr[$a]['ZEILEN'][$b]['ART'] = $betraege_arr[$b]['0']['ART'];
             if ($hndl_betrag == '0.00') {
                 $tab_arr[$a]['ZEILEN'][$b]['BEZ'] = $betraege_arr[$b]['0']['TEXT'];
             } else {
                 $tab_arr[$a]['ZEILEN'][$b]['BEZ'] = $betraege_arr[$b]['0']['TEXT'] . ' *';
             }
             $r = new rechnung();
             $tab_arr[$a]['ZEILEN'][$b]['KOS_BEZ'] = $r->kostentraeger_ermitteln($kos_typ, $kos_id);
             $einheit_id = $tab_arr[$a]['EINHEIT_ID'];
             if (isset($this->berechnen)) {
                 unset($this->berechnen);
             }
             if ($kos_typ == 'Wirtschaftseinheit') {
                 $wi = new wirt_e();
                 /* Hier weiter mt g_value */
                 $g_value = $this->key_daten_gesamt($gen_key_id, 'Wirtschaftseinheit', $kos_id);
                 if (isset($this->{$ein_berr})) {
                     unset($this->ein_berr);
                 }
                 if ($wi->check_einheit_in_we($einheit_id, $kos_id)) {
                     $this->berechnen = '1';
                 } else {
                     $this->berechnen = '0';
                 }
             }
             /* Berechnungsquote ermitteln pro Konto */
             $d = new detail();
             $e = new einheit();
             $e->get_einheit_info($einheit_id);
             if ($gen_key_id == 1) {
                 $e_anteile = nummer_punkt2komma($e->einheit_qm);
             }
             if ($gen_key_id == 2) {
                 $e_anteile = 1;
             }
             if ($gen_key_id == 3) {
                 $e_anteile = $d->finde_detail_inhalt('EINHEIT', $einheit_id, 'WEG-Anteile');
             }
             if ($gen_key_id == 4) {
                 // die('GenKey 4 nicht definiert');
                 $e_anteile = 0.0;
             }
             /* Aufzug nach Prozent */
             if ($gen_key_id == 5) {
                 $e_anteile = $d->finde_detail_inhalt('EINHEIT', $einheit_id, 'WEG-Aufzugprozent');
                 $g_value = 100;
             }
             $tage = $tab_arr[$a]['TAGE'];
             /* Prüfen ob Einheit im Array der Aufteilung */
             $bet = 0;
             $bet_hndl = 0;
             if ($g_value == 0.0 or empty($g_value)) {
                 $tab_arr[$a]['ZEILEN'][$b]['G_KEY_A'] = $g_value . $bk->g_key_name;
                 $tab_arr[$a]['ZEILEN'][$b]['E_KEY_A'] = $e_anteile . $bk->g_key_me . $bk->g_key_me;
             }
             if ($this->berechnen == 1) {
                 $betrag = number_format($betrag, 2, '.', '');
                 $e_anteile = punkt_zahl($e_anteile);
                 $e_anteile_a = number_format($e_anteile, 3, ',', '');
                 $g_value = punkt_zahl($g_value);
                 $g_value_a = number_format($g_value, 3, ',', '');
                 $bet = $betrag * $e_anteile / $g_value * $tage / $tj;
                 $bet = number_format($bet, 2, '.', '');
                 $bet_hndl = $hndl_betrag * $e_anteile / $g_value * $tage / $tj;
                 $tab_arr[$a]['ZEILEN'][$b]['G_KEY_NAME'] = $bk->g_key_name;
                 $tab_arr[$a]['ZEILEN'][$b]['G_KEY_ME'] = $bk->g_key_me;
                 $tab_arr[$a]['ZEILEN'][$b]['G_KEY_A'] = $g_value_a . $bk->g_key_me;
                 $tab_arr[$a]['ZEILEN'][$b]['E_KEY_A'] = $e_anteile_a . $bk->g_key_me;
             } else {
                 $bet = 0.0;
                 $bet_hndl = 0.0;
             }
             /* HNDL Betrag */
             $bet_a = nummer_punkt2komma($bet);
             $bet_hndl_a = nummer_punkt2komma_t($bet_hndl);
             $tab_arr[$a]['ZEILEN'][$b]['E_BETRAG'] = $bet_a;
             $tab_arr[$a]['ZEILEN'][$b]['E_BETRAG_HNDL'] = $bet_hndl_a;
             /* Ergebnistabelle füttern */
             $eigent_id = $tab_arr[$a]['EIG_ID'];
             $tab_erg['BETRAG'][$eigent_id]['BETEILIGUNG'] += nummer_komma2punkt($bet_a);
             if ($bet_hndl != 0.0) {
                 $tab_erg[BETRAG_HNDL][$eigent_id]['BETEILIGUNG'] += nummer_komma2punkt($bet_hndl_a);
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['KONTO'] = $konto;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['KONTO_BEZ'] = $k->konto_bezeichnung;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['KONTO_ART'] = $k->konto_art_bezeichnung;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['GRUPPE'] = $k->konto_gruppen_bezeichnung;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['BETRAG'] = nummer_punkt2komma_t($betrag);
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['BETRAG_HNDL'] = nummer_punkt2komma_t($hndl_betrag);
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['G_KEY_NAME'] = $bk->g_key_name;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['G_KEY_ME'] = $bk->g_key_me;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['E_KEY_A'] = $e_anteile_a . $bk->g_key_me;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['E_BETRAG_HNDL'] = $bet_hndl_a;
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['KOS_BEZ'] = $r->kostentraeger_ermitteln($kos_typ, $kos_id);
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['BEZ'] = $betraege_arr[$b]['0']['TEXT'] . ' *';
                 $hndl_arr[$eigent_id]['ZEILEN'][$hndl_z]['G_KEY_A'] = $g_value_a . $bk->g_key_me;
                 $hndl_z++;
             }
         }
         // end for Konten $b
     }
     // end for Eigentuemer $a
     $tab_erg['BETRAG']['G_SUMME'] = $g_summe_aller_kosten;
     echo "<hr>";
     $anz = count($tab_arr);
     for ($a = 0; $a < $anz; $a++) {
         $eig_id = $tab_arr[$a]['EIG_ID'];
         $zeilen = $tab_arr[$a]['ZEILEN'];
         $anz_z = count($zeilen);
         echo "<table>";
         echo "<tr><th>EIGENTÜMER {$eig_id}</th></tr>";
         for ($b = 0; $b < $anz_z; $b++) {
             $konto = $zeilen[$b]['KONTO'];
             $bez = $zeilen[$b]['BEZ'];
             $betrag = $zeilen[$b]['BETRAG'];
             $kos_bez = $zeilen[$b]['KOS_BEZ'];
             $e_betrag = $zeilen[$b]['E_BETRAG'];
             echo "<tr><td>{$konto}</td><td>{$bez}</td><td>{$kos_bez}</td><td>{$betrag}</td><td>{$e_betrag}</td></tr>";
             if ($b == $anz_z - 1) {
                 $g_summe = nummer_punkt2komma_t($tab_erg['BETRAG']['G_SUMME']);
                 $g_bet = nummer_punkt2komma_t($tab_erg['BETRAG'][$eig_id]['BETEILIGUNG']);
                 $tab_arr[$a]['ZEILEN'][$b + 1]['BETRAG'] = $g_summe;
                 $tab_arr[$a]['ZEILEN'][$b + 1]['E_BETRAG'] = $g_bet;
                 $tab_arr[$a]['ZEILEN'][$b + 1]['U_BETRAG'] = $g_bet;
             }
         }
         $g_summe = nummer_punkt2komma_t($tab_erg['BETRAG']['G_SUMME']);
         $g_bet = nummer_punkt2komma_t($tab_erg['BETRAG'][$eig_id]['BETEILIGUNG']);
         echo "<tr><td></td><td></td><td></td><td>{$g_summe}</td><td>{$g_bet}</td></tr>";
         echo "</table>";
     }
     /* Gesamtbeteiligung als letzte Zeile hinzufügen */
     $g_summe = nummer_punkt2komma_t($tab_erg['BETRAG']['G_SUMME']);
     $g_bet = nummer_punkt2komma_t($tab_erg['BETRAG'][$eig_id]['BETEILIGUNG']);
     include_once 'classes/class_bpdf.php';
     $pdf = new Cezpdf('a4', 'portrait');
     $bpdf = new b_pdf();
     $bpdf->b_header($pdf, 'Partner', $_SESSION['partner_id'], 'portrait', 'Helvetica.afm', 6);
     $pdf->ezStopPageNumbers();
     // seitennummerirung beenden
     $p = new partners();
     $p->get_partner_info($_SESSION['partner_id']);
     $datum = date("d.m.Y");
     $anz = count($tab_arr);
     for ($a = 0; $a < $anz; $a++) {
         /* Bei jedem Eigentümer, mit neuer Seite anfangen */
         if ($a > 0) {
             $pdf->ezNewPage();
             $pdf->setColor(0, 0, 0);
             $pdf->ezSetDy(-5);
         }
         $eig_id = $tab_arr[$a]['EIG_ID'];
         $this->n_tage = $tab_arr[$a]['TAGE'];
         /* Kopf Anfang */
         $einheit_id = $tab_arr[$a]['EINHEIT_ID'];
         $this->einheit_id = $einheit_id;
         $e = new einheit();
         $e->get_einheit_info($einheit_id);
         $oo = new objekt();
         $anz_einheiten = $oo->anzahl_einheiten_objekt($e->objekt_id);
         $pdf->setColor(0, 0, 0);
         $pdf->setStrokeColor(0, 0, 0);
         $pdf->setLineStyle(0.5);
         $pdf->rectangle(400, 601, 165, 87);
         $this->get_eigentumer_id_infos2($eig_id);
         $this->get_anrede_eigentuemer($eig_id);
         $standard_anschrift = str_replace('<br />', "\n", $this->postanschrift[0]);
         if (!empty($standard_anschrift)) {
             $pdf->ezText("{$standard_anschrift}", 10);
         } else {
             $pdf->ezText("{$this->eig_namen_u_pdf}", 10);
             $pdf->ezSetDy(10);
             $pdf->ezText("{$this->haus_strasse} {$this->haus_nummer}", 10);
             $pdf->ezSetDy(-10);
             $pdf->ezText("{$this->haus_plz} {$this->haus_stadt}", 10);
         }
         $d = new detail();
         $anteile_g = $d->finde_detail_inhalt('OBJEKT', $e->objekt_id, 'Gesamtanteile');
         $pdf->addText(405, 680, 8, "Einheiten:");
         $pdf->addText(465, 680, 8, "{$anz_einheiten}");
         $pdf->addText(405, 670, 8, "Einheit:");
         $pdf->addText(465, 670, 8, "{$e->einheit_kurzname}");
         $pdf->addText(405, 660, 8, "Gesamtanteile:");
         $pdf->addText(465, 660, 8, "{$anteile_g}");
         $this->einheit_anteile = $d->finde_detail_inhalt('EINHEIT', $einheit_id, 'WEG-Anteile');
         $pdf->addText(405, 650, 8, "Ihre MAE:");
         $pdf->addText(465, 650, 8, "{$this->einheit_anteile}");
         $e->einheit_qm_a = nummer_punkt2komma($e->einheit_qm);
         $pdf->addText(405, 640, 8, "Fläche:");
         $pdf->addText(465, 640, 8, "{$e->einheit_qm_a} m²");
         $pdf->addText(405, 630, 8, "Aufzug %:");
         $pdf->addText(465, 630, 8, "{$e->aufzug_prozent_d}");
         $this->eigentuemer_von_d = date_mysql2german($this->eigentuemer_von);
         $this->eigentuemer_bis_d = date_mysql2german($this->eigentuemer_bis);
         if ($this->eigentuemer_bis_d == '00.00.0000') {
             $this->eigentuemer_bis_d = "31.12.{$jahr}";
         }
         $e_jahr_arr = explode(".", $this->eigentuemer_bis_d);
         $e_jahr = $e_jahr_arr[2];
         if ($e_jahr > $jahr) {
             $this->eigentuemer_bis_d = "31.12.{$jahr}";
         }
         $e_ajahr_arr = explode(".", $this->eigentuemer_von_d);
         $e_ajahr = $e_ajahr_arr[2];
         if ($e_ajahr < $jahr) {
             $this->eigentuemer_von_d = "01.01.{$jahr}";
         }
         $pdf->addText(405, 618, 7, "Zeitraum:");
         if ($this->p_von && $this->p_bis) {
             $pdf->addText(465, 618, 7, "{$this->p_von_d} - {$this->p_bis_d}");
         } else {
             $pdf->addText(465, 618, 7, "01.01.{$jahr} - 31.12.{$jahr}");
         }
         $pdf->addText(405, 611, 7, "Nutzungszeitraum: ");
         $pdf->addText(465, 611, 7, "{$this->eigentuemer_von_d} - {$this->eigentuemer_bis_d}");
         $pdf->addText(405, 604, 7, "Tage:");
         $pdf->addText(465, 604, 7, "{$this->n_tage} von {$tj}");
         // $pdf->addText(465,590,7,"$p->partner_ort, $datum");
         $pdf->ezSetY(590);
         $pdf->ezText("{$p->partner_ort}, {$datum}", 10, array('justification' => 'right'));
         $pdf->ezSetY(590);
         $pdf->ezText("{$this->pdf_anrede}", 10);
         $pdf->ezText("beiliegend übersenden wir Ihnen die Hausgeld-Einzelabrechnung zur Jahresabrechnung {$jahr}.", 10);
         $zeilen = array_orderby($tab_arr[$a]['ZEILEN'], 'GRUPPE', SORT_DESC, 'KONTO', SORT_ASC);
         $cols = array('KOS_BEZ' => "KOS", 'KONTO' => "Konto", 'BEZ' => "Kontobezeichnung", 'GRUPPE' => "Kontoart", 'KOS_BEZ' => "Aufteilung", 'BETRAG' => "Gesamt € ", 'G_KEY_A' => "Gesamt", 'E_KEY_A' => "Ihr Anteil", 'E_BETRAG' => "Ihre Beteiligung € ", 'U_BETRAG' => "");
         $pdf->ezTable($zeilen, $cols, "<b>Einnahmen/Ausgaben (*  Kostenkonto beinhaltet haushaltsnahe Dienstleistungen)</b>", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('KONTO' => array('justification' => 'left', 'width' => 32), 'GRUPPE' => array('justification' => 'left', 'width' => 80), 'BETRAG' => array('justification' => 'right', 'width' => 45), 'KOS_BEZ' => array('justification' => 'left', 'width' => 65), 'G_KEY_A' => array('justification' => 'right', 'width' => 65), 'E_KEY_A' => array('justification' => 'right', 'width' => 55), 'E_BETRAG' => array('justification' => 'right', 'width' => 50))));
         // $pdf->ezText("<b> *) Kostenkonto beinhaltet haushaltsnahe Dienstleistungen</b>", 7);
         $g = new geldkonto_info();
         $g->geld_konto_details($this->p_gk_id);
         $this->get_eigentumer_id_infos2($eig_id);
         if (str_replace('-', '', $this->eigentuemer_von) < "{$jahr}" . '0101') {
             $this->eigentuemer_von_t = "{$jahr}-01-01";
         } else {
             $this->eigentuemer_von_t = $this->eigentuemer_von;
         }
         if (str_replace('-', '', $this->eigentuemer_bis) > "{$jahr}" . '1231') {
             $this->eigentuemer_bis_t = "{$jahr}-12-31";
         } else {
             $this->eigentuemer_bis_t = $this->eigentuemer_bis;
         }
         if ($this->eigentuemer_bis == '0000-00-00') {
             $this->eigentuemer_bis_t = "{$jahr}-12-31";
         }
         $g = new geldkonto_info();
         $g->geld_konto_details($this->p_gk_id);
         $geldkonto_id = $this->p_gk_id;
         /* Hier noch 6020 als CONST, in VAR ändern */
         $hg_kosten_soll = $this->hg_tab_soll_ist_einnahmen($this->hg_konto, 'Einheit', $this->einheit_id, $this->eigentuemer_von_t, $this->eigentuemer_bis_t);
         $this->eigentuemer_von_t_a = date_mysql2german($this->eigentuemer_von_t);
         $this->eigentuemer_bis_t_a = date_mysql2german($this->eigentuemer_bis_t);
         $hg_tab[0]['ART'] = "Einnahmen aus Hausgeld für Kosten";
         $hg_tab[0]['ZEITRAUM'] = "{$this->eigentuemer_von_t_a} bis {$this->eigentuemer_bis_t_a}";
         $hg_tab[0]['SOLL'] = '-' . nummer_punkt2komma_t($hg_kosten_soll);
         $hg_ist_summe = $this->get_summe_zahlungen_arr_jahr('Eigentuemer', $eig_id, $jahr, $geldkonto_id, $this->hg_konto);
         if (!$hg_ist_summe) {
             $hg_ist_summe = $this->get_summe_zahlungen_hga('Eigentuemer', $eig_id, $p_id, $this->hg_konto);
         }
         $hg_tab[0]['IST'] = nummer_punkt2komma_t($hg_ist_summe);
         $hg_tab[0]['ERG'] = nummer_punkt2komma_t($hg_ist_summe);
         $hg_kosten_saldo = $hg_ist_summe - $hg_kosten_soll;
         $tab_hg_zahl_kosten[0]['TEXT'] = 'Hausgeldzahlung Anteil für Kosten';
         $tab_hg_zahl_kosten[0]['SUM'] = nummer_punkt2komma($hg_ist_summe);
         $l_z = count($tab_arr2) - 1;
         $hg_kosten_ant = nummer_komma2punkt(strip_tags($tab_arr2[$l_z]['BETRAG_ANT']));
         $hg_kosten_ant = $tab_erg['BETRAG'][$eig_id]['BETEILIGUNG'];
         $hg_kosten_saldo_ist_soll = $hg_ist_summe + $hg_kosten_ant;
         $hg_tab[1]['ART'] = '<b>Zwischenergebnis (ohne Instandhaltungsrücklage und Energieabrechnung)</b>';
         $hg_tab[1]['ERG'] = '<b>' . nummer_punkt2komma($hg_kosten_saldo_ist_soll) . '</b>';
         /* Zwischenergebnis 1 */
         $zw1 = $hg_kosten_saldo_ist_soll;
         /* Heizkostentabelle */
         $hk_kosten_soll = $this->hg_tab_soll_ist_einnahmen($this->hk_konto, 'Einheit', $this->einheit_id, $this->eigentuemer_von_t, $this->eigentuemer_bis_t);
         $hk_tab[0]['ART'] = "Einnahmen aus Hausgeld für Energiekosten";
         $hk_tab[0]['ZEITRAUM'] = "{$this->eigentuemer_von_t_a} bis {$this->eigentuemer_bis_t_a}";
         $hk_tab[0]['SOLL'] = '-' . nummer_punkt2komma($hk_kosten_soll);
         $hk_ist_summe = $this->get_summe_zahlungen_hga('Eigentuemer', $eig_id, $p_id, '6010');
         if (!$hk_ist_summe) {
             $hk_ist_summe = $this->get_summe_zahlungen_arr_jahr('Eigentuemer', $eig_id, $jahr, $geldkonto_id, '6010');
         }
         $tab_hg_zahl_kosten[1]['TEXT'] = 'Hausgeldzahlung Anteil für Energie';
         $tab_hg_zahl_kosten[1]['SUM'] = nummer_punkt2komma($hk_ist_summe);
         $hk_tab[0]['IST'] = nummer_punkt2komma($hk_ist_summe);
         $hk_tab[0]['ERG'] = nummer_punkt2komma($hk_ist_summe);
         $hk_diff_ist_soll = $hk_ist_summe - $hk_kosten_soll + $hg_kosten_saldo_ist_soll;
         $hk_verbrauch_ist = $this->get_summe_hk('Eigentuemer', $eig_id, $p_id);
         $hk_tab[1]['ART'] = 'Energieabrechnungsergebnis';
         $hk_tab[1]['IST'] = nummer_punkt2komma($hk_verbrauch_ist);
         $hk_tab[1]['ERG'] = nummer_punkt2komma($hk_verbrauch_ist);
         $zw2 = $hk_verbrauch_ist + $zw1 + $hk_ist_summe;
         $hk_tab[2]['ART'] = "<b>Zwischenergebnis nach Abzug Energieabrechnung</b>";
         $hk_tab[2]['ERG'] = '<b>' . nummer_punkt2komma($zw2) . '</b>';
         $hk_tab[0]['IST'] = $hk_tab[0][IST];
         /* Instandhaltungstabelle */
         $inst_kosten_soll = $this->hg_tab_soll_ist_einnahmen($this->ihr_konto, 'Einheit', $this->einheit_id, $this->eigentuemer_von_t, $this->eigentuemer_bis_t);
         $inst_tab[0]['ART'] = "Einnahmen aus Hausgeld für Instandhaltungsrücklage";
         $inst_tab[0]['ZEITRAUM'] = "{$this->eigentuemer_von_t_a} bis {$this->eigentuemer_bis_t_a}";
         $inst_tab[0]['SOLL'] = '-' . nummer_punkt2komma($inst_kosten_soll);
         $inst_ist_summe = $this->get_summe_zahlungen_arr_jahr('Eigentuemer', $eig_id, $jahr, $geldkonto_id, $this->ihr_konto);
         if (!$inst_ist_summe) {
             $inst_ist_summe = $this->get_summe_zahlungen_hga('Eigentuemer', $eig_id, $p_id, $this->ihr_konto);
         }
         $inst_tab[0]['IST'] = nummer_punkt2komma($inst_ist_summe);
         $inst_diff = $inst_ist_summe - $inst_kosten_soll;
         $tab_hg_zahl_kosten[2]['TEXT'] = 'Hausgeldzahlung Anteil für die IHR';
         $tab_hg_zahl_kosten[2]['SUM'] = nummer_punkt2komma($inst_ist_summe);
         $sum_hausgeld = nummer_komma2punkt($tab_hg_zahl_kosten[0]['SUM']) + nummer_komma2punkt($tab_hg_zahl_kosten[1]['SUM']) + nummer_komma2punkt($tab_hg_zahl_kosten[2]['SUM']);
         $tab_hg_zahl_kosten[3]['TEXT'] = "<b>Ihre Hausgeldzahlungen gesamt</b>";
         $tab_hg_zahl_kosten[3]['SUM'] = "<b>" . nummer_punkt2komma($sum_hausgeld) . "</b>";
         $tab_hg_zahl_kosten[4]['TEXT'] = '';
         $tab_hg_zahl_kosten[4]['SUM'] = '';
         $tab_hg_zahl_kosten[5]['TEXT'] = 'Ihr Kostenanteil';
         $tab_hg_zahl_kosten[5]['SUM'] = nummer_punkt2komma($hg_kosten_ant);
         $tab_hg_zahl_kosten[6]['TEXT'] = 'Ihr Energieverbrauch';
         $tab_hg_zahl_kosten[6]['SUM'] = nummer_punkt2komma($hk_verbrauch_ist);
         $tab_hg_zahl_kosten[7]['TEXT'] = 'Ihr Anteil in der IHR';
         $tab_hg_zahl_kosten[7]['SUM'] = nummer_punkt2komma($inst_kosten_soll * -1);
         $bet_ges = nummer_komma2punkt($tab_hg_zahl_kosten[5]['SUM']) + nummer_komma2punkt($tab_hg_zahl_kosten[6]['SUM']) + nummer_komma2punkt($tab_hg_zahl_kosten[7]['SUM']);
         $tab_hg_zahl_kosten[8]['TEXT'] = "<b>Ihre Beteiligung gesamt</b>";
         $tab_hg_zahl_kosten[8]['SUM'] = "<b>" . nummer_punkt2komma($bet_ges) . "</b>";
         $bet_erg = $sum_hausgeld + $bet_ges;
         if ($bet_erg > 0) {
             $nzgh = "Guthaben";
         } else {
             $nzgh = "Nachzahlung";
         }
         $tab_hg_zahl_kosten[9]['TEXT'] = "<b>Ergebnis {$nzgh} </b>";
         $tab_hg_zahl_kosten[9]['SUM'] = "<b>" . nummer_punkt2komma($bet_erg) . "</b>";
         $inst_tab[1]['ART'] = '<b>Ergebnis Instandhaltungsrücklage</b>';
         $inst_tab[1]['ERG'] = '<b>' . nummer_punkt2komma($inst_diff) . '</b>';
         $zw3 = $zw2 + $inst_diff;
         if ($zw3 < 0) {
             $zw_text = 'Nachzahlung';
         }
         if ($zw3 > 0) {
             $zw_text = 'Guthaben';
         }
         $inst_tab[2]['ART'] = "<b><i>Gesamtergebnis Hausgeld (inkl. Energieabrechnung und Instandhaltungsrücklagen)  =  {$zw_text}</i></b>";
         $inst_tab[2]['ERG'] = '<b>' . nummer_punkt2komma_t($zw3) . '</b>';
         $uebersicht[$a]['EINHEIT_ID'] = $einheit_id;
         $uebersicht[$a]['EINHEIT'] = $this->einheit_kurzname . "  " . ltrim(rtrim($this->eigentuemer_name_str));
         $uebersicht[$a]['ERGEBNIS'] = nummer_punkt2komma_t($zw3);
         $uebersicht[$a]['ZAHLUNGEN_J'] = nummer_punkt2komma($sum_hausgeld);
         $uebersicht[$a]['KOSTEN_J'] = nummer_punkt2komma($bet_ges);
         $zzz++;
         $pdf->ezSetDy(-5);
         /* Zweite Seite */
         $pdf->ezNewPage();
         $cols_1 = array('ART' => "Hausgeldeinnahmen für Kosten", 'SOLL' => "Soll", 'IST' => "Ist ", 'ERG' => "");
         $pdf->ezTable($hg_tab, $cols_1, '<b>Hausgeldeinnahmen ohne Instandhaltungsrücklage und Heizkostenvorschüsse</b>', array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('ART' => array('justification' => 'left'), 'SOLL' => array('justification' => 'right', 'width' => 45), 'IST' => array('justification' => 'right', 'width' => 50), 'ERG' => array('justification' => 'right', 'width' => 40))));
         $pdf->ezSetDy(-10);
         $cols_3 = array('ART' => "Energieabrechnung (siehe Abrechnung)", 'SOLL' => "Soll", 'IST' => "Ist ", 'ERG' => "");
         $pdf->ezTable($hk_tab, $cols_3, '<b>Energieabrechnung (Heizung/Kalt- Warmwasser)</b>', array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('ART' => array('justification' => 'left'), 'SOLL' => array('justification' => 'right', 'width' => 45), 'IST' => array('justification' => 'right', 'width' => 50), 'ERG' => array('justification' => 'right', 'width' => 40))));
         $pdf->ezSetDy(-10);
         $cols_2 = array('ART' => "Instandhaltungsrücklage", 'SOLL' => "Soll", 'IST' => "Ist ", 'ERG' => "");
         $pdf->ezTable($inst_tab, $cols_2, '<b>Instandhaltungsrücklage</b>', array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('ART' => array('justification' => 'left'), 'SOLL' => array('justification' => 'right', 'width' => 45), 'IST' => array('justification' => 'right', 'width' => 50), 'ERG' => array('justification' => 'right', 'width' => 40))));
         $pdf->ezSetDy(-10);
         $cols_hg = array('TEXT' => "BEZEICHNUNG", 'SUM' => "WERT [€]");
         $pdf->ezTable($tab_hg_zahl_kosten, $cols_hg, '<b>Übersicht Ihrer Zahlungen und Kosten</b>', array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('TEXT' => array('justification' => 'left'), 'SUM' => array('justification' => 'right', 'width' => 80))));
         /* Zweite Seite */
         // $pdf->ezNewPage();
         $pdf->ezSetDy(-30);
         $pdf->ezText("Sollte Ihre Abrechnung ein Guthaben ausweisen, dann werden wir nach Genehmigung der Jahresabrechnung auf der diesjährigen Eigentümerversammlung den Guthabenbetrag auf Ihr Konto überweisen, soweit es nicht zum Ausgleich von Rückständen benötigt wird.", 10, array('justification' => 'full'));
         $pdf->ezSetDy(-10);
         $pdf->ezText("Bei einer Nachzahlung überweisen Sie bitte den Nachzahlungsbetrag nach Genehmingung der Jahresabrechnung auf der diesjährigen Eigentümerversammlung auf das Hasusgeldkonto. Als Verwendungszweck geben Sie bitte <b>Hausgeldabrechnung {$jahr}  {$e->einheit_kurzname}</b> ein.", 10, array('justification' => 'full'));
         $pdf->ezSetDy(-10);
         $pdf->ezText("Wir behalten uns eine Berichtigung dieser Abrechnung vor, falls nachträglich Rechnungen Dritter für den Abrechnungszeitraum eingehen, die bei der Abrechnung hätten berücksichtigt werden müssen, Fehler anerkannt werden, welche zunächst nicht ohne weiteres erkennbar waren (z. B. Fehler von Messdiensten) oder der Abrechnungsfehler zu einem schlechthin unzumutbaren Nachteil für einen Vertragspartei führt.", 10, array('justification' => 'full'));
         $pdf->ezSetDy(-25);
         $cols_bu = array('DATUMD' => "Datum", 'KONTENRAHMEN_KONTO' => "Konto", 'BETRAG' => "Betrag [€]", 'VERWENDUNGSZWECK' => "Buchungstext");
         $bu_arr_et = $this->get_buchungen_et_HG($geldkonto_id, $eig_id, $jahr);
         if (is_array($bu_arr_et)) {
             $pdf->ezNewPage();
             $pdf->ezTable($bu_arr_et, $cols_bu, "Buchungsübersicht {$jahr} {$e->einheit_kurzname}", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 530, 'cols' => array('KONTENRAHMEN_KONTO' => array('justification' => 'left', 'width' => 40), 'BETRAG' => array('justification' => 'right'))));
         }
         if (is_array($hndl_arr)) {
             $pdf->ezNewPage();
             $pdf->ezSetDy(-10);
             $this->get_eigentumer_id_infos2($eig_id);
             $standard_anschrift = str_replace('<br />', "\n", $this->postanschrift[0]);
             if (!empty($standard_anschrift)) {
                 $pdf->ezText("{$standard_anschrift}", 10);
             } else {
                 $pdf->ezText("{$this->eig_namen_u_pdf}", 10);
                 $pdf->ezSetDy(10);
                 $pdf->ezText("{$this->haus_strasse} {$this->haus_nummer}", 10);
                 $pdf->ezSetDy(-10);
                 $pdf->ezText("{$this->haus_plz} {$this->haus_stadt}", 10);
             }
             $pdf->ezSetDy(-30);
             $pdf->setColor(0.6, 0.6, 0.6);
             $pdf->filledRectangle(50, 600, 500, 15);
             $pdf->setColor(0, 0, 0);
             $pdf->ezSetY(650);
             $pdf->ezText("{$p->partner_ort}, {$datum}", 10, array('justification' => 'right'));
             $pdf->ezSetY(650);
             $pdf->ezSety(615);
             $pdf->ezText("<b>Nachweis der haushaltsnahen Dienstleistungen im Sinne §35a EStG. für das Jahr {$jahr}</b>", 10);
             $pdf->ezSetDy(-20);
             $zeilen = $hndl_arr[$eig_id]['ZEILEN'];
             $anz_zeilen = count($zeilen);
             $hndl_arr[$eig_id]['ZEILEN'][$anz_zeilen][E_BETRAG_HNDL] = '<b>' . nummer_punkt2komma_t($tab_erg[BETRAG_HNDL][$eig_id]['BETEILIGUNG']) . '</b>';
             $zeilen = $hndl_arr[$eig_id]['ZEILEN'];
             $cols = array('KONTO' => "Konto", 'BEZ' => "Kontobezeichnung", 'GRUPPE' => "Kontoart", 'KOS_BEZ' => "Aufteilung", 'BETRAG_HNDL' => "HNDL Gesamt € ", 'G_KEY_A' => "Gesamt", 'E_KEY_A' => "Ihr Anteil", 'E_BETRAG_HNDL' => "Ihre Beteiligung € ");
             $pdf->ezTable($zeilen, $cols, "<b>Haushaltsnahe- und Handwerkerdienstleistungen </b>", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 7, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('KONTO' => array('justification' => 'left', 'width' => 35), 'GRUPPE' => array('justification' => 'left', 'width' => 80), 'BETRAG_HNDL' => array('justification' => 'right', 'width' => 45), 'KOS_BEZ' => array('justification' => 'left', 'width' => 60), 'G_KEY_A' => array('justification' => 'right', 'width' => 45), 'E_KEY_A' => array('justification' => 'right', 'width' => 45), 'E_BETRAG_HNDL' => array('justification' => 'right', 'width' => 50))));
             $pdf->ezText("<b>*) Kostenkonto beinhaltet haushaltsnahe Dienstleistungen</b>", 7);
             $summe_hndl_pdf = nummer_punkt2komma_t(abs($tab_erg[BETRAG_HNDL][$eig_id]['BETEILIGUNG']));
             $pdf->ezSetDy(-20);
             $pdf->ezText("<b>Ihr steuerbegünstigter Kostenanteil beträgt {$summe_hndl_pdf} €</b>", 8);
             $pdf->ezSetDy(-20);
             $pdf->ezText("In den oben aufgeführten Kostenarten sind nur Lohnkosten und eventuelle An-/Abfahrtskosten enthalten.", 8);
             $pdf->ezText("Die Verteilung \"Ihr Anteil\" an den Gesamtkosten wird aus den jeweils aufgeführten Verteilerfaktoren der Hausgeld-Einzelabrechnung ermittelt.", 8);
             $pdf->ezSetDy(-10);
             $pdf->ezText("Die Originalbelege (Rechnungen) liegen bei der Hausverwaltung zur Einsicht vor.", 8);
             $pdf->ezSetDy(-10);
             $pdf->ezText("Bei steuerlichen Fragen, wenden Sie sich bitte an Ihren Steuerberater.", 8);
             $pdf->ezSetDy(-10);
             $pdf->ezText("Diese Angaben sind im Rahmen ordnungsgemäßer Verwaltung und nach bestem Wissen ermittelt worden. Für tatsächliche Gewährung einer Steuerbegünstigung durch das zuständige Finanzamt wird indes keine Haftung übernommen.", 8);
             $pdf->ezSetDy(-10);
             $pdf->ezText("Dieses Schreiben wurde maschinell erstellt und ist daher ohne Unterschrift gültig.\n", 8);
             $pdf->ezSetDy(-10);
             $bpdf->zahlungshinweis = strip_tags($bpdf->zahlungshinweis);
             // $pdf->ezText("$bpdf->zahlungshinweis",8);
         }
         $tab_zahl_rueck[$a]['EINHEIT'] = $this->einheit_kurzname;
         $tab_zahl_rueck[$a]['NAME'] = substr($this->eigentuemer_name_str, 0, -2);
         $tab_zahl_rueck[$a]['VORJAHRE'] = '';
         $tab_zahl_rueck[$a]['SOLL_IHR'] = nummer_punkt2komma($inst_kosten_soll);
         $tab_zahl_rueck[$a]['IST_IHR'] = nummer_punkt2komma($inst_ist_summe);
         $tab_zahl_rueck[$a]['SALDO'] = nummer_punkt2komma($inst_diff + $vorjahre);
     }
     // end for $a
     $anz_u = count($uebersicht);
     $summe_alle = 0;
     $summe_nachzahlung = 0;
     $summe_guthaben = 0;
     $summe_kosten = 0;
     $summe_zahlungen = 0;
     $summe_einheit = 0;
     $einheit_temp = '';
     $sum_pro_einheit = 0;
     for ($a = 0; $a < $anz_u; $a++) {
         $einheit_id_n = $uebersicht[$a]['EINHEIT_ID'];
         $betrag = nummer_komma2punkt($uebersicht[$a]['ERGEBNIS']);
         $kosten_j = nummer_komma2punkt($uebersicht[$a]['KOSTEN_J']);
         $zahlungen_j = nummer_komma2punkt($uebersicht[$a]['ZAHLUNGEN_J']);
         if ($a == 0) {
             $einheit_temp = $einheit_id_n;
             $summe_einheit += $betrag;
         }
         if ($a > 0) {
             if ($einheit_temp == $einheit_id_n) {
                 $summe_einheit += $betrag;
             } else {
                 $uebersicht[$a - 1]['ERGEBNIS_E'] = nummer_punkt2komma_t($summe_einheit);
                 $sum_pro_einheit += $summe_einheit;
                 $summe_einheit = 0;
                 $einheit_temp = $einheit_id_n;
                 $summe_einheit += $betrag;
                 /* Letzte Zeile/Einheit */
                 if ($a == $anz_u - 1) {
                     $uebersicht[$a]['ERGEBNIS_E'] = nummer_punkt2komma_t($summe_einheit);
                     $sum_pro_einheit += $summe_einheit;
                 }
             }
         }
         $betrag = nummer_komma2punkt($uebersicht[$a]['ERGEBNIS']);
         $kosten_j = nummer_komma2punkt($uebersicht[$a]['KOSTEN_J']);
         $zahlungen_j = nummer_komma2punkt($uebersicht[$a]['ZAHLUNGEN_J']);
         $summe_kosten += $kosten_j;
         $summe_zahlungen += $zahlungen_j;
         if ($betrag < '0.00') {
             $summe_nachzahlung += $betrag;
         } else {
             $summe_guthaben += $betrag;
         }
         $summe_alle += $betrag;
     }
     $pdf->ezNewPage();
     $pdf->ezSetDy(-20);
     $uebersicht[$anz_u + 1]['EINHEIT'] = '<b>SUMME NACHZAHLUNGEN (EINNAHMEN)</b>';
     $uebersicht[$anz_u + 1]['ERGEBNIS'] = '<b>' . nummer_punkt2komma_t($summe_nachzahlung) . '</b>';
     $uebersicht[$anz_u]['EINHEIT'] = '<b>SUMME GUTHABEN (AUSZAHLUNGEN)</b>';
     $uebersicht[$anz_u]['ERGEBNIS'] = '<b>' . nummer_punkt2komma_t($summe_guthaben) . '</b>';
     if ($summe_alle > '0.00') {
         $uebersicht[$anz_u + 2]['EINHEIT'] = '<b>GESAMT GUTHABEN</b>';
     } else {
         $uebersicht[$anz_u + 2]['EINHEIT'] = '<b>GESAMT NACHZAHLUNG</b>';
     }
     $uebersicht[$anz_u + 2]['ZAHLUNGEN_J'] = "<b>" . nummer_punkt2komma_t($summe_zahlungen) . "</b>";
     $uebersicht[$anz_u + 2]['KOSTEN_J'] = "<b>" . nummer_punkt2komma_t($summe_kosten) . "</b>";
     $uebersicht[$anz_u + 2]['ERGEBNIS'] = '<b>' . nummer_punkt2komma_t($summe_alle) . '</b>';
     $uebersicht[$anz_u + 2]['ERGEBNIS_E'] = '<b>' . nummer_punkt2komma_t($sum_pro_einheit) . '</b>';
     $cols = array('EINHEIT' => "EINHEIT / EIGENTÜMER", 'ZAHLUNGEN_J' => "HAUSGELD", 'KOSTEN_J' => "KOSTEN", 'ERGEBNIS' => "ERGEBNISE", 'ERGEBNIS_E' => "PRO EINHEIT");
     $pdf->ezTable($uebersicht, $cols, "<b>Abrechnungsergebnis {$this->p_jahr}</b>", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 9, 'fontSize' => 9, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('ERGEBNIS' => array('justification' => 'right', 'width' => 65), 'ERGEBNIS_E' => array('justification' => 'right', 'width' => 60), 'KOSTEN_J' => array('justification' => 'right', 'width' => 60), 'ZAHLUNGEN_J' => array('justification' => 'right', 'width' => 60))));
     // $pdf->ezTable($tab_erg[BETRAG_HNDL]);
     ob_clean();
     // ausgabepuffer leeren
     $pdf->ezStream();
     die;
 }