<?php
/* 	
 * Author   : Dhidhik / Tanggal : 04-11-2015	
 * note     : 
 * Revisi   : 
 */
//---------Untuk privellege Print and export excel ----------//
if (isset($group_user)) {
    if ($group_user->PrintPrivillage == 1) {
        $cek_autority_print = "";
    } else {
        $cek_autority_print = "disabled";
    }

    if ($group_user->ExcelPrivillage == 1) {
        $cek_autority_excel = "";
    } else {
        $cek_autority_excel = "disabled";
    }
    if ($group_user->EditPrivillage == 1) {
        $cek_autority_edit = "";
    } else {
        $cek_autority_edit = "disabled";
    }
} else {
    $cek_autority_print = "disabled";
    $cek_autority_excel = "disabled";
    $cek_autority_edit = "disabled";
}
//---------END Untuk privellege Print and export excel ----------//
?>
<!--<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/custom/css/treetable/bootstrap.css">-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/custom/css/treetable/jquery.treegrid.css">
<script type="text/javascript" src="<?= base_url() ?>assets/custom/js/treetable/jquery.treegrid.bootstrap3.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/custom/js/treetable/jquery.treegrid.js"></script>
<style type="text/css">

    .margin-left5persen{
        margin-left:5%; 
    }
    .margin-right5persen{
        margin-right:5%; 
    }
    @media print {
        .noPrint { display: none; visibility: hidden; }
        .displayPrint{
            display: inline-block;
            left: 0px;
            position: fixed;
            background-color: white;
            width: 82%;
        }
        .layout-panel-west{display: none; visibility: hidden; }
        table{
            width: 100%;
        }       
    }
    /* style sheet for "A4" printing */
    @media print and (width: 21cm) and (height: 29.7cm) {
        @page {
            margin: 3cm;
        }
    }

    /* style sheet for "letter" printing */
    @media print and (width: 8.5in) and (height: 11in) {
        @page {
            margin: 1in;
        }
    }

    /* A4 Landscape*/
    @page {
        size: A4 landscape;
    }
</style>
<div id="cc" class="easyui-layout" data-options="fit:true, border:false">
    <div id="west-panel" data-options="region:'west',split:true,border:true" class="noPrint" title="Filter" style="width:190px;background-color:#CCCCFF;padding:5px;">
        <form class="form-filter noPrint" method="post" name="formFilterAmountItemCatgry" id="formFilterAmountItemCatgry" >
            <table width="100%" cellpadding="0" cellspacing="0">
                <!-------copy company dari sini------------------------------------------------------------------------>
                <tr>
                    <td align="left" style="padding-bottom:8px;">
                        <b>by Company</b>
                    </td>
                </tr>
                <tr>
                    <td align="left">                        
                        <select name="cmb_company" id="cmb_company" 
                                class="easyui-combobox" 
                                style="width:174px;"
                                data-options="
                                value:'<?php echo $this->session->userdata('company'); ?>',
                                valueField:'CompanyCode',
                                textField:'CompanyName',
                                url:'<?php echo base_url(); ?>custom/get_data/company_find_master',
                                onSelect: function(rec){
                                var url = '<?php echo base_url(); ?>custom/get_data/branch_by_company_new/'+rec.CompanyCode;
                                $('#cmb_branch').combobox('reload', url);
                                $('#cmb_branch').combobox('setValue', '');
                                }
                                "
                                editable="true">
                        </select>
                    </td>
                </tr>
                <!---end COMPANY select--------------------------------------------------------------------- -->

                <!--ini separator-------------------------------------------->
                <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                <!--end-------------------------------------------------------->

                <!-------copy branch dari sini------------------------------------------------------------------------>
                <tr>
                    <td align="left" style="padding-bottom:8px;">
                        <b>by Branch/Depo</b>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <select name="cmb_branch" id="cmb_branch" 
                                class="easyui-combobox" 
                                style="width:174px;"  
                                data-options="
                                value :'<?php echo $this->session->userdata('branch'); ?>',
                                valueField:'BranchCode', 
                                textField:'BranchName', 
                                url:'<?php echo base_url(); ?>custom/get_data/branch_by_company_new/<?php echo $this->session->userdata('company'); ?>'
                                " editable="true">
                        </select>
                    </td>
                </tr>
                <!------------end copy branch dari sini---------------------------------------------------------------->

                <!--ini separator-------------------------------------------->
                <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                <!--end-------------------------------------------------------->

                <!-----------------find by date------------------------------------------------------------------------>
                <tr>
                    <td style="padding-bottom:8px;">
                        <b>by Date</b>
                        <input type="checkbox" name="chk_ByDateNew" value="1" id="chk_ByDateNew" style="float:right;" checked disabled />
                    </td>
                </tr>
                <tr>
                    <td>
                        From
                        <span style="float:right;">
                            <input name="txt_DateFrom" id="txt_DateFrom" type="text" class="easyui-datebox " style="width:100px;height:22px;" editable="false" disabled />
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>
                        To
                        <span style="float:right;">
                            <input name="txt_DateTo" id="txt_DateTo" type="text" class="easyui-datebox " style="width:100px;height:22px;" editable="false" disabled />
                        </span>
                    </td>
                </tr>
                <!----------------------------------------------end-------------------------------------------------------------->

                <!--ini separator-------------------------------------------->
                <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                <!--end-------------------------------------------------------->

                <!-------copy item dari sini------------------------------------------------------------------------>
                <tr>
                    <td align="left" style="padding-bottom:8px;">
                        <b>by Categori Item</b>
                    </td>
                </tr>
                <tr>                    
                    <td align="left">
                        <input id="txt_itemCat" name="txt_itemCat" placeholder="< Item Categori Name >" style="margin:2px 0px 3px;width:100%;height:18px;border:1px solid #CCC;">
                    </td>
                </tr>
                <!------------end copy item dari sini---------------------------------------------------------------->

                <!--ini separator-------------------------------------------->
                <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                <!--end-------------------------------------------------------->

                <!-------copy branch dari sini------------------------------------------------------------------------>
                <tr>
                    <td align="left" style="padding-bottom:8px;">
                        <b>Data in </b>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <select name="cmb_collapse" id="cmb_collapse" 
                                class="easyui-combobox" 
                                style="width:174px;"  
                                editable="false">
                            <option value="collapseAll" selected > Collapse </option>
                            <option value="expandAll"> Expand </option>
                        </select>

                    </td>
                </tr>
                <!------------end copy branch dari sini---------------------------------------------------------------->

                <!--ini separator-------------------------------------------->
                <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                <!--end-------------------------------------------------------->

                <!----------------------------------ini by status---------------------------------------------------------->
