<?php


//if (isset($isSettlement) && ($isSettlement == true)) {
//
//    $strByTrans = "";
//    $strByMenu = "";
//    $strByPym = "";
//    $strByBahan = "";
//
//    if (isset($headerByTransaksi) && sizeof($headerByTransaksi) > 0) {
//        if (isset($settlementByTransaksi) && sizeof($settlementByTransaksi) > 0) {
//            $itemTrans = (isset($settlementByTransaksiProduk) && sizeof($settlementByTransaksiProduk) > 0) ? $settlementByTransaksiProduk : array();
//
//            // $strByTrans .= "<h3>$labelByTransaksi</h3>";
//            // $strByTrans .= "<style type='text/css'>
//            // .form-control{
//            //     height: 1px !important;
//            //     padding: 3px 2px !important;
//            // }
//            // </style>";
//
//            $total = 0;
//            foreach ($settlementByTransaksi as $trNomor => $spec) {
//                $total += $spec['validGrandTotal'];
//
//                $strByTrans .= "<div class='table-responsive no-padding no-border dataTable compact'>";
//
//                if (isset($headerMainByTransaksi) && sizeof($headerMainByTransaksi) > 0) {
//                    foreach ($headerMainByTransaksi as $key => $val) {
//                        $mhVal = isset($spec[$key]) ? $spec[$key] : "";
//                        if ($val == NULL) {
//                            $strByTrans .= formatField_he_format($key, $mhVal);
//                        }
//                        else {
//                            $strByTrans .= "$val : " . formatField_he_format($key, $mhVal);
//                        }
//                        $strByTrans .= "<br>";
//                    }
//                }
//
//                //region header per-transaksi
//                $strByTrans .= "<table class='table table-condensed no-padding table-bordered no-margin'>";
//                $strByTrans .= "<tr class='bg-grey-2 text-uppercase'>";
//                $strByTrans .= "<th style='width:0.5%;' class='text-center'>";
//                $strByTrans .= "No.";
//                $strByTrans .= "</th>";
//                foreach ($headerByTransaksi as $key => $val) {
//                    $strByTrans .= "<th class='text-muted text-center'>";
//                    $strByTrans .= $val;
//                    $strByTrans .= "</th>";
//                }
//                $strByTrans .= "</tr>";
//
//                if (isset($itemTrans[$trNomor]) && sizeof($itemTrans[$trNomor]) > 0) {
//                    $no_itr = 0;
//                    foreach ($itemTrans[$trNomor] as $iSpec) {
//                        $no_itr++;
//
//                        $strByTrans .= "<tr>";
//                        $strByTrans .= "<td style='text-align: right;'>$no_itr</td>";
//
//                        foreach ($headerByTransaksi as $key => $val) {
//                            $colVal = isset($iSpec[$key]) ? formatField_he_format($key, $iSpec[$key]) : "";
//                            $strByTrans .= "<td>$colVal</td>";
//                        }
//                        $strByTrans .= "</tr>";
//                    }
//                }
//
//                if (isset($summaryByTransaksi) && sizeof($summaryByTransaksi) > 0) {
//                    foreach ($summaryByTransaksi as $key => $val) {
//                        $colspan = sizeof($headerByTransaksi);
//                        $sumVal = isset($spec[$key]) ? $spec[$key] : "0";
//
//                        $strByTrans .= "<tr>";
//                        $strByTrans .= "<td style='text-align: right;' colspan='$colspan'>$val</td>";
//                        $strByTrans .= "<td>" . formatField_he_format($key, $sumVal) . "</td>";
//                        $strByTrans .= "</tr>";
//                    }
//                }
//
//                $strByTrans .= "</table>";
//                //endregion
//
//
//                $strByTrans .= "</div>";
//                $strByTrans .= "<br>";
//
//            }
//
//            $strByTrans .= "<div style='color:#000000;font-size:18px;' class='alert alert-warning'>";
//            $strByTrans .= "<div><span sstyle='color:#000000;font-size:18px;'>TOTAL BILL: </span><span class='pull-right'>" . formatField_he_format("debet", sizeof($settlementByTransaksi)) . "</span></div>";
//            $strByTrans .= "<div><span sstyle='color:#000000;font-size:18px;'>TOTAL BY NOTA/BILL: </span><span class='pull-right'>" . formatField_he_format("debet", $total) . "</span></div>";
//            $strByTrans .= "</div>";
//            $strByTrans .= "<br><br>";
//
//        }
//    }
//    if (isset($settlementByMenu) && sizeof($settlementByMenu) > 0) {
//        if (isset($headerByMenu) && sizeof($headerByMenu) > 0) {
//            $strByMenu .= "<div class='table-responsive no-padding no-border'>";
//            $strByMenu .= "<h3>$labelByMenu</h3>";
//            $strByMenu .= "<table class='table table-condensed no-padding table-bordered no-margin'>";
//            $strByMenu .= "<tr class='bg-grey-2 text-uppercase'>";
//            $strByMenu .= "<th style='width:0.5%;' class='text-center'>";
//            $strByMenu .= "No.";
//            $strByMenu .= "</th>";
//            foreach ($headerByMenu as $key => $val) {
//                $strByMenu .= "<th class='text-muted text-center'>";
//                $strByMenu .= $val;
//                $strByMenu .= "</th>";
//            }
//        }
//        $strByMenu .= "<tr class='bg-grey-2 text-uppercase'>";
//
//        $no_menu = 0;
//        $total_menu = array();
//        foreach ($settlementByMenu as $mSpec) {
//            $no_menu++;
//            $strByMenu .= "<tr>";
//            $strByMenu .= "<td style='text-align: right;'>$no_menu</td>";
//
//            foreach ($headerByMenu as $key => $val) {
//
//                $colVal = isset($mSpec[$key]) ? formatField_he_format($key, $mSpec[$key]) : "";
//                $strByMenu .= "<td>$colVal</td>";
//
//                if (isset($mSpec[$key]) && is_numeric($mSpec[$key])) {
//                    if (!isset($total_menu[$key])) {
//                        $total_menu[$key] = 0;
//                    }
//                    $total_menu[$key] += $mSpec[$key];
//                }
//            }
//            $strByMenu .= "</tr>";
//        }
//        $strByMenu .= "<tr>";
//        $strByMenu .= "<td style='text-align: right;' colspan='2'>TOTAL</td>";
//        foreach ($headerByMenu as $key => $val) {
//            if (isset($total_menu[$key])) {
//                $colVal = formatField_he_format($key, $total_menu[$key]);
//                $strByMenu .= "<td>$colVal</td>";
//            }
//        }
//        $strByMenu .= "</tr>";
//        $strByMenu .= "</table class='table table-condensed no-padding table-bordered no-margin'>";
//        $strByMenu .= "</div class='table-responsive no-padding no-border'>";
//        $strByMenu .= "<br>";
//    }
//    if (isset($settlementByPayment) && sizeof($settlementByPayment) > 0) {
//        if (isset($headerByPayment) && sizeof($headerByPayment) > 0) {
//            $strByPym .= "<div class='table-responsive no-padding no-border'>";
//            $strByPym .= "<h3>$labelByPayment</h3>";
//            $strByPym .= "<table class='table table-condensed no-padding table-bordered no-margin'>";
//            $strByPym .= "<tr class='bg-grey-2 text-uppercase'>";
//            $strByPym .= "<th style='width:0.5%;' class='text-center'>";
//            $strByPym .= "No.";
//            $strByPym .= "</th>";
//            foreach ($headerByPayment as $key => $val) {
//                $strByPym .= "<th class='text-muted text-center'>";
//                $strByPym .= $val;
//                $strByPym .= "</th>";
//            }
//        }
//        $strByPym .= "<tr class='bg-grey-2 text-uppercase'>";
//
//        $no_menu = 0;
//        $total_menu = array();
//        foreach ($settlementByPayment as $mSpec) {
//            $no_menu++;
//            $strByPym .= "<tr>";
//            $strByPym .= "<td style='text-align: right;'>$no_menu</td>";
//
//            foreach ($headerByPayment as $key => $val) {
//
//                $colVal = isset($mSpec[$key]) ? formatField_he_format($key, $mSpec[$key]) : "";
//                $strByPym .= "<td>$colVal</td>";
//
//                if (isset($mSpec[$key]) && is_numeric($mSpec[$key])) {
//                    if (!isset($total_menu[$key])) {
//                        $total_menu[$key] = 0;
//                    }
//                    $total_menu[$key] += $mSpec[$key];
//                }
//            }
//            $strByPym .= "</tr>";
//        }
//        $strByPym .= "<tr>";
//        $strByPym .= "<td style='text-align: right;' colspan='2'>TOTAL</td>";
//        foreach ($headerByPayment as $key => $val) {
//            if (isset($total_menu[$key])) {
//                $colVal = formatField_he_format($key, $total_menu[$key]);
//                $strByPym .= "<td>$colVal</td>";
//            }
//        }
//        $strByPym .= "</tr>";
//        $strByPym .= "</table class='table table-condensed no-padding table-bordered no-margin'>";
//        $strByPym .= "</div class='table-responsive no-padding no-border'>";
//        $strByPym .= "<br>";
//    }
//    if (isset($settlementByBahan) && sizeof($settlementByBahan) > 0) {
//        if (isset($headerByBahan) && sizeof($headerByBahan) > 0) {
//            $strByBahan .= "<div class='table-responsive no-padding no-border'>";
//            $strByBahan .= "<h3>$labelByBahan</h3>";
//            $strByBahan .= "<table class='table table-condensed no-padding table-bordered no-margin'>";
//            $strByBahan .= "<tr class='bg-grey-2 text-uppercase'>";
//            $strByBahan .= "<th style='width:0.5%;' class='text-center'>";
//            $strByBahan .= "No.";
//            $strByBahan .= "</th>";
//            foreach ($headerByBahan as $key => $val) {
//                $strByBahan .= "<th class='text-muted text-center'>";
//                $strByBahan .= $val;
//                $strByBahan .= "</th>";
//            }
//        }
//        $strByBahan .= "<tr class='bg-grey-2 text-uppercase'>";
//
//        $no_menu = 0;
//        $total_menu = array();
//        foreach ($settlementByBahan as $mSpec) {
//            $no_menu++;
//            $strByBahan .= "<tr>";
//            $strByBahan .= "<td style='text-align: right;'>$no_menu</td>";
//
//            foreach ($headerByBahan as $key => $val) {
//
//                $colVal = isset($mSpec[$key]) ? formatField_he_format($key, $mSpec[$key]) : "";
//                $strByBahan .= "<td>$colVal</td>";
//
//                if (isset($mSpec[$key]) && is_numeric($mSpec[$key])) {
//                    if (!isset($total_menu[$key])) {
//                        $total_menu[$key] = 0;
//                    }
//                    $total_menu[$key] += $mSpec[$key];
//                }
//            }
//            $strByBahan .= "</tr>";
//        }
//        $strByBahan .= "<tr>";
//        $strByBahan .= "<td style='text-align: right;' colspan='3'>TOTAL</td>";
//        foreach ($headerByBahan as $key => $val) {
//            if (isset($total_menu[$key])) {
//                $colVal = formatField_he_format($key, $total_menu[$key]);
//                $strByBahan .= "<td>$colVal</td>";
//            }
//        }
//        $strByBahan .= "</tr>";
//        $strByBahan .= "</table class='table table-condensed no-padding table-bordered no-margin'>";
//        $strByBahan .= "</div class='table-responsive no-padding no-border'>";
//    }
//
//    echo $strByTrans;
//    echo $strByMenu;
//    echo $strByPym;
//    echo $strByBahan;
//
//}
//else {