<!--                <tr>
                    <td style="padding-bottom:8px;"><b>by Status Category</b></td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="chk_TransStatus" value="1" style="margin-left:0px;" checked /> On Active
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="chk_TransStatus" value="3" style="margin-left:0px;"  /> Non Active
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="chk_TransStatus" value="4" style="margin-left:0px;"  /> Need App. Dir
                    </td>
                </tr>-->

                <tr class="divTranstatus">
                    <td></td>
                </tr>
                <!------------------------------------------------------end by status-------------------------------------------------------------------------------------------->

                <!--copy dari sini untuk button reset dan search-->
                <tr>
                    <td height="38">
                        <div style="float:right;">
                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onClick="location.reload();" >Reset</a>
                            <a id="btn-search" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onClick="searching_data_sales_amount_item('', '');" >Search</a>
                        </div>
                    </td>
                </tr>
                <!--end copy dari sini untuk button reset dan search-------------------------->

            </table>
        </form>
    </div>

    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
        <div style="padding:2px" id="form-header">
            <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-print'" onClick="window.print_detail()" <?= $cek_autority_print ?>>Print</a>
            &nbsp;&nbsp;           
            <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-excel'" onclick="actionExcel()" <?= $cek_autority_excel ?>>Export File </a>
            &nbsp;&nbsp;           
            <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload();">Refresh</a>
        </div><br />
        <div id="databox" class="displayPrint">

        </div>	
    </div>

</div>