if (isset($items)) {
    if (isset($fixedNoteTop)) {
        echo "<div class='alert alert-danger' style='margin-top: 0px;font-size: 15px;'>";
        echo "<span>$fixedNoteTop</span>";
        echo "</div>";
    }
    $showItems = isset($showItems) && strlen($showItems) > 0 && $showItems == "false" ? false : "true";
    if (sizeof($items) > 0) {
        $jmlKolomHeader = sizeof($itemLabels) + 2;

        $jmlItems = count($items);
        $jmlQtys = 0;
        $grandTotalRp = isset($main['grand_total']) ? preg_replace("/\,?00+$/", "", number_format($main['grand_total'], 2, ',', '.')) : 0;

        foreach ($items as $k => $rItems) {
            $jmlQtys += $rItems['qty_unit'];
        }

        echo $info_member_style;
        /* ----------------------------------------------------------------------------------------------------------
         * style untuk info diskon di-shoping cart dan pembayaran SO
         * ----------------------------------------------------------------------------------------------------------*/
        echo "<style type='text/css'>
            .float-container {
            color: darkblue;
            }

            .float-child {
                float: left;
                padding: 3px;
            }
            .box-free {
                border-top: crimson 1px dashed;
                margin-top: 3px;
            }
            .box{
                margin-bottom: 10px;
            }
            .box-header{
                padding: 5px;
            }
            .box-body {
                padding: 5px 2px !important;
            }
            gb {
                color: green;
                font-weight: bolder;
            }
            .text-blur{
            filter: blur(3px);
            }
        </style>";
        echo "<div class='no-padding no-border'>";
        echo "<style>table.dataTable.compact tbody th, table.dataTable.compact tbody td { padding: 0px 0px; }</style>";
        echo "<style>table.dataTable.compact tbody td > input, table.dataTable.compact tbody td > span, table.dataTable.compact tbody td > select { border: 0px !important; }</style>";

        if ($cCode != "_TR_982") {
            echo "<div class='col col-md-12'>
                      <div class='col col-lg-6 col-md-6 col-xs-6 col-sm-6 text-bold text-black fa-2x text-left'>Jml.Items: $jmlItems ($jmlQtys)</div>
                      <div class='col col-lg-6 col-md-6 col-xs-6 col-sm-6 text-bold text-green fa-2x text-right'>Rp. <span id='summaryTotalRupiah' class=''>$grandTotalRp</span></div>
                  </div>";
        }
        else {
            echo "
                    <div class='col-md-12 col-lg-12 no-padding'>
                        <div style='margin-bottom: 15px;' class='label box-header bg-red text-bold'>
                            <h3>=== PEMBATALAN TRANSAKSI PENJUALAN ===</h3>
                            <h3 class='text-link text-bold'>$referenceNo</h3>
                        </div>
                    </div>
                ";
        }

        echo "<table class='table table-condensedx no-padding table-bordered no-margin dataTable compact'>";
        echo "<thead>";

        //region clear shoping cart
        if (!$avoidRemove && $cCode != "_TR_982") {
            echo "<tr class='bg-grey-2'>";
            echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";

            echo "<span class='pull-left'>";
            echo "<label><input type='checkbox' id='popup_qty' checked class=''> popUp Qty</label>";
            echo "</span>";

            echo "<span class='pull-left hidden-lg'>";
            echo "<button id='btn_clear_shopping_cart' type='button' class='text-red btn btn-xs' title='remove ALL ITEMS' data-toggles='tooltip' data-placement='right' onclick=\"confirm_alert_result('Attention !!!','Remove all items on shopping cart?','$resetLink','YES CLEAR');\"><i class='fa fa-trash'> </i> Clear Shoping Cart</button>";
            echo "</span>";
            echo "</td>";
            echo "</tr>";
        }
        //endregion

        //region clear shoping cart
        //            if ($selectAll) {
        //                echo "<tr class='bg-grey-2'>";
        //                echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";
        //                echo "<span class='pull-left'>";
        //                echo "<label>Select All <input type='checkbox' id='select_all' class='select2'></label> ";
        //                echo "</span>";
        //                echo "<div class='text-red text-bold text-center fa-2x'> SILAHKAN CENTANG PRODUK YANG AKAN DI BATALKAN </div>";
        //                echo "</td>";
        //                echo "</tr>";
        //            }
        //endregion

        /*===============header shoping cart======================*/
        if (isset($itemLabels)) {
            if (sizeof($itemLabels) && (is_array($itemLabels)) && $showItems) {
                echo "<tr class='bg-grey-2 text-uppercase'>";
                echo "<th style='width:5px;' class='text-center'>";
                echo "URUT";
                echo "</th>";
                foreach ($itemLabels as $key => $label) {
                    if ($key == "jml" || $key == "qty" || $key == "qty_unit") {
                        echo "<th style='max-width:5px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "barcode") {
                        echo "<th style='min-width:70px;max-width:80px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "nama") {
                        echo "<th style='min-width:400px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "satuan_factor_nama") {
                        echo "<th style='min-width:12px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    else {
                        echo "<th style='min-width:50px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                }
                if (!$avoidRemove) {
                    // echo "<th style='width:1%;' class='text-muted text-center'>";
                    // echo "x";
                    // echo "</th>";
                }
                echo "</tr>";
            }
        }

        echo "</thead>";

        /*===============body shoping cart=======================================*/
        $no = 0;

        echo "<tbody>";

        //select produk dari baris shoppingcart
        if ($cCode != "_TR_982") {
            if (isset($itemLabels)) {
                if (sizeof($itemLabels) && (is_array($itemLabels)) && $showItems) {
                    echo "<style>
                        input.ns:focus {
                          background-color: yellow;
                          border: 2px gray dashed;
                        }
                    </style>";
                    echo "<tr class='bg-grey-2 text-uppercase hidden-xs hidden-sm'>";

                    echo "<td style='width:5px;padding: 4px;' class='text-center'>";
                    echo "<i style='font-size: 27px; margin-top: 1px;' class='fa fa-check-circle text-green'></i>";
                    echo "</td>";

                    foreach ($itemLabels as $key => $label) {
                        if ($key == "jml" || $key == "qty" || $key == "qty_unit") {
                            echo "<td style='max-width:5px;white-spacex: nowrap;padding: 2px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewQty' autocomplete='off' autocomplete='disable' tabindex='1000' onclick='this.select()' class='form-control ns text-center text-bold' value='1'>";
                            echo "</td>";
                        }
                        else if ($key == "barcode") {
                            echo "<td style='min-width:70px;max-width:80px;white-space: nowrap;padding: 2px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewSKU' list='new_sku'  autocomplete='off' autocomplete='disable' tabindex='888' class='form-control ns'>";
                            echo "</td>";
                        }
                        else if ($key == "nama") {
                            echo "<td style='min-width:400px;white-space: nowrap;padding: 2px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewProduk' list='new_produk' autocomplete='off' autocomplete='disable' tabindex='999' class='form-control ns' placeholder='Nama Barang | eg. Mie Goreng'>";
                            echo "<div id='addNewProdukContent' style='min-width: 100px;max-width:250px;max-height: 300px;position: absolute;z-index: 1;' class=''></div>";
                            echo "</td>";
                        }
                        else if ($key == "satuan_factor_nama") {
                            echo "<td style='min-width:12px;white-space: nowrap;padding: 2px;' class='$key text-muted text-center'>";
                            //                            echo $label;
                            echo "</td>";
                        }
                        else {
                            echo "<td style='min-width:50px;white-space: nowrap;padding: 2px;' class='$key text-muted text-center'>";

                            //                            echo $label;
                            echo "</td>";
                        }
                    }
                    echo "</tr>";
                }
            }
        }

        $infoFreeItems = "";
        // $infoFreeItems .= "<b>Free Item(s)</b>";
        $infoDiskonItems = "";

        // $infoDiskonItems .= "<b>Diskon berjenjang</b>";
        foreach ($items as $iSpec) {
            if ($showItems) {

                $iID = $iSpec['id'];
                $rowRemove = "";
                //                    if ($selectAll) {
                //                        $rowRemove .= "<input type='checkbox' class='checkbox_prd' id='chkPrd_".$iSpec['id']."' name='produk_id[".$iSpec['id']."]'>";
                //                    }
                //                    else{
                /*
                 * Transaksi yang di simpan menggunakan modul Preorder, membawa path modul preorder
                 * jadi tidak jalan remove itemsnya.
                 * SOLUSI: modul preorder di replace menjadi modul penjualan pada link target items
                 */
                $removeTarget = isset($iSpec['removeTarget']) ? str_replace("preorder", "penjualan", $iSpec['removeTarget']) : "#";

                $rowRemove = "<a href='javascript:void(0);' class='btn btn-xs bg-red text-white' title='remove this item' data-toggles='tooltip' data-placement='left' onclick=\"document.getElementById('result').src='" . $removeTarget . "';setTimeout( function(){ $('#shopping_cart').trigger('change') }, 1500);\"><i class='fa fa-close'></i></a>";
                //                    }
// cekBiru($iSpec);
// cekBiru($iSpec);
                $checked_grosir = !isset($items_cCode[$iID]['free_items']) && isset($items_cCode[$iID]['discPersen']) && $items_cCode[$iID]['discPersen'] > 0 ? "checked" : "";
                $checked_free = isset($items_cCode[$iID]['free_items']) && $iSpec['discPersen'] == 0 ? "checked" : "";
                // $box_warna = (isset($items_cCode[$iID]['free_items']) || isset($items_cCode[$iID]['free_items_off'])) && isset($items_cCode[$iID]['discPersen']) ? "box-warning" : "box-info";
                /* -------------------------------------------------------------------------------------
                 * pewarna informasi box
                 * -------------------------------------------------------------------------------------*/
                $dfree_produk = isset($items_cCode[$iID]['free_items']);
                $dgrosir = (isset($items_cCode[$iID]['discPersen']) && $items_cCode[$iID]['discPersen'] > 0);

                if($dfree_produk == true && $dgrosir == true){
                    $box_warna = "box-danger";
                    echo "<script>
                            $('#discNilai').addClass('text-blur');
                            $('#grand_total').addClass('text-blur');
                    </script>";

                }
                elseif ($dfree_produk == false && $dgrosir == false){
                    $box_warna = "box-warning";
                }
                else{
                    $box_warna = "box-info";
                }
                /* -------------------------------------------------------------------------
                 * informasi diskon pada tiap produk
                 * -------------------------------------------------------------------------*/
                if (isset($produkDiskon[$iID]) || isset($free_items[$iID]) || (isset($iSpec['free_produk_note']) && !empty($iSpec['free_produk_note']))) {

                    /* -------------------- ----------
                     * nama produk
                     * ------------------------------*/
                    $infoDiskonItems .= "<div class='box $box_warna box-solid'>";
                    $infoDiskonItems .= "<div class='box-header with-border' title='$iID'>" . $iSpec['nama'] . "</div>";
                    $infoDiskonItems .= "<div class='box-body'>";
                    $diskon_grosir = false;
                    /* ---------------------------------------------------
                     * grosir produk
                     * ---------------------------------------------------*/
                if (isset($produkDiskon[$iID])) {
                        $infoDiskonItems .= "<div class='float-container' style='overflow: hidden;'>";
                    $infoDiskonItems_ = "";

                    // arrPrintWebs($produkDiskon[$iID][0]);
                    /* -------------------------------------------------------------------------------------------
                     * informasi diskon grosir (pre grosir)
                     * untuk tidak menampilkan info ini ------------
                     * // $hasil = "";
                     * dihidupkan saja
                         *
                         * no.001:: untuk mengatur gedenya area informasi yg abu2 ada di template transaksi.html (Informasi)
                     * height: 20vh; dirunah saja nilainya
                         * info no.001 sudah tidak dipakai, scrip di tempate dimatikan
                     * -------------------------------------------------------------------------------------------*/
                    $produk_diskon_0 = $produkDiskon[$iID][0];
                    $minim_0 =$produk_diskon_0['minim'] - 1;
                    $harga_af_0 = $produk_diskon_0['harga_be'];
                    $harga_af_f0 = number_format($harga_af_0, 0);

                    $var = "<b>1</b> s/d <b>$minim_0</b> harga Rp. <b>$harga_af_f0</b>,-";
                    $hasil = $var;

                    // $hasil = "";
                    /* -------------------------------------------------------------------------------------------
                     * info diskon grosir yg bener-bener dapat diskon
                     * -------------------------------------------------------------------------------------------*/
                    foreach ($produkDiskon[$iID] as $k => $gross) {
                        if ($gross['persen'] * 1 > 0) {

                            $minim = $gross['minim'];
                            $maxim = $gross['maxim'];
                            $harga_af = $gross['harga_af'];
                            $harga_af_f = number_format($harga_af, 0);
                            $nilai = $gross['nilai'];
                            $nilai_f = number_format($nilai, 0);
                            $persen = $gross['persen'];
                            $persen_f = number_format($persen, 2);
                                $harga_bulk = $minim * $harga_af;
                                $harga_bulk_f = number_format($harga_bulk,0);

                            if ($maxim > 0){
                                    $var = "<b>$minim</b> s/d <b>$maxim</b> harga Rp.<b>$harga_af_f</b>,- (disc Rp.<r>$nilai_f</r>/$persen_f%) (Rp.<gb>$harga_bulk_f</gb>,-/<r>$minim</r>)";
                            }
                            else{
                                    $var = "<b>$minim</b> <r>keatas</r> harga Rp.<b>$harga_af_f</b>,- (disc Rp.<r>$nilai_f</r>/$persen_f%) (Rp.<gb>$harga_bulk_f</gb>,-/<r>$minim</r>)";
                            }

                            if ($hasil == "") {
                                $hasil .= "$var";
                            }
                            else {
                                $hasil = "$hasil<br>$var";
                            }
                        }
                    }
                        $option_d = "<input type='radio' name='produk_$iID' id='grosir_$iID' $checked_grosir value='1' onclick='diskon_off(this.value, this.id);'>";
                        $infoDiskonItems .= "<div class='float-child'>$option_d</div>";
                        $infoDiskonItems .= "<div class='float-child'> $hasil</div>";

                    $infoDiskonItems .= "</div>";

                        $diskon_grosir = true;
                }

                    /* ---------------------------------------------------------------------------------------------
                     * free produk
                     * ---------------------------------------------------------------------------------------------*/
                    $option_df = "";
                    if (isset($free_items[$iID])) {
                        // $option_df = "<input type='radio' name='produk_$iID' id='free_$iID' value='1'>";
                        $option_df = "<input type='radio' name='produk_$iID' id='free_$iID' $checked_free value='1' onclick='diskon_off(this.value, this.id);'>";
                        foreach ($free_items[$iID] as $idDiskon => $rowDiskon) {
                            // arrPrintPink($rowDiskon);
                            $infoFreeItemss = "<span class='text-green'><b class='text-red'>Gratis!</b> <span class='text-bold text-capitalize'>" . $rowDiskon['free_qty'] . "x " . $rowDiskon['free_produk_nama'] . "</span></span>";
                            $infoFreeItemss .= "<br>minimal pembelian " . $rowDiskon['minimal'] . "x <span class='meta'> (" . ($rowDiskon['kelipatan'] == 0 ? "tidak berlaku kelipatan" : "berlaku kelipatan") . ")</span>";
                        }
                    }
                    else {
                        // arrPrintHijau($iSpec);
                        $option_df = "<input type='radio' disabled>";
                        $infoFreeItemss = "";
                        if(isset($iSpec['free_produk_note']) &&  !empty($iSpec['free_produk_note'])){
                            // $infoFreeItemss = "<span style='background-color: yellow;' class=''>" . $iSpec['free_produk_note'] . "</span>";
                            $infoFreeItemss = "<r>Gratis!</r> " .$iSpec['free_produk_note'];
                            // $infoFreeItemss = "test";
                        }
                        else{
                            $infoFreeItemss = "";
                        }
                    }

                    if(!empty($infoFreeItemss)){
                        if($diskon_grosir == true){
                            $infoDiskonItems .= "<div class='box-free bg-grey-1 overflow-h'>";
                        }
                        else{
                            $infoDiskonItems .= "<div class=''>";
                        }
                        $infoDiskonItems .= "<div  class='float-child'>$option_df</div>";
                        $infoDiskonItems .= "<div  class='float-child' style='word-wrap: break-spaces;'>$infoFreeItemss</div>";
                        $infoDiskonItems .= "</div>";
                    }

                    $infoDiskonItems .= "</div>";
                    $infoDiskonItems .= "</div>";
                }
                else if (!isset($produkDiskon[$iID]) && $iSpec['discPersen'] * 1 > 0) {
                    /*?????--------apakah ini dipakai-----------?????*/
                    $infoDiskonItems .= "<div style='margin-top: 3px;' class='text-bold text-left text-green'>" . $iSpec['nama'] . "</div>";
                    $infoDiskonItems .= "<div class='text-left'>Potongan <b><r>(" . ($iSpec['discPersen'] * 1) . "%)</r></b> beli Min 1 Buah";
                    $infoDiskonItems .= "</div>";
                    $infoDiskonItems .= "</div>";
                }
                else {

                }

                $no++;
                $bgColor = "transparent";
                if (isset($_SESSION['errLines'])) {
                    if (in_array($iSpec['id'], $_SESSION["errLines"])) {
                        $bgColor = "#ffff77";
                    }
                }

                echo "<tr id='tr_" . $iSpec['id'] . "' bgcolor=$bgColor>";
                echo "<td style='vertical-align:middle; width:15px;' class='text-center'>";
                echo "<span class='text-bold'>$rowRemove&nbsp;$no</span>";
                echo "</td>";

                $colCtr = 0;
                $queryParams = "";
                $colID = array();
                $listMode = array();
                $readOnly = array();
                $qtyParam = "";
                if (isset($itemLabels['jml'])) {
                    $qtyParam = "+document.getElementById('jml_$no').value";
                }
                if (isset($itemLabels['qty_unit'])) {
                    $qtyParam = "+removeCommas(document.getElementById('qty_unit_$no').value)";
                }
                foreach ($itemLabels as $key => $label) {
                    if (isset($optionItemField[$key])) {
                        $listMode[$key] = "option";
                    }
                    else {
                        $listMode[$key] = "input";
                    }
                    $keyupEvent[$key] = "";
                    $keyUpStr[$key] = "";
                    if (array_key_exists($key, $keyUpEvents)) {
                        if (sizeof($selectedPrices) > 0) {
                            $keyupEvent[$key] = $keyUpEvents[$key];
                            foreach ($selectedPrices as $k => $v) {
                                $nameLabel = $k . "_" . $no;
                                $keyupEvent[$key] = str_replace("{" . $k . "}", $nameLabel, $keyupEvent[$key]);
                            }
                            foreach ($itemLabels as $k => $v) {
                                $nameLabel = $k . "_" . $no;
                                $keyupEvent[$key] = str_replace("{" . $k . "}", $nameLabel, $keyupEvent[$key]);
                            }
                        }
                        if (isset($keyupAction) && $keyupAction == true) {
                            $keyupEvent[$key] = $keyUpEvents[$key];
                            foreach ($selectedPrices as $k => $v) {
                                $nameLabel = $k . "_" . $no;
                                $keyupEvent[$key] = str_replace("{" . $k . "}", $nameLabel, $keyupEvent[$key]);
                            }
                            foreach ($itemLabels as $k => $v) {
                                $nameLabel = $k . "_" . $no;
                                $keyupEvent[$key] = str_replace("{" . $k . "}", $nameLabel, $keyupEvent[$key]);
                            }
                        }
                    }
                    else {
                    }
                    if (strlen($keyupEvent[$key]) > 2) {
                        $keyUpStr[$key] = " onkeyup=\"" . $keyupEvent[$key] . "\" ";
                    }
                    if (in_array($key, $editableFields)) {
                        $readOnly[$key] = "";
                        if (isset($iSpec["jml"]) && $iSpec["jml"] < 1) {
                            $readOnly[$key] = "readonly_xz";
                        }
                        if (isset($paramsForceEditable[$key])) {
                            if ($paramsForceEditable[$key] == true) {

                            }
                            else {
                                $readOnly[$key] = "readonly_xxz";
                                $listMode[$key] = "text";
                            }
                        }
                    }
                    else {
                        $readOnly[$key] = "readonly_xxz";
                        $listMode[$key] = "text";
                    }
                    $colID[$key] = $key . "_" . $no;
                    if ($listMode[$key] == "input") {
                        $queryParams .= "&$key='+removeCommas(document.getElementById('" . $colID[$key] . "').value)+'";
                    }
                }

                $tabIndex = 1000;
                foreach ($itemLabels as $key => $label) {
                    $colCtr++;
                    $color = "343434";
                    if (isset($_SESSION['errFields'][$iSpec['id']])) {
                        if (in_array($key, $_SESSION['errFields'][$iSpec['id']])) {
                            $color = "#dd3300";
                        }
                    }
                    echo "<td>";
                    $colID = $key . "_" . $no;
                    $keyID = $key;
                    $noID = $no;
                    $tabIndexNum = $colCtr . $no;
                    $fieldVal = "";

                    $js_tr_free_prod = ($key == "nama" && isset($free_items[$iID])) || ($key == "nama" && isset($iSpec['free_produk_note']) && $iSpec['free_produk_note'] != '') ? (isset($free_items[$iID]) ? "<i onclick=\"$('#tr_free_prod_$iID').toggleClass('in out')\" title='click untuk melihat diskon' class='fa fa-gift text-green'></i>&nbsp;" : "<i onclick=\"$('#tr_free_prod_$iID').toggleClass('in out')\" title='click untuk melihat diskon' class='fa fa-gift text-yellow'></i>&nbsp;") : "";
                    $js_tr_disc_prod = $key == "nama" && ($key == "nama" && isset($iSpec['discPersen']) && $iSpec['discPersen'] * 1 > 0) ? " <i class='fa fa-percent text-green text-bold'></i>" : ($key == "nama" && isset($produkDiskon[$iID]) && $iSpec['discPersen'] * 1 == 0 ? "<i class='fa fa-percent text-yellow text-bold'></i>" : "");

                    if (substr($key, 0, 1) == "*") {
                        $key_p = str_replace("*", "", $key);
                        $key_ex = explode("#", $key_p);
                        $pair_name = $key_ex[0];
                        $pair_key = $key_ex[1];
                        $pair_key_val = $iSpec[$pair_key];
                        if (sizeof($key_ex) > 1) {
                            $fieldVal = isset($pairedValue[$pair_name][$pair_key_val]) ? $pairedValue[$pair_name][$pair_key_val] : "0";
                        }
                        else {
                            $fieldVal = isset($pairedValue[$pair_name]) ? $pairedValue[$pair_name] : "0";
                        }
                    }
                    else {
                        if (isset($iSpec[$key])) {
                            if (is_numeric($iSpec[$key])) {
                                $fieldVal = $iSpec[$key] + 0;
                            }
                            else {
                                $fieldVal = $iSpec[$key];
                            }
                        }
                    }
                    if (sizeof($minValues) > 0) {
                        $moq = isset($minValues['moq'][$iID]) ? $minValues['moq'][$iID] : 0;
                        $validateKey_up = true;
                    }
                    else {
                        $moq = 0;
                        $validateKey_up = false;
                    }
                    $keyupData = (($key == "qty" || $key == "jml") && $validateKey_up == true) ? "onkeydown=\"if(parseInt(removeCommas(this.value))<$moq){setTimeout(function(){ this.value='" . $iSpec[$key] . "'}, 1000);} \"" : "";

                    switch ($listMode[$key]) {
                        case "input":
                            echo "<input type='number' tabindex=" . ($tabIndex + $noID) . " min='$moq' autocomplete='off' " . $readOnly[$key] . " keyid=$keyID noid=$noID id_jml=$iID id=$colID  class='form-control $keyID text-center text-bold' style='background:#00ff8a;color:$color;' value='" . $fieldVal . "' onclick=\"this.select();$(this).parent().parent().css('background-color','yellow');\" " . $keyUpStr[$key] . " ";
                            $baseInputName = isset($unionSelectors['base']) ? "document.getElementById('" . $unionSelectors['base'] . "_" . $no . "')" : "this";
                            $pemicuGerbangAsli = "onblur=\"$(this).parent().parent().css('background-color', 'white');if(removeCommas(this.value)!=removeCommas(this.defaultValue)){hiliteDiv(this);getData('" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams','result');} \" $keyupData";
                            $pemicuGerbangAsli .= "onmouseout=\"if(removeCommas(this.value)!=removeCommas(this.defaultValue)){hiliteDiv(this);document.getElementById('result').src='" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams';}\" ";
                            $pemicuGerbang = "onblur=\"$(this).parent().parent().css('background-color', 'white');if(removeCommas($baseInputName.value(!=removeCommas($baseInputName.defaultValue)){hiliteDiv($baseInputName);getData('" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams','result');}\" $keyupData ";
                            $pemicuGerbang .= "onmouseout=\"if(removeCommas($baseInputName.value)!=removeCommas($baseInputName.defaultValue)){hiliteDiv($baseInputName);getData('" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams','result');}\" ";
                            $pemicuGerbangUnion = "onchange=\"if(removeCommas($baseInputName.value!=$baseInputName.defaultValue)){hiliteDiv($baseInputName);getData('" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams','result');} \" ";
                            if (isset($unionSelectors['base'])) {
                                if ($unionSelectors['base'] == $key) {//==jadi acuan kiriman
                                    echo str_replace("this", $baseInputName, $pemicuGerbang);
                                }
                                else {
                                    if (in_array($key, $unionSelectors['members'])) {//==jadi member union, tidak memicu perubahan gerbang
                                        echo $pemicuGerbangUnion;
                                    }
                                    else {//==biasa aja, memicu perubahan gerbang
                                        echo $pemicuGerbangAsli;
                                    }
                                }
                            }
                            else {
                                echo $pemicuGerbangAsli;
                            }

                            if (isset($keyupAction) && $keyupAction == true) {
                                echo "onkeyup=\"document.getElementById('result').src='" . $iSpec['editTarget'] . "'$qtyParam+'$queryParams';\"";
                            }
                            else {
                                echo "onkeyup=\"delay_v2( function(){ $('#shopping_cart').trigger('change') }, 400, this );\"";
                            }
                            echo ">";

                            $tabIndex += $tabIndex;

                            break;
                        case "text":
                            if (is_numeric($fieldVal)) {
                                echo "<span numeric keyid=$keyID noid=$noID id=$colID class='form-control text-bold text-right' style='color:$color;background-color: transparent!important;'>" . ($keyID == 'barcode' ? $fieldVal : ($key == 'discPersen' ? preg_replace("/\,?00+$/", "", number_format($fieldVal, 2, ',', '.'))  : preg_replace("/\,?00+$/", "", number_format($fieldVal, 2, ',', '.')) )) . "</span>";
                            }
                            else {
                                //                                    if (strlen($fieldVal) > 19) {
                                //                                        $fieldVal_f = substr($iSpec[$key], 0, 19) . ' ...';
                                //                                        echo "<span panjang35 keyid=$keyID noid=$noID id=$colID title='".trim($fieldVal)."' class='form-control text-bold text-left text-uppercase' style='color:$color;border:0px;white-space: nowrap;background-color: transparent!important;'>$js_tr_free_prod $js_tr_disc_prod " . formatField_he_format($key, $fieldVal_f) . "</span>";
                                //                                    }
                                //                                    else {
                                echo "<span panjang34 keyid=$keyID noid=$noID id=$colID class='form-control text-bold text-left text-uppercase' style='color:$color;border:0px;white-space: nowrap;background-color: transparent!important;'>$js_tr_free_prod $js_tr_disc_prod " . formatField_he_format($key, $fieldVal) . "</span>";
                                //                                    }
                            }
                            break;

                        case "option":
                            $keyOptionIndex = $optionItemField[$key]["keySrc"];
                            $qparams = blobEncode($optionItemField[$key]["usedFields"]);
                            $processorTargetOption = MODUL_PATH . "" . $optionItemField[$key]["selectorProcessor"];
                            $actionTrigger = "onchange=\"document.getElementById('result').src='" . $processorTargetOption . "/?pid=$iID&key=$keyOptionIndex&jml=" . $iSpec['jml'] . "&qty_unit=" . $iSpec['qty_unit'] . "&qparams=$qparams&value='+this.value;\" ";
                            $optionField = "<select onblur=\"console.log('test blur');$(this).parent().parent().css('background-color', 'white');\" onfocus=\"console.log('test focus');$(this).parent().parent().css('background-color','yellow')\" keyid=$keyID noid=$noID name='$colID' id='$colID' style='background:#00ff8a;' class='form-control text-bold' $actionTrigger>";
                            $prevData = isset($items3[$iID]) ? $items3[$iID] : "";
                            foreach ($items3[$iID][$key] as $iiD2 => $iiData) {
                                $selected = $iSpec["satuan_factor_id"] == $iiD2 ? "selected" : "";
                                $optionField .= "<option value='" . $iiD2 . "' $selected >$iiData[$key] <span style=\"font-size:1em ;margin:0px 2px 0px 2px;color:#0056cd;\" pull-right class='text-blue'>(Isi " . $iiData["satuan_factor_qty"] . ")</span></option>";
                            }
                            $optionField .= "</select>";
                            echo $optionField;
                            break;
                    }
                    echo "</td>";

                }

                //region remover per row
                if (!$avoidRemove) {
                    //                         echo "<td width='1%'>";
                    //                         echo "<a class='text-red btn' title='remove this item' data-toggle='tooltip' data-placement='left' onclick=\"document.getElementById('result').src='" . $iSpec['removeTarget'] . "';\"><span class='glyphicon glyphicon-remove'></span></a>";
                    //                         echo "</td>";
                }
                //endregion

                echo "</tr>";


                /* ----------------------------------------------------------------------
                 * info diskon ditiap baris produk (diskon grosir, free produk)
                 * ----------------------------------------------------------------------*/
                if (isset($free_items[$iID])) {
                    /*-----free produk yg sudah diambil------*/
                    foreach ($free_items[$iID] as $idDiskon => $rowDiskon) {
                        $freeLabelCol = count($itemLabels);
                        echo "<tr id='tr_free_prod_$iID' class='collapse'>";
                        echo "<td style='padding: 2px;font-size: 12px;' colspan='2' class='text-center'>";
                        echo "<span class='text-bold text-green form-controlx'><i class='fa fa-gift'></i> Get Free Produk <i class='fa fa-check-circle'></i></span>";
                        echo "</td>";
                        echo "<td style='padding: 2px;font-size: 12px;' colspan='$freeLabelCol' class='text-left'>";
                        echo "<span style='font-size: 12px;' class='text-bold text-green form-controls text-capitalize'> &nbsp; &nbsp; &nbsp; " . $rowDiskon['free_qty'] . "x " . $rowDiskon['free_produk_nama'] . "</span> &nbsp; &nbsp; &nbsp; <span>" . $rowDiskon['free_produk_note'] . "</span>";
                        echo "</td>";
                        echo "</tr>";
                        // $infoFreeItems .= "<div style='padding: 6px;margin-bottom: 3px;' class='panel panel-success bg-green'>&nbsp;<i class='fa fa-check-circle'></i>&nbsp;<span class='text-bold text-capitalize'>" . $rowDiskon['free_qty'] . "x " . $rowDiskon['free_produk_nama'] . "</span></div>";
                    }
                }
                else if (isset($iSpec['free_produk_note']) && $iSpec['free_produk_note'] != "") {
                    /*-----free produk info doang------*/
                    $freeLabelCol = count($itemLabels);
                    if (!$isMobile && !$onPreOrderOnly) {
                        echo "<tr id='tr_free_prod_$iID' class='collapse'>";
                        echo "<td style='padding: 2px;font-size: 12px;' colspan='2' class='text-center'>";
                        echo "<span style='font-family: monospace;' class='text-bold text-default form-controlx'><i class='fa fa-gift text-red blink'></i> Ada Diskon Produk <i class='fa fa-gift text-red blink'></i></span>";
                        echo "</td>";
                        echo "<td style='padding: 2px;font-size: 12px;' colspan='$freeLabelCol' class='text-left'>";
                        echo "<span style='font-size: 12px;font-family: monospace;' class='text-bolds text-default text-capitalize'> &nbsp; <b><r>INFORMASI DISKON PRODUK:</r></b>  " . $iSpec['free_produk_note'] . "</span>";
                        echo "</td>";
                        echo "</tr>";
                    }
                    else {
                        echo "<tr id='tr_free_prod_$iID' class='collapse'>";
                        echo "<td style='padding: 2px;font-size: 12px;' colspan='" . ($freeLabelCol + 1) . "' class='text-left'>";
                        echo "<span style='font-size: 12px;font-family: monospace;' class='text-bolds text-default text-capitalize'><b><r>INFORMASI DISKON PRODUK:</r></b><br>" . $iSpec['free_produk_note'] . "</span>";
                        echo "</td>";
                        echo "</tr>";
                    }
                    // $infoFreeItems .= "<div style='padding: 6px;margin-bottom: 3px;background-color: yellow;' class='panel panel-danger text-bold text-muted'> <i class='fa fa-warning blink text-red'></i> &nbsp; " . $iSpec['free_produk_note'] . "</div>";
                }
                else {

                }
                if ($noteEnabled == true) {
                    $colspan2 = $imageEnable == true ? 1 : -1;
                    $colspan = sizeof($itemLabels) - $colspan2;
                    echo "<tr>";
                    echo "<td>&nbsp;</td>";
                    echo "<td colspan='" . $colspan . "'>";
                    $noteVal = isset($iSpec['note']) ? $iSpec['note'] : "";
                    if (isset($noteType)) {
                        switch ($noteType) {
                            case "textarea":
                                echo "<textarea class='form-control' placeholder='write notes here'
                                onblur=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                onmouseout=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                >$noteVal</textarea>";
                                break;
                            case "text":
                            default:
                                echo "<input type=text class='form-control' value='$noteVal' placeholder='write notes here'
                                onblur=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                onmouseout=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                >";
                                break;
                        }
                    }

                    echo "</td>";
                    if ($imageEnable == true) {
                        echo "<td colspan='2'>";
                        $imageVal = isset($iSpec['images']) ? $iSpec['images'] : "";
                        if (isset($imageType)) {
                            switch ($imageType) {
                                case "images":

                                    $file_e = "";
                                    $file = isset($iSpec['images']) ? $iSpec['images'] : "";
                                    $file_e = urlencode($file);
                                    echo "<div class='input-groups'>";
                                    if (strlen($imageVal) > 0) {
                                        $modals = array(
                                            "title" => "Attachment " . $iSpec['nama'],
                                            "body"  => array($file),
                                        );
                                        $modal_e = urlencode(blobEncode($modals));
                                        $modal_l = base_url() . "Katalog/modal/$modal_e";

                                        echo "<a href='$modal_l' data-toggle='modal' data-target='#myModal'><img src='$file' class='img-rounder' height='50px' style='float: right;'></a>";
                                        echo "<input type='hidden' name='img_$iID' value='$file'>";
                                    }

                                    echo "<form class='input-group' id='myForm_$iID' method='post' enctype='multipart/form-data' action='$imageRecorder/$iID?valValue=$file_e' target='result'>";

                                    echo "<input type='file' id='file-upload' style='border: none;' name='file' class='file' onchange=\"document.getElementById('myForm_$iID').submit();swal({'text':'uploading image ... ... ',showConfirmButton: false,timer:5000,});\">";

                                    echo "</form>";
                                    echo "</div>";

                                    break;
                                case "text":
                                default:
                                    echo "<input type=text class='form-control' value='$noteVal'
                                onblur=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                onmouseout=\"if(this.value!=this.defaultValue){hiliteDiv(this);document.getElementById('result').src='" . $noteRecorder . "?val='+encodeURIComponent(this.value)+'&iid=$iID';}\"
                                >";
                                    break;
                            }
                        }
                        echo "</td>";
                    }
                    echo "</tr>";
                }
                if ($pairedItemEnabled == true) {
                    if (sizeof($pairedItemField) > 0) {
                        $listModePairedItem = array();
                        $readOnlyPairedItem = array();
                        foreach ($pairedItemField as $key => $label) {
                            $listModePairedItem[$key] = "input";
                            if (in_array($key, $editableFields)) {
                                $readOnlyPairedItem[$key] = "";
                                if (isset($iSpec["jml"]) && $iSpec["jml"] < 1) {
                                    $readOnlyPairedItem[$key] = "readonly_x";
                                }
                            }
                            else {
                                $readOnlyPairedItem[$key] = "readonly_xx";
                                $listModePairedItem[$key] = "text";
                            }
                        }
                    }
                    echo "<tr>";
                    echo "<td>&nbsp;</td>";
                    $c_itemLabels = sizeof($itemLabels);
                    $c_pairedItemField = sizeof($pairedItemField);
                    $c_colspan = ($c_itemLabels - $c_pairedItemField + 1);
                    echo "<td colspan='" . $c_colspan . "'>";
                    //==pairedItems, if any
                    if (isset($selItems) && sizeof($selItems) > 0) {
                        echo "<select
                                title='Choose one of the following...'
                                data-header='Ketik Nama/Kode/Folder/Barcode'
                                data-size='10'
                                data-container='body'
                                class='picker_$iID selectpicker form-control select2 show-tick'
                                data-style='btn-primary'
                                data-live-search='true'
                                classs='form-control'
                                onchange=\"document.getElementById('result').src='" . $pairedItemRecorder . "?val='+(this.value)+'&iid=$iID'\"
                                >";

                        asort($selItems);

                        foreach ($selItems as $piID => $piName) {
                            if ($piID != $iSpec['id']) {
                                $selectedState = (isset($pairedItems[$iID]) && ($piID == $pairedItems[$iID]['id'])) ? "selected" : "";
                                $selItemsKodes = isset($selItemsKode[$piID]) ? $selItemsKode[$piID] : "-";
                                $selItemsFolders = isset($selItemsFolder[$piID]) ? $selItemsFolder[$piID] : "-";
                                $selItemsKeterangans = isset($selItemsKeterangan[$piID]) ? $selItemsKeterangan[$piID] : "-";
                                $selItemsBarcodes = isset($selItemsBarcode[$piID]) ? $selItemsBarcode[$piID] : "-";
                                echo "<option data-subtext='$selItemsKodes' data-tokens='$piID $selItemsFolders $selItemsKeterangans $selItemsBarcodes' value='$piID' $selectedState>$piName </option>";
                            }
                        }
                        echo "</select>";
                    }

                    echo "</td>";

                    echo "<script> $('.picker_$iID').selectpicker(); </script>";

                    if (sizeof($pairedItemField) > 0) {
                        foreach ($pairedItemField as $key => $label) {
                            $pairedItems2ID = isset($pairedItems[$iID]['id']) ? $pairedItems[$iID]['id'] : 0;
                            $pairedItems2Qty = isset($pairedItems[$iID]['jml']) ? $pairedItems[$iID]['jml'] : 0;
                            $fieldVal = isset($pairedItems[$iID][$key]) ? $pairedItems[$iID][$key] : "";
                            echo "<td>";
                            switch ($listMode[$key]) {
                                case "input":
                                    echo "<input type='number' class='form-control text-right' value='" . $pairedItems2Qty . "' min='0' autocomplete='off'
                                    onblur=\"document.getElementById('result').src='" . $pairedItemRecorder . "?newQty='+(this.value)+'&iid=$iID&val=$pairedItems2ID&spc=1';\"
                                    onmouseout06=\"document.getElementById('result').src='" . $pairedItemRecorder . "?newQty='+(this.value)+'&iid=$iID&val=$pairedItems2ID&spc=1';\"
                                    >";
                                    break;
                                case "text":
                                    if (is_numeric($fieldVal)) {
                                        echo "<span class='form-control text-right' style='color:$color;background:#f0f0f0;'>" . number_format($fieldVal) . "</span>";
                                    }
                                    else {
                                        echo "<span class='form-control text-left' style='color:$color;border:0px;'>" . str_replace(" ", "&nbsp;", $fieldVal) . "</span>";
                                    }
                                    break;
                            }
                            echo "</td>";
                        }
                    }
                    echo "</tr>";
                }
            }
        }
        //region items2, kalau salah satunya untuk produksi dan konversi
        if (isset($items2) && sizeof($items2) > 0) {
            echo "<tr class='bg-info'>";
            echo "<td colspan='$jmlKolomHeader'>";
            echo "<div class='panel no-margin'>"; // anakan table
            echo "<table class='table table-condensed table-striped no-padding no-border'>";
            if (sizeof($itemLabels2) && (is_array($itemLabels2)) && $showItems) {
                echo "<tr>";
                echo "<td class='text-muted bg-grey-1 text-center'>";
                echo "No";
                echo "</td>";
                foreach ($itemLabels2 as $key => $label) {
                    echo "<td class='text-muted bg-grey-1 text-center text-capitalize'>";
                    echo $label;
                    echo "</td>";
                }
                echo "</tr>";
            }
            $no = 0;
            $kurangStoks = array();
            foreach ($items2 as $iSpec) {
                $iID = $iSpec['id'];
                $no++;
                $bgColor = "transparent";
                if (isset($items2_sum_kurang) && is_array($items2_sum_kurang)) {
                    if (isset($items2_sum_kurang[$iID])) {
                        $bgColor = "yellow";
                    }
                }
                if (isset($_SESSION['errLines'])) {
                    if (in_array($iSpec['id'], $_SESSION["errLines"])) {
                        $bgColor = "#ffff77";
                    }
                }
                echo "<tr id='tr_" . $iSpec['id'] . "' bgcolor=$bgColor>";
                echo "<td width='5%'>";
                echo $no;
                echo ".</td>";
                $colCtr = 0;
                $queryParams = "";
                foreach ($itemLabels2 as $key => $label) {
                    $colID = $key . "_" . $no;
                    $queryParams .= "&$key='+document.getElementById('$colID').value+'";
                }
                foreach ($itemLabels2 as $key => $label) {
                    $colCtr++;
                    $color = "343434";
                    if (isset($_SESSION['errFields'][$iSpec['id']])) {
                        if (in_array($key, $_SESSION['errFields'][$iSpec['id']])) {
                            $color = "#dd3300";
                        }
                    }
                    $cAlign = is_numeric($iSpec[$key]) ? "text-right" : "text-left";
                    if ($key == "sisa") {
                        if ($iSpec[$key] < 0) {
                            $kurangStoks[$iSpec['nama']] = $iSpec['sisa'];
                            $cAlign .= " text-red text-bold";
                        }
                        else {
                            $cAlign .= "";
                        }
                    }
                    echo "<td class='$cAlign'>";
                    $tabIndexNum = $colCtr . $no;
                    if (is_numeric($iSpec[$key])) {
                        echo formatField_he_format($key, $iSpec[$key]);
                    }
                    else {
                        echo $iSpec[$key];
                    }
                    echo "</td>";
                }
                echo "</tr>";
            }
            echo "</table>";
            echo "</div>"; // anakan table
            echo "</td>";
            echo "</tr>";
        }
        //endregion items2, kalau salah satunya untuk produksi dan konversi
        echo "</tbody>";

        /*=============================sumrows============================*/
        if (isset($sumRows) && sizeof($sumRows) > 0) {
            $nr = 0;
            foreach ($sumRows as $key => $label) {
                $val = 0;
                $nr++;
                $bottom_borderless = $nr < sizeof($sumRows) ? "bottom-borderlessx" : "";
                if (isset($main[$key]) && $main[$key] > 0) {
                    $val = $main[$key];
                }
                else {
                    if (isset($addValues[$key]) && $addValues[$key] > 0) {
                        $val = $addValues[$key];
                    }
                }
                if ($showItems) {
                    echo "<tr class=''>";
                    echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right $bottom_borderless valign-m text-uppercase text-bold text-muted'>$label &nbsp; &nbsp; &nbsp;</td>";
                    echo "<td colspan='3' class='right-borderlessx'>";
                    echo "<input type='text' id='$key' class='form-control text-right text-bold' readonly value='" . preg_replace("/\,?00+$/", "", number_format($val, 2, ',', '.'))  . "' >";
                    echo "</td>";
                    echo "</tr>";
                }
            }
        }

        if (isset($sumRows2) && sizeof($sumRows2) > 0) {
            echo "<tr bgcolor='#e0e0e0'>";
            echo "<td colspan='" . (sizeof($itemLabels2) + 1) . "' class='text-left text-muted'><span class='fa fa-cog'></span> additional fees</td>";
            echo "</td>";
            echo "</tr>";
            $nr = 0;
            foreach ($sumRows2 as $key => $label) {
                $nr++;
                $bottom_borderless = $nr < sizeof($sumRows2) ? "bottom-borderless" : "";
                echo "<tr bgcolor='#f0f0f5'>";
                echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right bottom-borderless valign-m text-uppercase'>$label</td>";
                echo "<td>";
                echo $sumSpec2[$key];
                echo "</td>";
                echo "</tr>";
            }
        }

        //            if (sizeof($addRows) > 0 && !$onPreOrderOnly ) {
        //                $nr = 0;
        //                foreach ($addRowLabels as $k => $label) {
        //                    $nr++;
        //                    $bottom_borderless = $nr < sizeof($addRowLabels) ? "bottom-borderless" : "";
        //                    $rowHide = isset($addRowHiddens[$k]) ? $addRowHiddens[$k] : "";
        //
        //                    echo "<tr addRows class='hidden $rowHide'>";
        //                    echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right $bottom_borderless valign-m text-uppercase text-bold text-muted'>$label &nbsp; &nbsp; &nbsp;</td>";
        //                    echo "<td colspan='2' class='text-right'>";
        //                    echo $addRows[$k];
        //                    echo "</td>";
        //                    echo "</tr>";
        //
        //                }
        //            }

        //region clear shoping cart
        if (!$avoidRemove) {
            echo "<tr class='bg-grey-2'>";
            // echo "<td>&nbsp;</td>";
            echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";


            echo "<span class='pull-left hidden-lg'>";
            echo "<button style='margin: 3px;' id='btn_clear_shopping_cart' type='button' class='text-red btn btn-xs' title='remove ALL ITEMS' data-toggles='tooltip' data-placement='right' onclick=\"confirm_alert_result('Attention !!!','Remove all items on shopping cart?','$resetLink','YES CLEAR');\"><i class='fa fa-trash'> </i> Clear Shoping Cart</button>";
            echo "</span>";
            //                if (isset($main['oto_diskon'])) {
            //                    echo "<input id='r_oto_diskon' class='hidden' value='" . $main['oto_diskon'] . "'>";
            //                }
            //                 arrPrintPink($tmpSaver);
            if (sizeof($tmpSaver) > 0) {
                $link_tmpSave = MODUL_PATH . $tmpSaver["exeTarget"];
                $link_reqDiskon = MODUL_PATH . $reqDiskon["exeTarget"];
                echo "<button style='margin: 3px;' type='button' id='tmp_save' class='btn btn-md btn-primary pull-right hidden-lg' onclick=\"btn_result('$link_tmpSave');\"><i class='fa " . $tmpSaver['btnIcon'] . "'>&nbsp;</i> " . $tmpSaver['btnLabel'] . "</button>";
                //                    if (sizeof($reqDiskon) > 0) {
                //                        echo "<button type='button' id='req_diskon' class='btn btn-warning' onclick=\"btn_result('$link_reqDiskon');\"><i class='fa " . $reqDiskon['btnIcon'] . "'>&nbsp;</i> " . $reqDiskon['btnLabel'] . "</button>&nbsp;";
                //                    }
            }
            echo "<span id='btn_kalkulasi' class='pusll-left hidden'>";
            echo "<button type='button' class='btn btn-danger text-normal' titles='kalkulasi' data-toggles='tooltip' data-placement='right' onclick=\"fillBoxes()\"><i class='fa fa-refresh fa-spin'></i> <i id='kalkulasi'></i> Update View</button>";
            echo "</span>";
            echo "</td>";
            echo "</tr>";
        }
        //endregion
        $info_customer = 1;
        if ($info_customer && !$onPreOrderOnly) {
            echo "<tr class='bg-grey'>";
            echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";
            echo "<div class='text-left bg-grey' style='hheight: 80px;margin: 6px;'><div>$str_customer-</div></div>";
            echo "</td>";
            echo "</tr>";
        }

        echo "</table class='table'>";
        echo "</div class='table-responsive'>";

        if (isset($fixedNote)) {
            echo "<div class='alert alert-danger' style='margin-top: 10px;font-size: 15px;'>";
            echo "<span>$fixedNote</span>";
            echo "</div>";
        }

        if ($cCode == "_TR_982") {
            if (sizeof($elements) > 0) {
                echo "<div class='panel-body table-responsive'>";
                echo "<div class='row'>";
                echo "<div class='col-md-12'>";
                echo "<h4 class='text-blue text-left'>Please fill in details below</h4>";
                echo "</div class='col-md-12'>";
                echo "</div class='row'>";
                echo "<div class='col-lg-12 no-padding text-center' style='text-align:center;'>";
                $elCtr = 0;
                foreach ($elements as $eName => $pSpec) {
                    $elCtr++;
                    if (isset($pSpec['type']) && ($pSpec['type'] == "hidden")) {
                        // type hidden tidak perlu tampil di ui //
                    }
                    else {

                        if ($isMobile) {
                            //region penampil untuk elemen pada shopingcart
                            echo "<div class='col-md-6 col-lg-6 col-xs-12' style='border:2px #e1ece6 solid;margin:0px;background:" . $pSpec['bgColor'] . "'>";
                            echo "<div id='elTitle_$eName' class='text-left text-muted text-bold text-capitalize'>";

                            echo $pSpec['label'] . " ";
                            if (isset($elementConfigs[$eName]['autoSelect']) && $elementConfigs[$eName]['autoSelect']) {

                            }
                            else {
                                echo "<a href='javascript:void(0)' onclick=\"hiliteDiv(this);document.getElementById('result').src='" . $elementResetTarget . "$eName';\"><span class='fa fa-eraser'></span></a>";
                            }
                            echo "<span class='pull-right'><sup>" . $pSpec['editStr'] . "&nbsp;" . $pSpec['addStr'] . "</sup></span>";
                            echo "</div class='box-title'>";

                            if (isset($elementConfigs[$eName]['warningLabel']) && $elementConfigs[$eName]['warningLabel']) {
                                echo "<div class='col-md-12'>" . $elementConfigs[$eName]['warningLabel'] . "</div>";
                            }

                            echo "<div class=''>&nbsp;</div>";
                            echo $pSpec['string'];
                            echo "</div>";
                            //endregion
                        }
                        else {
                            //region penampil untuk elemen pada shopingcart
                            if ($elCtr % 2 == 0) {
                            }
                            else {
                                echo "<div class='col-lg-12 no-padding'>";
                                echo "<div class='row row-eq-height'>";
                            }
                            echo "<div class='col-md-6 col-lg-6 col-xs-12' style='border:2px #e1ece6 solid;margin:0px;background:" . $pSpec['bgColor'] . "'>";

                            echo "<div id='elTitle_$eName' class='text-left text-muted text-bold text-capitalize'>";

                            echo $pSpec['label'] . " ";
                            if (isset($elementConfigs[$eName]['autoSelect']) && $elementConfigs[$eName]['autoSelect']) {

                            }
                            else {
                                echo "<a href='javascript:void(0)' onclick=\"hiliteDiv(this);document.getElementById('result').src='" . $elementResetTarget . "$eName';\"><span class='fa fa-eraser'></span></a>";
                            }
                            echo "<span class='pull-right'><sup>" . $pSpec['editStr'] . "&nbsp;" . $pSpec['addStr'] . "</sup></span>";
                            echo "</div class='box-title'>";

                            if (isset($elementConfigs[$eName]['warningLabel']) && $elementConfigs[$eName]['warningLabel']) {
                                echo "<div class='col-md-12'>" . $elementConfigs[$eName]['warningLabel'] . "</div>";
                            }

                            echo "<div class=''>&nbsp;</div>";
                            echo $pSpec['string'];

                            echo "</div>";
                            if ($elCtr % 2 == 0) {
                                echo "</div>";
                                echo "</div>";
                            }
                            //endregion
                        }
                    }
                }
                echo "</div class='row'>";
            }
        }

        // items element
        if ($cCode == "_TR_982") {
            if (sizeof($itemElements) > 0) {
                echo "<div class='panel-body table-responsive'>";
                echo "<div class='row'>";
                echo "<div class='col-md-12'>";
                echo "<h4 class='text-blue text-left'>Please fill in details below</h4>";
                echo "</div class='col-md-12'>";
                echo "</div class='row'>";
                echo "<div class='col-lg-12 no-padding text-center' style='text-align:center;'>";
                $elCtr = 0;
                foreach ($itemElements as $eName => $pSpec) {
                    $elCtr++;
                    if (isset($pSpec['type']) && ($pSpec['type'] == "hidden")) {
                        // type hidden tidak perlu tampil di ui //
                    }
                    else {

                        if ($isMobile) {

                        }
                        else {

                            //region penampil untuk elemen pada shopingcart
                            if ($elCtr % 2 == 0) {
                            }
                            else {
                                echo "<div class='col-lg-12 hidden no-padding'>";
                                echo "<div class='row row-eq-height'>";
                            }
                            echo "<div class='col-md-6 col-lg-6' style='border:2px #e1ece6 solid;margin:0px;background:" . $pSpec['bgColor'] . "'>";
                            echo "<div id='elTitle_$eName' class='text-left text-muted text-bold text-capitalize'>";
                            echo $pSpec['label'] . " ";
                            if (isset($itemElementConfigs[0]['autoSelect']) && $itemElementConfigs[0]['autoSelect']) {
                            }
                            else {
                                $helpName = $pSpec['helpName'];
                                echo "<a href='javascript:void(0)' onclick=\"hiliteDiv(this);document.getElementById('result').src='" . $itemElementResetTarget . "$eName/$helpName';\"><span class='fa fa-eraser'></span></a>";
                            }
                            echo "<span class='pull-right'><sup>" . $pSpec['editStr'] . "&nbsp;" . $pSpec['addStr'] . "</sup></span>";
                            echo "</div class='box-title'>";

                            if (isset($itemElementConfigs[0]['warningLabel']) && $itemElementConfigs[0]['warningLabel']) {
                                echo "<div class='col-md-12'>" . $itemElementConfigs[0]['warningLabel'] . "</div>";
                            }

                            echo "<div class=''>&nbsp;</div>";
                            $strSpec = $pSpec['string'];
                            /*-----------------------------
                             * penampil element kirimna dari controler
                             * -----------------------*/
                            echo $pSpec['string'];
                            echo "</div>";


                            if ($elCtr % 2 == 0) {
                                echo "</div>";
                                echo "</div>";
                            }
                            //endregion
                        }
                    }
                }
                echo "</div class='row'>";
            }
        }

        if (sizeof($inputs) > 0) {
            echo "<div class='col-lg-12 no-padding' style='margin-top:5px;'>";
            echo "<div class='alert alert-info-dot'>";
            echo "<h4 class='text-left'>additional values</h4>";
            echo "<table class='table table-condensed'>";
            echo "<tr>";
            foreach ($inputs as $eName => $eStr) {
                echo "<td class='text-muted'>";
                echo $inputLabels[$eName];
                echo "</td>";
            }
            echo "</tr>";
            echo "<tr>";
            foreach ($inputs as $eName => $eStr) {
                echo "<td>";
                echo $eStr;
                echo "</td>";
            }
            echo "</div>";
            echo "</div>";
            echo "</tr>";
            echo "</table class='table table-condensed'>";
            echo "</div class='panel-default'>";
            echo "</div class='panel'>";
        }
        if (isset($previewJurnal) && sizeof($previewJurnal) > 0) {
            $headersJurnal = $previewJurnal['header'];
            foreach ($previewJurnal['jurnal'] as $cabangID => $subItems) {
                if (sizeof($subItems) > 0) {
                    $cabangNama = isset($previewJurnal['cabang'][$cabangID]) ? $previewJurnal['cabang'][$cabangID] : "";

                    echo "<h4 class='text-blue' style='text-align: left;margin-top: 10px;'><span class='fa fa-book'></span> preview journal entries ($cabangNama)</h4>";

                    echo "<div class='tabel table-responsive'>";
                    echo "<table class='table table-condensed'>";

                    echo "<tr bgcolor='#f0f0f0'>";
                    foreach ($headersJurnal as $key => $label) {
                        echo "<td>";
                        echo "$label";
                        echo "</td>";
                    }
                    echo "</tr>";

                    foreach ($subItems as $iSpec) {
                        echo "<tr>";
                        foreach ($headersJurnal as $key => $label) {
                            echo "<td style='text-align: left;'>";
                            echo formatField_he_format($key, $iSpec[$key]);
                            echo "</td>";
                            if (is_numeric($iSpec[$key])) {
                                if (!isset($total[$cabangID][$key])) {
                                    $total[$cabangID][$key] = 0;
                                }
                                $total[$cabangID][$key] += $iSpec[$key];
                            }
                        }
                        echo "</tr>";
                    }

                    echo "<tr style='font-size: 15px;font-weight: bold;'>";
                    foreach ($headersJurnal as $key => $label) {
                        echo "<td>";
                        if (isset($total[$cabangID][$key])) {
                            echo formatField_he_format($key, $total[$cabangID][$key]);
                        }
                        echo "</td>";
                    }
                    echo "</tr>";

                    echo "</table>";
                    echo "</div>";

                }
                else {
                    echo "<div class='text-center text-warning'>";
                    echo "- no journal affected by this transaction -<br><br>";
                    echo "</div class='text-center text-warning'>";
                }
            }
        }

        //            if ($selectAll) {
        //                echo "<button href='' type='submit'>GENERATE</button>";
        //                echo "</form>";
        //            }
        /* ---------------------------------------------------------------------------
        * tebus murah aktif akan nongol disini
         * belum selesai yuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        * ---------------------------------------------------------------------------*/
        // arrPrintKuning($tebusMurah);
        // arrPrintPink($tebusMurah);
        // cekKuning(count($tebusMurah));
        $tebusMurah_info = "";
        if (count($tebusMurah['parents'])) {
            $tebusMurah_info .= "<div style='margin: 0 5px;'>";
            $tebusMurah_info .= "<div class='text-uppercase text-bold text-left text-blue'>tebus murah</div>";
            // $tebusMurah_info .= "<div class='meta'>Minimal belanja</div>";
            $tebusMurah_info .= "<div style='overflow: hidden;'>";
            foreach ($tebusMurah['parents'] as $item) {
                $tbm_minim = $item['minim'];
                $tbm_persen = $item['persen'];
                $tbm_nilai = $item['nilai'];
                $tbm_minim_f = formatField_he_format("kredit_limit", $tbm_minim);
                $tbm_persen_f = formatField_he_format("persen", $tbm_persen);
                $tbm_nilai_f = formatField_he_format("harga", $tbm_nilai);

                $tebusMurah_info .= "<div class='row bg-danger' style='padding: 5px;'>";
                $tebusMurah_info .= "<div class='col-md-9 text-left'>Transaksi Minimal <b>Rp. $tbm_minim_f</b></div></div>";
                // $tebusMurah_info .= "<div class='col-md-4 text-right'>Transaksi Min<br><b>$tbm_minim_f</b></div> <div class='col-md-4 text-right'>Diskon <br><b>$tbm_persen_f%</b></div> <div class='col-md-4 text-right'>Diskon max<br><b>$tbm_nilai_f</b></div>";
                $tebusMurah_info .= "</div>";
                if (isset($tebusMurah['childs'][$tbm_minim])) {

                    foreach ($tebusMurah['childs'][$tbm_minim] as $item_c) {

                        $pnama = $item_c['produk_nama'];
                        $pharga = $item_c['produk_harga'];
                        $pharga_f = formatField_he_format("harga", $pharga);

                        // arrPrintHijau($item_c);

                        $tebusMurah_info .= "$pnama $pharga_f<br>";
                    }
                }
                else{
                    $tebusMurah_info .= "Produk tebus murah untuk transaksi $tbm_minim_f, belum disetting";
                }
            }
            $tebusMurah_info .= "</div>";
            $tebusMurah_info .= "</div>";
        }
        $infoFreeItems .= $tebusMurah_info;
        // arrPrintKuning($tebusMurah_info);
        /*memasukan info tebus murah ke kolom kanan shoping cart*/
        // $infoDiskonItems .= $tebusMurah_info;
        //right side info diskon

        if ($infoFreeItems != '') {
            echo "<script>
                    setTimeout(function(){
                        top.$('#container_information').html(\"$infoFreeItems\");
                    }, 400)
                </script>";
        }
        else {
            echo "<script>
                    setTimeout(function(){
                        top.$('#container_information').html('');
                    }, 400)
                </script>";
        }

        //right side info diskon
        if ($infoDiskonItems != '') {
            echo "<script>
                    setTimeout(function(){
                        top.$('.produk_diskon_list').html(\"$infoDiskonItems\");
                    }, 600)
                </script>";
        }
        else {
            echo "<script>
                    setTimeout(function(){
                        top.$('.produk_diskon_list').html('');
                    }, 600)
                </script>";
        }

        if ($selectAll) {
            //                echo "\n<script>
            //                 $('#select_all').on('change', function(){
            //                     if( $(this).is(':checked') ){
            //                        $('.checkbox_prd').prop('checked', true)
            //                     }
            //                     else{
            //                        $('.checkbox_prd').prop('checked', false)
            //                     }
            //                 });
            //                 $('.checkbox_prd').on('change', function(){
            //                        var arrCheckBoxed = $('.checkbox_prd');
            //                        jQuery.each(arrCheckBoxed, function(a,b){
            //                            if( $(b).is(':checked') ){
            //                                console.log( $(this).attr('id') );
            //                            }
            //                        })
            //                 })
            //                 </script>";
        }

        else {

            //                echo "<script>
            ////                        setTimeout( function(){
            ////                            top.checkerAddDiskonValidation()
            ////                            top.shoppingCartChangeTrigger()
            ////                        },1000)
            //                    </script>";
        }

    }
    else {

        echo "<div class='no-padding no-border'>";
        echo "<style>table.dataTable.compact tbody th, table.dataTable.compact tbody td { padding: 0px 0px; }</style>";
        echo "<style>table.dataTable.compact tbody td > input, table.dataTable.compact tbody td > span, table.dataTable.compact tbody td > select { border: 0px !important; }</style>";

        if ($cCode != "_TR_982") {
            echo "<div class='col col-md-12'>
                      <div class='col col-lg-6 col-md-6 col-xs-6 col-sm-6 text-bold text-black fa-2x text-left'>Jml.Items: 0 (0)</div>
                      <div class='col col-lg-6 col-md-6 col-xs-6 col-sm-6 text-bold text-green fa-2x text-right'>Rp. <span id='summaryTotalRupiah' class=''>0</span></div>
                  </div>";
        }
        else {
            echo "
                    <div class='col-md-12 col-lg-12 no-padding'>
                        <div style='margin-bottom: 15px;' class='label box-header bg-red text-bold'>
                            <h3>=== PEMBATALAN TRANSAKSI PENJUALAN ===</h3>
                            <h3 class='text-link text-bold'>SILAHKAN PILIH NOTA YANG AKAN DIBATALKAN</h3>
                        </div>
                    </div>
                ";
        }

        echo "<table class='table table-condensed no-padding table-bordered no-margin dataTable compact'>";
        echo "<thead>";

        if ($cCode != "_TR_982") {
            if (!$avoidRemove) {
                echo "<tr class='bg-grey-2'>";
                echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";

                echo "<div class='text-left'>";
                echo "<label><input type='checkbox' id='popup_qty' checked class=''> popUp Qty</label>";
                echo "</div>";

                echo "<div class='pull-left'>";
                echo "<r><b>ANDA BELUM MEMILIH PRODUK, SILAHKAN MEMILIH PRODUK DARI FORM SKU & NAMA ITEM DIBAWAH</b></r>";
                echo "</div>";


                echo "</td>";
                echo "</tr>";
            }
        }

        if (isset($itemLabels)) {
            if (sizeof($itemLabels) && (is_array($itemLabels)) && $showItems) {
                echo "<tr class='bg-grey-2 text-uppercase'>";
                echo "<th style='width:5px;' class='text-muted text-center'>";
                echo "#";
                echo "</th>";
                foreach ($itemLabels as $key => $label) {
                    if ($key == "jml" || $key == "qty" || $key == "qty_unit") {
                        echo "<th style='width:3%;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "barcode") {
                        echo "<th style='width:12%;max-width:80px;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "nama") {
                        echo "<th style='white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    elseif ($key == "satuan_factor_nama") {
                        echo "<th style='width:5%;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                    else {
                        echo "<th style='min-width:1%;white-space: nowrap;' class='$key text-muted text-center'>";
                        echo $label;
                        echo "</th>";
                    }
                }
                echo "</tr>";
            }
        }

        echo "</thead>";
        echo "<tbody>";


        //select produk dari baris shoppingcart
        if ($cCode != "_TR_982") {
            if (isset($itemLabels)) {
                if (sizeof($itemLabels) && (is_array($itemLabels)) && $showItems) {
                    echo "<style>
                        input.ns:focus {
                          background-color: yellow;
                          border: 2px gray dashed;
                        }
                    </style>";
                    echo "<tr class='bg-grey-2 text-uppercase hidden-xs hidden-sm'>";
                    echo "<td style='width:5px;padding: 4px;' class='text-center'>";
                    echo "<i style='font-size: 30px; margin-top: 1px;' class='fa fa-check-circle text-green'></i>";
                    echo "</td>";
                    foreach ($itemLabels as $key => $label) {
                        if ($key == "jml" || $key == "qty" || $key == "qty_unit") {
                            echo "<td style='max-width:5px;white-space: nowrap;padding: 4px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewQty' autocomplete='off' autocomplete='disable' tabindex='1000' onclick='this.select()' class='form-control ns text-center text-bold' value='1'>";
                            echo "</td>";
                        }
                        else if ($key == "barcode") {
                            echo "<td style='min-width:70px;max-width:80px;white-space: nowrap;padding: 4px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewSKU' list='new_sku' autocomplete='off' autocomplete='disable' class='form-control ns'>";
                            echo "</td>";
                        }
                        else if ($key == "nama") {
                            echo "<td style='min-width:150px;white-space: nowrap;padding: 4px;' class='$key text-muted text-center'>";
                            echo "<input id='addNewProduk' list='new_produk' autocomplete='off' autocomplete='disable' class='form-control ns'>";
                            echo "<div id='addNewProdukContent' style='min-width: 100px;max-width:250px;max-height: 300px;position: absolute;z-index: 1;' class=''></div>";
                            echo "</td>";
                        }
                        else if ($key == "satuan_factor_nama") {
                            echo "<td style='min-width:12px;white-space: nowrap;padding: 4px;' class='$key text-muted text-center'>";
                            //                            echo $label;
                            echo "</td>";
                        }
                        else {
                            echo "<td style='min-width:50px;white-space: nowrap;padding: 4px;' class='$key text-muted text-center'>";
                            //                            echo $label;
                            echo "</td>";
                        }
                    }
                    echo "</tr>";
                }
            }
        }


        echo "<tr class='bg-grey-2 text-uppercase'>";
        echo "<th style='width:5px;' class='text-muted text-center'>";
        echo "1";
        echo "</th>";
        foreach ($itemLabels as $key => $label) {
            if ($key == "jml" || $key == "qty" || $key == "qty_unit") {
                echo "<th style='max-width:5px;white-space: nowrap;' class='$key text-muted text-center'>";
                echo "0";
                echo "</th>";
            }
            elseif ($key == "barcode") {
                echo "<th style='min-width:70px;max-width:80px;white-space: nowrap;' class='$key text-muted text-center'>";
                echo "123456789";
                echo "</th>";
            }
            elseif ($key == "nama") {
                echo "<th style='min-width:150px;white-space: nowrap;' class='$key text-muted text-center'>";
                echo "<span class='text-link' onclick=\"$('#itemKeyword').focus();$('#itemKeyword').click()\">SILAHKAN PILIH PRODUK</span>";
                echo "</th>";
            }
            elseif ($key == "satuan_factor_nama") {
                echo "<th style='min-width:12px;white-space: nowrap;' class='$key text-muted text-center'>";
                echo "n/a";
                echo "</th>";
            }
            else {
                echo "<th style='min-width:50px;white-space: nowrap;' class='$key text-muted text-center'>";
                echo "0";
                echo "</th>";
            }
        }
        echo "</tr>";
        echo "</tbody>";

        if (isset($sumRows) && sizeof($sumRows) > 0) {
            $nr = 0;
            foreach ($sumRows as $key => $label) {
                $val = 0;
                $nr++;
                $bottom_borderless = $nr < sizeof($sumRows) ? "bottom-borderless" : "";
                if (isset($main[$key]) && $main[$key] > 0) {
                    $val = $main[$key];
                }
                else {
                    if (isset($addValues[$key]) && $addValues[$key] > 0) {
                        $val = $addValues[$key];
                    }
                }
                if ($showItems) {
                    echo "<tr class=''>";
                    echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right $bottom_borderless valign-m text-uppercase text-bold text-muted'>$label &nbsp; &nbsp; &nbsp;</td>";
                    echo "<td colspan='3' class='right-borderless'>";
                    echo "<input type='text' id='$key' class='form-control text-right text-bold' readonly value='" . number_format($val) . "' >";
                    echo "</td>";
                    echo "</tr>";
                }
            }
        }
        if (isset($sumRows2) && sizeof($sumRows2) > 0) {
            echo "<tr bgcolor='#e0e0e0'>";
            echo "<td colspan='" . (sizeof($itemLabels2) + 1) . "' class='text-left text-muted'><span class='fa fa-cog'></span> additional fees</td>";
            echo "</td>";
            echo "</tr>";
            $nr = 0;
            foreach ($sumRows2 as $key => $label) {
                $nr++;
                $bottom_borderless = $nr < sizeof($sumRows2) ? "bottom-borderless" : "";

                echo "<tr bgcolor='#f0f0f5'>";
                echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right bottom-borderless valign-m text-uppercase'>$label</td>";
                echo "<td>";
                echo $sumSpec2[$key];
                echo "</td>";
                echo "</tr>";
            }
        }

        //            if (sizeof($addRows) > 0 ) {
        //                $nr = 0;
        //                foreach ($addRowLabels as $k => $label) {
        //                    $nr++;
        //                    $bottom_borderless = $nr < sizeof($addRowLabels) ? "bottom-borderless" : "";
        //                    $rowHide = isset($addRowHiddens[$k]) ? $addRowHiddens[$k] : "";
        //                    echo "<tr addRows class='$rowHide'>";
        //                    echo "<td colspan='" . sizeof($itemLabels) . "' class='text-right $bottom_borderless valign-m text-uppercase text-bold text-muted'>$label &nbsp; &nbsp; &nbsp;</td>";
        //                    echo "<td colspan='2' class='text-right'>";
        //                    echo $addRows[$k];
        //                    echo "</td>";
        //                    echo "</tr>";
        //                }
        //            }

        $info_customer = 1;
        if ($info_customer) {
            echo "<tr class='bg-grey'>";
            echo "<td colspan='" . (sizeof($itemLabels) + 2) . "'>";
            echo "<div class='text-left bg-grey' style='hheight: 80px;'><div>$str_customer</div></div>";
            echo "</td>";
            echo "</tr>";
        }

        echo "</table class='table'>";
        echo "</div class='table-responsive'>";

        //================
    }
    $sessionCleares = array("errLines", "errFields", "errMsg");
    foreach ($sessionCleares as $s) {
        if (isset($_SESSION[$s])) {
            unset($_SESSION[$s]);
        }
    }
    if (isset($cellID)) {
        echo "\n<script>
                var rows_tr_$cellID = $('tr#tr_$cellID').addClass('bg-yellow');
                setTimeout(function() {
                   $(rows_tr_$cellID).removeClass('bg-yellow');
                }, 2000);
            </script>\n";
    }
    if ($cCode == "_TR_982") {

    }
    else {
        echo "<script>$(document).ready( function(){ top.initAllEvent(); } );</script>";
    }

    // if(isset($pilih_diskon)){
    // }
    // $link_diskon_off = MODUL_PATH . get_class($this) . "diskon_off";
    $link_diskon_off = MODUL_PATH . "_shoppingCart/diskon_off/$jenisTr";
    echo "<script>
         // $('#search_result').load('$link_diskon_off?n='+n+'&t='+t);
       function diskon_off(n,t) {
         $('#result').load('$link_diskon_off?n='+n+'&t='+t);
         // document.location.reload();
       }

         // $('#search_result').load('$link_diskon_off?n='+n+'&t='+t);
       function diskon_off_r(n,t) {
         $('#result').load('$link_diskon_off?n='+n+'&t='+t);
         // document.location.reload();
         setTimeout(function (){
            showPembayaran();
         },500);

       }

       function txt_blur() {
         $('#discNilai').addClass('text-blur');
       }

       </script>";
}
//}