<script type="text/javascript">
    var shortingText = "";
    var rstTypeShorting = "ASC";
    var pre_url = base_url + 'report/index_sales/pre_ajax_reloadDataSalesAmountItemCategory';
    var url = base_url + 'report/index_sales/ajax_reloadDataSalesAmountItemCategory';
    var dataSend = {};
    var noTree = 1;
    var stringHTML = "";
    var pages = {limit: limitRowInPage(), pages: 1};
    function variableDefault() {
        shortingText = "";
        rstTypeShorting = "ASC";
        dataSend = {};
        noTree = 1;
        stringHTML = "";
        pages['pages'] = 1;
    }

    function checkShorting(txtCheckShorting) {
        if (shortingText == txtCheckShorting) {
            rstTypeShorting == "DESC" ? rstTypeShorting = "ASC" : rstTypeShorting = "DESC";
        } else {
            rstTypeShorting = "ASC";
            shortingText = txtCheckShorting;
        }
        //alert("cek="+txtCheckShorting+"-"+rstTypeShorting);
        return rstTypeShorting;
    }
    function startLoad() {
        //========load tanggal=============//
        $('#txt_DateFrom').datebox('enable', true);
        $('#txt_DateTo').datebox('enable', true);

        if ($('#txt_DateFrom').datebox('getValue') == "" || $('#txt_DateFrom').datebox('getValue') == undefined) {
            $('#txt_DateFrom').datebox('setValue', '<?= date('01-m-Y') ?>');
            $('#txt_DateTo').datebox('setValue', 'today');
        }
        //========END load tanggal=============//        

        var searchParameter = {};

        if ($('#cmb_company').length > 0) {
            searchParameter['cmb_company'] = $('#cmb_company').combobox('getValue');
        }
        if ($('#cmb_branch').length > 0) {
            searchParameter['cmb_branch'] = $('#cmb_branch').combobox('getValue');
        }

        searchParameter['chk_TransStatus'] = new Array();
        $.each($('input[name="chk_TransStatus"]:checked'), function () {
            searchParameter['chk_TransStatus'].push($(this).val());
        });

        if ($('#txt_DateFrom').length > 0) {
            searchParameter['txt_DateFrom'] = $('#txt_DateFrom').datebox('getValue');
            searchParameter['txt_DateTo'] = $('#txt_DateTo').datebox('getValue');
        }

        return searchParameter;
    }
    $(document).ready(function () {
        //============= transtatus ========================//
        var listTrans = [
            {"status": "all", "checked": ""},
            {"status": "master_active", "checked": "checked"},
            {"status": "master_nonactive", "checked": ""},
            {"status": "master_app_dir", "checked": ""}
        ];//daftar Transtatus yang dipakai, value parameter nya liat di custom js
        toHTMLTranstatusReport("divTranstatus", listTrans);//untuk memanggil html Transtatus        
        //============= end transtatus ========================//

        startLoad();//Load awal
        /*===chk_ByDateNew jangan lupa ganti ============*/
        $('#chk_ByDateNew').click(function () {
            if ($(this).is(':checked')) {
                $('#txt_DateFrom').datebox('enable', true);
                $('#txt_DateTo').datebox('enable', true);
                $('#txt_DateFrom').datebox('setValue', '<?= date('01-m-Y') ?>');
                $('#txt_DateTo').datebox('setValue', 'today');
            }
            else {
                $('#txt_DateFrom').datebox('disable', true);
                $('#txt_DateTo').datebox('disable', true);
                $('#txt_DateFrom').datebox('setValue', '');
                $('#txt_DateTo').datebox('setValue', '');
            }

        });
        /*==================end=========================*/
    });

    function searching_data_sales_amount_item(txtTable, txtFieldShorting) {//(namaVariableTabelDiModel, namaField)
        variableDefault();
        var getValue = startLoad();
        var typeShorting = checkShorting(txtFieldShorting);
        var dataIn = $('#cmb_collapse').combobox('getValue');

        dataSend = {
            pages: pages,
            predata: [],
            cmb_company: getValue['cmb_company'] == undefined ? "" : getValue['cmb_company'],
            cmb_branch: getValue['cmb_branch'] == undefined ? "" : getValue['cmb_branch'],
            txt_itemCat: document.formFilterAmountItemCatgry.txt_itemCat.value,
            txt_DateFrom: getValue['txt_DateFrom'],
            txt_DateTo: getValue['txt_DateTo'],
            chk_TransStatus: getValue['chk_TransStatus'],
            txtTable: txtTable,
            txtField: txtFieldShorting,
            typeShorting: typeShorting,
            dataIn: dataIn
        };
        if ($('#cmb_branch').combobox('getValue') == undefined) {
            $('#cmb_branch').combobox('clear');
        }
        if ($('#cmb_company').combobox('getValue') == undefined) {
            $('#cmb_company').combobox('clear');
            var strAlert = strMessageAlert_report('companyIsEmpty');
            messageAlertBiasa('Warning', strAlert, 'error');
        }
        else if (strDateIndToEng(dataSend['txt_DateFrom']) > strDateIndToEng(dataSend['txt_DateTo'])) {
            var strAlert = strMessageAlert_report('dateFrom>dateTo');
            messageAlertBiasa('Warning', strAlert, 'error');
        } else {
            modal_open('Progress Bar', 'dlg_loading');
            $.post(pre_url, dataSend).done(function (pre_result) {//preAjax
                var stringHTML = "";   // untuk menyimpan yang akan ditampilkan ke layar
                var preResult = JSON.parse(pre_result);
                var dataTopHeader = {
                    CompanyName: preResult.company.CompanyName,
                    BranchName: preResult.company.BranchName == undefined || preResult.company.BranchName == "" ? "All Branch" : preResult.company.BranchName,
                    reportLabel: " Sales Amount Item Category ",
                    startdate: preResult.startdate,
                    enddate: preResult.enddate,
                    colspan: 15
                };
                stringHTML += tableHTMLTopHeaderReport(dataTopHeader);//topHeader
                if (preResult.datas != 0) {//jika pre ajax data ada 
                    //Array Pre_result diambil code nya saja
                    var pre_arData = [];
                    preResult.datas.forEach(function (pre_dtResults) {//untuk mempersiapkan pre Array utk search
                        var pre_code = pre_dtResults['code'];
                        pre_arData.push(pre_code);
                    });
                    dataSend['predata'] = pre_arData;//isi preArray dengan value baru
                    //End Array Pre_result diambil code nya saja

                    $.post(url, dataSend).done(function (result) {//loadAjax
                        var parseResult = JSON.parse(result);
                        //console.log("parseResult="+JSON.stringify(parseResult)); 
                        var arTempDatas = [];   // temporer untuk menyimpan   
                        //=== JIKA DATA DITEMUKAN ========================================//
                        if (parseResult.datas != 0) {
                            //console.log("arTempDatas="+JSON.stringify(arTempDatas));
                            arTempDatas = prepareReport(parseResult);
                            stringHTML += createReport(arTempDatas);
                            pages['pages'] = (pages['pages'] * 1) + 1;
                        }//=== END JIKA DATA DITEMUKAN ===================================//
                        else {
                            stringHTML += tableHTMLNotFound();
                        }
                        //console.log("arTempDatas="+JSON.stringify(arTempDatas));
                        $("#databox").html(stringHTML);
                        modal_close('dlg_loading');
                    }, 'json');
//                modal_close('dlg_loading');
                } else {
                    stringHTML += tableHTMLNotFound();
                    $("#databox").html(stringHTML);
                    modal_close('dlg_loading');
                }
            }, 'json');
        }
    }

    function print_detail() {
        //var opt_print   = $("input[type='radio'][name='opt_print']:checked").val();
        var data_print = $("#databox").html();
        Popup(data_print);

    }
    function Popup(data) {
        var mywindow = window.open('', 'print-container', 'height=528,width=700');
        //var css = '<link rel="stylesheet" href="<?php echo base_url() ?>assets/custom/css/print.css" type="text/css" />';        
        var css = '<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>assets/custom/css/treetable/jquery.treegrid.css">';
        var varCSS = "<style>table{width: 100%;"
                + "font-family: 'Times New Roman';"
                + "font-size: small;"
                + "}"
                + ".thead{border:1px solid #333333;} .margin-left5persen{margin-left:0px;} .margin-right5persen{margin-right:0px;}"
                + ".table-summary{width:auto;}</style>";
        mywindow.document.write('<html><head><title>Print Detail</title>');
        mywindow.document.write(varCSS);
        mywindow.document.write(css);
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');

        mywindow.document.close(); // necessary for IE >= 10
        mywindow.focus(); // necessary for IE >= 10

        mywindow.print();
        mywindow.close();

        return true;
    }
    function actionExcel() {
        var htmls = "";
        var delRow = "";
        htmls = $('#databox').html();
        htmls = htmls.replace(/<table border='0' /gi, "<table border='1' ");
        htmls = htmls.replace(/<table border="0" /gi, "<table border='1' ");
        htmls = htmls.replace(/border='0'/gi, " ");
        htmls = htmls.replace(/'s0 text-center'/gi, "'s0 text-center' style='font-size:7;text-align: center;font-weight: bold;' ");
        htmls = htmls.replace(/'s1 text-center'/gi, "'s1 text-center' style='font-size:9;text-align: center;font-weight: bold;' ");
        htmls = htmls.replace(/'s2'/gi, "'s2' style='text-align: center;font-weight: bold;' ");
        htmls = htmls.replace(/id='tableHeader'/gi, " style='-webkit-print-color-adjust:exact;background-color:#d5d5d5;' ");
        htmls = htmls.replace(/<script/gi, " ");
        delRow = ">$(document).ready(function () {    $('.tree-2').treegrid({        expanderExpandedClass: ' treegrid-expander-expanded ',        expanderCollapsedClass: 'treegrid-expander-collapsed'    });    $('.tree-2').treegrid('";
        htmls = htmls.replace(delRow, " ");
        delRow = "collapseAll');});</";
        htmls = htmls.replace(delRow, " ");
        delRow = "expandAll');});</";
        htmls = htmls.replace(delRow, " ");
        htmls = htmls.replace(/script>/gi, " ");
        delRow = '';
        htmls = htmls.replace(/display: none;/gi, " ");

//        delRow="<tr>"
//            +"<td class='s5' align='right' colspan='8'><hr></td>"
//            +"</tr>";
//        htmls = htmls.replace(delRow, " ");
        //console.log("htmls = "+htmls);
        exportToExcel(htmls);
    }

    function prepareReport(parseResult) {
        var tempItemCode = "";
        var arTempDatas = [];
        // === LOOP PEMBACAAN DATA ===================================//
        parseResult.datas.forEach(function (dtResults) {
            if (tempItemCode == "") {//PEMBACAAN DATA PERTAMA KALI
                tempItemCode = dtResults.ItemCode;
                var dataJSONLevel1_2 = arJSONLevel1_2(dtResults);
                arTempDatas.push(dataJSONLevel1_2);
            }
            else {//PEMBACAAN DATA UNTUK DATA SETERUSNYA
                var indexCategoryCode = cekArraySummary(arTempDatas, "ItemCategoryID", dtResults.ItemCategoryID);//mendapatkan index array itemCategory
                if (indexCategoryCode > -1) {
                    var indexItemCode = cekArraySummary(arTempDatas[indexCategoryCode]['data'], "ItemCode", dtResults.ItemCode);//mendapatkan index array item
                    if (indexItemCode > -1) {//jika item ditemukan data yg sama
                        var dataJSONLevel3 = arJSONLevel3(dtResults);
                        dtResults.CurrencyCode != "IDR" ? arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] * 1) + ((dtResults.ItemAmount * 1) * dtResults.CurrencyRate * 1) : arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] * 1) + (dtResults.ItemAmount * 1);
                        //arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] =(arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmount'] * 1) + (dtResults.ItemAmount * 1);
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQty'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQty'] * 1) + (dtResults.ItemQty * 1);

                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQtyReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQtyReturn'] * 1) + (dtResults.QtyReturn * 1);
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQtyBookReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalQtyBookReturn'] * 1) + (dtResults.QtyBookReturn * 1);
//                                arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn'] =(arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn']*1) +((dtResults.QtyReturn * dtResults.ItemPrice)+(dtResults.QtyBookReturn * dtResults.ItemPrice)*dtResults.CurrencyRate);
//                                    arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn'] * 1) + ((dtResults.QtyReturn * dtResults.ItemPrice) * dtResults.CurrencyRate);
//                                    arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountBookReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountBookReturn'] * 1) + ((dtResults.QtyBookReturn * dtResults.ItemPrice) * dtResults.CurrencyRate);
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountReturn'] * 1) + (dtResults.totalReturn);
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountBookReturn'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalAmountBookReturn'] * 1) + (dtResults.totalReturnNotApp);
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalCOGS'] = (arTempDatas[indexCategoryCode]['data'][indexItemCode]['TotalCOGS']*1)+((dtResults.ItemPriceCogs * 1) * (dtResults.ItemQty * 1)),
                        arTempDatas[indexCategoryCode]['data'][indexItemCode]['data'].push(dataJSONLevel3);
                        //console.log('indexSICode='+indexSICode);
                    } else {
                        var dataJSONLevel2 = arJSONLevel2(dtResults);
                        arTempDatas[indexCategoryCode]['data'].push(dataJSONLevel2);
                    }
                } else {
                    var dataJSONLevel1_2 = arJSONLevel1_2(dtResults);
                    arTempDatas.push(dataJSONLevel1_2);
                }
            }//END PEMBACAAN DATA UNTUK DATA SETERUSNYA
        });// === END LOOP PEMBACAAN DATA ============================/    
        return arTempDatas;
    }
    function createReport(arTempDatas) {
        var tempStringHtml = "";
        tempStringHtml += createRowReport(arTempDatas);
        tempStringHtml += tableHTMLBlankForNext();
        tempStringHtml += "</table><script>"
                + "$(document).ready(function () {"
                + "    $('.tree-2').treegrid({"
                + "        expanderExpandedClass: ' treegrid-expander-expanded ',"
                + "        expanderCollapsedClass: 'treegrid-expander-collapsed'"
                + "    });"
                + "    $('.tree-2').treegrid('" + dataSend['dataIn'] + "');"
                + "});"
                + "</script" + ">";
        tempStringHtml += stringLegend();
        return tempStringHtml;
    }
    function createRowReport(arTempDatas) {
        var tempStringHtml = "";
        var tempTotalFooter = {tempTotalQ: 0, tempTotalQR: 0, tempTotalQBR: 0, tempTotalAR: 0,tempTotalAmount: 0,tempTotalCOGS: 0};

        //MULAI LOOP UNTUK DAPAT NAMA CATEGORY  
        arTempDatas.forEach(function (arData) {
            var noContentItem = 1;
            if (noTree > 1 && noContentItem == 1 && pages['pages'] < 2) {
                tempStringHtml += tableHTMLFooterSummary(tempTotalFooter);//MEMBUAT FOOTER SUMARY
                tempTotalFooter = {tempTotalQ: 0, tempTotalQR: 0, tempTotalQBR: 0, tempTotalAR: 0, tempTotalABR: 0, tempTotalAmount: 0};
            }
            tempStringHtml += tableHTMLHeader(arData);//membuat tabel header
            var noUrutItem = 1;
            arData['data'].forEach(function (arDataItem) {//MULAI LOOP UNTUK DAPAT NAMA CUSTOMER
                var parentItem = noTree;
                var noUrutSI = 1;
                tempStringHtml += tableHTMLContentFirst(noTree, noUrutItem, arDataItem);
                noTree++;

                //==== akumulasi untuk total footer ====//
                tempTotalFooter['tempTotalQ'] = (tempTotalFooter['tempTotalQ'] * 1) + arDataItem['TotalQty'];
                tempTotalFooter['tempTotalQR'] = (tempTotalFooter['tempTotalQR'] * 1) + arDataItem['TotalQtyReturn'];
                tempTotalFooter['tempTotalQBR'] = (tempTotalFooter['tempTotalQBR'] * 1) + arDataItem['TotalQtyBookReturn'];
                tempTotalFooter['tempTotalAR'] = (tempTotalFooter['tempTotalAR'] * 1) + arDataItem['TotalAmountReturn'];
                tempTotalFooter['tempTotalABR'] = (tempTotalFooter['tempTotalABR'] * 1) + arDataItem['TotalAmountBookReturn'];
                tempTotalFooter['tempTotalAmount'] = (tempTotalFooter['tempTotalAmount'] * 1) + arDataItem['TotalAmount'];
                tempTotalFooter['tempTotalCOGS'] = (tempTotalFooter['tempTotalCOGS'] * 1) + (arDataItem['TotalCOGS']*1);
                //==== akumulasi untuk total footer ====//

                arDataItem['data'].forEach(function (arDataSI) {//MULAI LOOP UNTUK DAPAT NAMA SALES INVOICE  
                    tempStringHtml += tableHTMLContentOther(noTree, parentItem, noUrutSI, arDataSI);
                    noTree++;
                    noUrutSI++;
                });//END MULAI LOOP UNTUK DAPAT NAMA SALES INVOICE
                noUrutItem++;
            });
        });//END MULAI LOOP UNTUK DAPAT NAMA ITEM
        tempStringHtml += tableHTMLFooterSummary(tempTotalFooter);//MEMBUAT FOOTER SUMARY 
        tempStringHtml += "<tr id='tr-see-more'><td colspan='5'><br><br><input id='btn-see-more' name='btn-see-more' type='button' onclick='seeMore()' value=' See More ' style='cursor:pointer;'></td></tr>";
        return tempStringHtml;
    }
    function seeMore() {
        modal_open('Progress Bar', 'dlg_loading');
        $.post(pre_url, dataSend).done(function (pre_result) {//preAjax
            var preResult = JSON.parse(pre_result);
//            dataSend['predata'] = preResult.datas;
            if (preResult.datas != 0) {//jika pre ajax data ada                 
                //Array Pre_result diambil code nya saja
                var pre_arData = [];
                preResult.datas.forEach(function (pre_dtResults) {
                    var pre_code = pre_dtResults['code'];
                    pre_arData.push(pre_code);
                });
                dataSend['predata'] = pre_arData;//isi preArray dengan value baru
                //End Array Pre_result diambil code nya saja

                var prearTempDatas = [];
                var pre_stringHTML = "";
                $.post(url, dataSend).done(function (result) {//loadAjax
                    var parseResult = JSON.parse(result);
                    if (parseResult.datas != 0) {
                        //console.log("arTempDatas="+JSON.stringify(arTempDatas));
                        prearTempDatas = prepareReport(parseResult);
                        pre_stringHTML += createRowReport(prearTempDatas);
                        pre_stringHTML += tableHTMLBlankForNext();

                        pages['pages'] = (pages['pages'] * 1) + 1;
                        $("#tr-see-more").replaceWith("");//clear row button 
                        $("#rowBlankForNext").replaceWith(pre_stringHTML);//mengganti row blank dengan ros data page baru
                        var htmlDataBox = $("#databox").html();//mengambil html pada div #databox yg data sudah baru
                        $("#databox").html(htmlDataBox);//mengisi kembali div #databox agar Tree-nya dapat work                      
                    }
                    else {
                        $("#btn-see-more").prop("disabled", true);
                        $("#btn-see-more").val("Data Completed");
                    }
                    modal_close('dlg_loading');
                }, 'json');
            } else {
                $("#btn-see-more").prop("disabled", true);
                $("#btn-see-more").val("Data Completed");
                modal_close('dlg_loading');
            }
        }, 'json');
    }
    function tableHTMLNotFound() {
        var strHeader = "<tr><td colspan='15' class='s3' align='left'><b><u>_____</u></b></td></tr>"
                + "<tr id='tableHeader'>"//baris heading table
                + "<td width='' class='s4 text-left'><span class='small_bold' >No</span></td>"
                + "<td width='' class='s4 text-center'><span class='small_bold'>Item <br>Code</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Date</span></td>"
                + "<td width='' class='s4 text-center'><span class='small_bold'>No.Transaction</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Rate</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Price</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Qty</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Unit</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Qty Return App</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Qty Return <br>Not App</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Amount <br>Return</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>Amount <br>Return <br>NotApp</span></td>"
                + "<td width='' class='s4 text-right'><span class='small_bold' >Amount</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold'>COGS</span></td>"
                + "<td width='' class='s4 text-left'><span class='small_bold' >Status</span></td>"
                + "</tr>"
                + "<tr>"
                + "<td width='' class='s5 text-center' colspan='15' align='center'><span class='small_bold' >Data Not Found</span></td>"
                + "</tr></table>";
        return strHeader;
    }
    function tableHTMLHeader(data) {
        var strHeader = "<tr><td colspan='15'><br></td></tr><tr><td colspan='15'> </td></tr>"
                + "<tr><td colspan='15' class='s3' align='left'><a class='linkParentTab' href='#'onclick=\"parent.tab_edit('Edit Item Category', 'list/item_categories', 'icon-edit', 'edit', '" + data.ItemCategoryID + "')\" <?= $cek_autority_edit ?>><u><b>[" + data.ItemCategoryID + "] </b> - " + data.ItemCategoryName + "</u></a></td></tr>"
                + "<tr id='tableHeader'>"//baris heading table
                + "<td width='' class='s4'><span class='small_bold' >No</span></td>"
                + "<td width='80' class='s4 linkParentTab' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_sinvdetail','ItemCode');\"><span class='small_bold'>Code Item</span></td>"
                + "<td width='80' class='s4 linkParentTab' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_salesinvoice','SInvDate');\"><span class='small_bold'>Date</span></td>"
                + "<td width='' class='s4 linkParentTab' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_salesinvoice','SInvNumber');\"><span class='small_bold'>No.Transaction</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Rate</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Price</span></td>"
                + "<td width='' class='s4 linkParentTab' align='right' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_sinvdetail','ItemQty');\"><span class='small_bold'>Qty</span></td>"
                + "<td width='' class='s4 linkParentTab' align='right' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_sinvdetail','ItemUnit');\"><span class='small_bold'>Unit</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Return <br>App</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Return <br>NotApp</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Amount <br>Return</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>Amount <br>Return <br> NotApp</span></td>"
                + "<td width='' class='s4 linkParentTab' align='right' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_sinvdetail','ItemAmount');\"><span class='small_bold'>Amount</span></td>"
                + "<td width='' class='s4' align='right'><span class='small_bold'>COGS</span></td>"
                + "<td width='' class='s4 linkParentTab' align='right' style='cursor:pointer;' onclick=\"searching_data_sales_amount_item('at_salesinvoice','TransStatus');\"><span class='small_bold' >Status</span></td>"
                + "</tr>";
        return strHeader;
    }
    function tableHTMLContentFirst(noTree, noUrut, data) {
        var strContent = "<tr class='treegrid-" + noTree + "' style='-webkit-print-color-adjust:exact;background-color:#F4F4FF; font-weight: bold;'>"
                + "<td width='' class='s5'><span class='small_bold' >" + noUrut + "</span></td>"
                + "<td width='' class='s5' colspan='4'><span class='small_bold' ><a class='linkParentTab' href='#'onclick=\"parent.tab_edit('Edit Item', 'list/items', 'icon-edit', 'edit', '" + data.ItemCode + "')\" <?= $cek_autority_edit ?>><b>[" + data.ItemCode + "] </b> - " + data.ItemDesc + "</a></span></td>"

                + "<td width='' class='s5' align='right'><span class='small_bold' ></span></td>"//Price
                + "<td width='' class='s5' align='right'><span class='small_bold' >" + formatRp(data.TotalQty) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' ></span></td>"//Unit

                + "<td width='' class='s5' align='right'><span class='small_bold' >" + formatRp(data.TotalQtyReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >" + formatRp(data.TotalQtyBookReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >Rp. " + formatRp(data.TotalAmountReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >Rp. " + formatRp(data.TotalAmountBookReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >Rp. " + formatRp(data.TotalAmount) + "</span></td>"

                + "<td width='' class='s5' align='right'><span class='small_bold' ></span></td>"//cogs
                + "<td width='' class='s5' align='right'><span class='small_bold' >" + data.itemTransStatus + "</span></td>"
                + "</tr>";
        return strContent;
    }
    function tableHTMLContentOther(noTree, noTreeParent, noUrut, data) {
        var strContent = "";
        strContent = "<tr  class='treegrid-" + noTree + " treegrid-parent-" + noTreeParent + "' style='-webkit-print-color-adjust:exact;background-color:#EAFFFB;'>"
                + "<td width='' class='s5'><span class='small_bold' >" + noUrut + "</span></td>"
                + "<td width='' class='s5'><span class='small_bold' ></span></td>"
                + "<td width='' class='s5'><span class='small_bold' >" + data.SInvDate + "</span></td>"
                + "<td width='' class='s5'><span class='small_bold' ><a class='linkParentTab' href=\"#\" onclick=\"parent.tab_edit('Edit Sales Invoice', 'list/sales_invoice', 'icon-edit', 'edit', '" + data.SInvNumber + "')\" <?= $cek_autority_edit ?>>" + data.SInvNumber + "</a></span></td>"

//        + "<td width='' class='s5' align='right'><span class='small_bold'>";
//        data.CurrencyCode!="IDR"?strContent +=formatRp(data.ItemAmount):strContent +="-";
//        strContent +="</span></td>"        

                + "<td width='' class='s5' align='right'><span class='small_bold'>";
        data.CurrencyCode != "IDR" ? strContent += formatRp(data.CurrencyRate) : strContent += "1";
        strContent += "</span></td>"//rate
                + "<td width='' class='s5' align='right'><span class='small_bold'>" + data.CurrencySymbol + " " + formatRp(data.ItemPrice) + "</span></td>"//price

                + "<td width='' class='s5' align='right'><span class='small_bold'>" + formatRp(data.ItemQty) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >" + data.ItemUnit + "</span></td>"

                + "<td width='' class='s5' align='right'><span class='small_bold'>" + formatRp(data.QtyReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'>" + formatRp(data.QtyBookReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'>Rp. " + formatRp(data.totalReturn) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'>Rp. " + formatRp(data.totalReturnNotApp) + "</span></td>"

                + "<td width='' class='s5' align='right'><span class='small_bold'>Rp. ";
        data.CurrencyCode != "IDR" ? strContent += formatRp(data.ItemAmount * data.CurrencyRate) : strContent += formatRp(data.ItemAmount);
        strContent += "</span></td>"

                + "<td width='' class='s5' align='right'><span class='small_bold'>Rp. " + formatRp((data.ItemPriceCogs * 1) * (data.ItemQty * 1)) + "</span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' >" + data.TransStatus + "</span></td>"
                + "</tr>";
        return strContent;
    }
    function tableHTMLFooter() {
        var strFooter = "<tr>"
                + "<td class='s5' align='right' colspan='15'><hr class='hrTableSummary'></td></tr>";
        return strFooter;
    }
    function tableHTMLFooterSummary(data) {
        var strFooter = "<tr>"
                + "<td class='s5' align='right' colspan='15'><hr class='hrTableSummary' style='size:3px;'></td></tr>"
                + "<tr><td class='s5' align='right' colspan='6'><b>TOTAL : </b></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' ><b>" + formatRp(data['tempTotalQ']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'><b></b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' ><b>" + formatRp(data['tempTotalQR']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold' ><b>" + formatRp(data['tempTotalQBR']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'><b>Rp. " + formatRp(data['tempTotalAR']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'><b>Rp. " + formatRp(data['tempTotalABR']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'><b>Rp. " + formatRp(data['tempTotalAmount']) + "</b></span></td>"
                + "<td width='' class='s5' align='right'><span class='small_bold'><b>Rp. " + formatRp(data['tempTotalCOGS']) + "</b></span></td>"
                + "</tr>";
        return strFooter;
    }
    function tableHTMLBlankForNext() {
        var strFooter = "<tr id='rowBlankForNext'>"
                + "<td class='s5' align='right' colspan='15'></td></tr>";
        return strFooter;
    }
    function summaryHTMLAll(tempBranch, alignTo, datas) {
        //console.log('datas='+datas);
        var strHeader = "<table align='" + alignTo + "' cellpadding='2' cellspacing='0' class='margin-" + alignTo + "5persen table-summary' style='margin-bottom:80px;'>"
                + "<tr id='tableHeader'>"
                + "<td width='' class='s4 text-center' colspan='6' align='center'><span class='small_bold' >Summary <u>" + tempBranch + "</u></span></td>"
                + "</tr>"
                + "<tr id='tableHeader'>"
                + "<td width='' class='s4 ' align='left'><span class='small_bold' >No &nbsp;&nbsp;</span></td>"
                + "<td width='' class='s4 ' align='left'><span class='small_bold' >Debt Receipt &nbsp;&nbsp;</span></td>"
                + "<td width='' class='s4 ' align='right'><span class='small_bold' >Debet &nbsp;&nbsp;</span></td>"
                + "<td width='' class='s4 ' align='right'><span class='small_bold' >Kredit &nbsp;&nbsp;</span></td>"
                + "<td width='' class='s4 ' align='right'><span class='small_bold' >Balance &nbsp;&nbsp;</span></td>"
                + "</tr>";
        var rowNo = 1;
        datas.forEach(function (data) {
            strHeader += "<tr>"
                    + "<td class='s5 text-left'><span class='small_bold' >" + rowNo + "</span></td>"
                    + "<td class='s5' align='left'><span class='small_bold' >" + data['EmployeeName'] + "</span></td>"
                    + "<td class='s5' align='right'><span class='small_bold' >" + formatRp(data['debt']) + " &nbsp;&nbsp;</span></td>"
                    + "<td class='s5' align='right'><span class='small_bold' >" + formatRp(data['payment']) + " &nbsp;&nbsp;</span></td>"
                    + "<td class='s5' align='right'><span class='small_bold' ><b>(" + formatRp(data['debt'] - data['payment']) + ") &nbsp;&nbsp;</b></span></td>"
                    + "</tr>";
            rowNo++;
        });

        strHeader += "</table>";
        return strHeader;
    }
    function arJSONLevel1_2(dtResults) {
        var tempData = {
            ItemCategoryID: dtResults.ItemCategoryID,
            ItemCategoryName: dtResults.ItemCategoryName,
            data: []
        };
        var ardatLevel2 = arJSONLevel2(dtResults);
        tempData['data'].push(ardatLevel2);
        return tempData;
    }
    function arJSONLevel2(dtResults) {
        var tempData = {
            ItemCode: dtResults.ItemCode,
            ItemDesc: dtResults.ItemDesc,
            TotalAmount: 0,
            TotalQty: 0,
            TotalQtyReturn: 0, //
            TotalQtyBookReturn: 0, //
            TotalAmountReturn: 0, //
            TotalCOGS: (dtResults.ItemPriceCogs * 1) * (dtResults.ItemQty * 1),
            itemTransStatus: dtResults.itemTransStatus,
            data: []
        };
        dtResults.CurrencyCode != "IDR" ? tempData['TotalAmount'] = (tempData['TotalAmount'] * 1) + ((dtResults.ItemAmount * 1) * dtResults.CurrencyRate * 1) : tempData['TotalAmount'] = (tempData['TotalAmount'] * 1) + (dtResults.ItemAmount * 1);
        //tempData['TotalAmount'] =(tempData['TotalAmount'] * 1) +(dtResults.ItemAmount * 1);
        tempData['TotalQty'] = (tempData['TotalQty'] * 1) + (dtResults.ItemQty * 1);
        tempData['TotalQtyReturn'] = (tempData['TotalQtyReturn'] * 1) + (dtResults.QtyReturn * 1);
        tempData['TotalQtyBookReturn'] = (tempData['TotalQtyBookReturn'] * 1) + (dtResults.QtyBookReturn * 1);
//        tempData['TotalAmountReturn']     =(tempData['TotalAmountReturn']*1) +((dtResults.QtyReturn * dtResults.ItemPrice)+(dtResults.QtyBookReturn * dtResults.ItemPrice)*dtResults.CurrencyRate);
//        tempData['TotalAmountReturn'] = (dtResults.QtyReturn * dtResults.ItemPrice) * dtResults.CurrencyRate;
//        tempData['TotalAmountBookReturn'] = (dtResults.QtyBookReturn * dtResults.ItemPrice) * dtResults.CurrencyRate;
        tempData['TotalAmountReturn'] = dtResults.totalReturn;
        tempData['TotalAmountBookReturn'] = dtResults.totalReturnNotApp;
        var ardatLevel3 = arJSONLevel3(dtResults);
        tempData['data'].push(ardatLevel3);
        return tempData;
    }
    function arJSONLevel3(dtResults) {
        var tempData = {
            SInvDetailID: dtResults.SInvDetailID,
            SInvDate: dtResults.SInvDate,
            SInvNumber: dtResults.SInvNumber,
            ItemPrice: dtResults.ItemPrice,
            ItemQty: dtResults.ItemQty,
            ItemUnit: dtResults.ItemUnit,
            ItemAmount: dtResults.ItemAmount,
            ItemCategoryCode: dtResults.ItemCategoryCode,
            ItemCategoryID: dtResults.ItemCategoryID,
            ItemPriceCogs: dtResults.ItemPriceCogs,
            CurrencySymbol: dtResults.CurrencySymbol,
            CurrencyCode: dtResults.CurrencyCode,
            CurrencyRate: dtResults.CurrencyRate,
            QtyReturn: dtResults.QtyReturn,
            QtyBookReturn: dtResults.QtyBookReturn,
//            totalReturn        : (dtResults.QtyReturn * dtResults.ItemPrice)+(dtResults.QtyBookReturn * dtResults.ItemPrice)*dtResults.CurrencyRate,
//            totalReturn: (dtResults.QtyReturn * dtResults.ItemPrice) * dtResults.CurrencyRate,
//            totalReturn         : (dtResults.QtyReturn * dtResults.ItemPrice) * dtResults.CurrencyRate,
//            totalReturnNotApp   : (dtResults.QtyBookReturn * dtResults.ItemPrice) * dtResults.CurrencyRate,
            totalReturn: dtResults.totalReturn,
            totalReturnNotApp: dtResults.totalReturnNotApp,
            TransStatus: dtResults.TransStatus
        };
        return tempData;
    }
    function stringLegend() {
        var strLgnd = {
            marginLeft: '2%',
            datas: [
                {boxColor: '#F4F4FF', strLabel: "Data Items"},
                {boxColor: '#EAFFFB', strLabel: "Data Sales Invoices"},
                {boxColor: '', strLabel: "'Date' : Tanggal Transaksi."},
                {boxColor: '', strLabel: "'No.Transaction' : Nomor Transaksi."},
                {boxColor: '', strLabel: "'Rate' : Currency Rate, yang akan bernilai 1 jika ber-currency 'IDR'."},
                {boxColor: '', strLabel: "'Price' : Harga Satuan Item, sudah termasuk 'Inclusive Tax' dan Discont Item (jika ada)."},
                {boxColor: '', strLabel: "'Qty' : Banyak Item."},
                {boxColor: '', strLabel: "'Unit' : Satuan Item."},
                {boxColor: '', strLabel: "'Return App' : Banyak Item yang di Retur yang 'Telah di Approve'."},
                {boxColor: '', strLabel: "'Return NotApp' : Banyak Item yang di Retur namun 'Belum di Approve'."},
                {boxColor: '', strLabel: "'Amount Return (Rp)' : Jumlah Nominal Rupiah dari item yang di 'Retur' dan yang 'Telah di Approve'. "},
                {boxColor: '', strLabel: "'Amount return NotApp (Rp)' : Jumlah Nominal Rupiah dari item yang di 'Retur', namun 'Belum di Approve'. "},
                {boxColor: '', strLabel: "'Amount (Rp)' : Jumlah Nominal Rupiah dari banyaknya Item yang bersangkutan, tetapi Belum Termasuk nominal item yang di Retur."},
                {boxColor: '', strLabel: "'COGS' : COGS(Harga Pokok Penjualan) per Invoice sesuai Item Barang yang bersangkutan."},
                {boxColor: '', strLabel: "'Status' : Status Item yang bersangkutan."}
            ]
        };
        var rst = legendsTable(strLgnd);
        return rst;
    }
</script>