<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once "Modul_Controller.php";

class Konversi extends Modul_Controller
{
    public function __construct()
    {
        parent::__construct();

        /* ----------------------------------------------------------------------------------
 * validasi session bila tidak ada dipaksa ke halaman login
 * ----------------------------------------------------------------------------------*/

    }

    public function index()
    {
        // arrPrint($this->session->login);
        $starttime = microtime(true);
        if (!isset($this->session->login['id'])) {
            redirect(base_url() . "Login");
        }
        $scriptBottom = "";
        $sesionReplacer = replaceSession();
        $jenisTr = $this->jenisTr;
        $cCode = $this->cCode;
        $paymentConfig = isset($this->configUi[$jenisTr]['paymentConfig']) ? $this->configUi[$jenisTr]['paymentConfig'] : false;
        $myPaymentConfig = isset($this->configUi[$jenisTr]['myPaymentConfig']) ? $this->configUi[$jenisTr]['myPaymentConfig'] : false;
        $historyFields = isset($this->configUi[$jenisTr]['shortHistoryFields']) ? $this->configUi[$jenisTr]['shortHistoryFields'] : array();
        $pairRegistries = isset($this->configUi[$jenisTr]['pairRegistries']) ? $this->configUi[$jenisTr]['pairRegistries'] : array();
        $connectTo = isset($this->configUi[$jenisTr]['connectTo']) ? $this->configUi[$jenisTr]['connectTo'] : "";
        $stepHistoryFields = isset($this->configUi[$jenisTr]['shortStepHistoryFields']) ? $this->configUi[$jenisTr]['shortStepHistoryFields'] : array();
        $mb = New MobileDetect();
        $isMob = $mb->isMobile();
        if ($isMob) {
            $historyFields = isset($this->configUi[$jenisTr]['compactHistoryFields']) ? $this->configUi[$jenisTr]['compactHistoryFields'] : array();
        }
        $prePreFields = $historyFields;
        $prePreFields['state'] = "status";
        $prePreFields['action'] = "action";
        $swapJenisTr = isset($this->configUi[$jenisTr]['requestCode']['masterCode']) ? $this->configUi[$jenisTr]['requestCode']['masterCode'] : array();
        $arrayOnprePre = array();
        $arrayOnprePreGroup = array();
        if (sizeof($swapJenisTr) > 0) {
            $steps = $this->configUi[$swapJenisTr]['steps'];
            $arrFilters = array();
            if (sizeof($steps) > 1) {
                $this->load->model("MdlTransaksi");
                $tr = new MdlTransaksi();
                $stepCodes = array();
                $jmlStep = count($steps);
                if (isset($this->accessList[$swapJenisTr]) && sizeof($this->accessList) > 0) {
                    $indsteps = "(";
                    foreach ($this->accessList[$swapJenisTr] as $stepNumber => $stepSpec) {
                        if ($stepNumber <= $jmlStep) {
                            foreach ($stepSpec as $targetCode => $filters) {
                                $indsteps .= "'$targetCode',";
                                $stepCodes[] = $targetCode;
                                if ($filters['allowFollowUp'] == "true") {
                                    $arrFilters["allowFollowUp"][] = $targetCode;
                                }
                            }
                        }
                    }
                    $indsteps = rtrim($indsteps, ",");
                    $indsteps .= ")";
                    if (sizeof($arrFilters) > 0) {
                        $tr->addFilter("next_step_code in $indsteps");
                    }
                    else {
                        $tr->addFilter("transaksi.oleh_id='" . $this->session->login['id'] . "'");
                    }
                }
                else {

                }
                $tr->addFilter("div_id='" . $this->session->login['div_id'] . "'");
                $tr->addFilter("jenis_top='" . $steps[1]['target'] . "'");
                $tr->addFilter("next_substep_code<>''");
                $tr->addFilter("sub_step_number>0");
                $tr->addFilter("valid_qty>0");
                $tmpHist = $tr->lookupRecentUndoneEntries_joined($sesionReplacer)->result();
                if (sizeof($tmpHist) > 0) {
                    $arrTransID = array();
                    $arrTransTopID = array();
                    $arrIdsHist = array();
                    $arrTransHist = array();
                    foreach ($tmpHist as $row) {
                        $arrTransID[] = $row->id;
                        $arrTransTopID[] = $row->id_top;

                        if ($row->ids_his != "") {
                            $hist = blobDecode($row->ids_his);
                            foreach ($hist as $hisSpec) {
                                $arrIdsHist[$row->id][$hisSpec['step']] = array(
                                    "step"  => $hisSpec['step'],
                                    "trID"  => $hisSpec['trID'],
                                    "nomer" => $hisSpec['nomer'],
                                );
                                $arrTransHist[] = $hisSpec['trID'];
                            }
                        }
                    }
                    $tmpReg_result = array();
                    $trReg = new MdlTransaksi();
                    $trReg->setFilters(array());
                    $trReg->addFilter("param='main'");
                    $trReg->addFilter("transaksi_id in ('" . implode("','", $arrTransID) . "')");
                    $tmpReg = $trReg->lookupRegistries()->result();

                    if (sizeof($tmpReg) > 0) {
                        foreach ($tmpReg as $regRow) {
                            $param = $regRow->param;
                            $tmpReg_result[$regRow->transaksi_id][$param] = blobDecode($regRow->values);
                        }
                    }

                    foreach ($tmpHist as $row) {
                        if (sizeof($pairRegistries) > 0) {
                            //                            $trReg = new MdlTransaksi();
                            //                            $trReg->setFilters(array());
                            //                            $trReg->addFilter("param in ('" . implode("','", $pairRegistries) . "')");
                            //                            $trReg->addFilter("transaksi_id='" . $row->transaksi_id . "'");
                            //                            $tmpReg = $trReg->lookupRegistries()->result();
                            //                            if (sizeof($tmpReg) > 0) {
                            //                                foreach ($tmpReg as $regRow) {
                            //                                    $param = $regRow->param;
                            //                                    $$param = blobDecode($regRow->values);
                            //                                }
                            //                                foreach ($pairRegistries as $eReg) {
                            //                                    foreach ($$eReg as $k => $v) {
                            //                                        if (!isset($row->$k)) {
                            //                                            $row->$k = $v;
                            //                                        }
                            //                                    }
                            //                                }
                            //                            }
                            if ((sizeof($tmpReg_result) > 0) && (isset($tmpReg_result[$row->id]))) {
                                foreach ($tmpReg_result[$row->id] as $param => $eReg) {
                                    foreach ($eReg as $k => $v) {
                                        if (!isset($row->$k)) {
                                            $row->$k = $v;
                                        }
                                    }
                                }
                            }
                        }

                        $tmp = array();
                        foreach ($historyFields as $fName => $fLabel) {
                            $tmp[$fName] = isset($row->$fName) ? formatField_he_format($fName, $row->$fName) : formatField_he_format($fName, 0);
                        }

                        //                        cekHijau('$swapJenisTr: ' . $swapJenisTr);

                        $showPoStatus = isset($this->configUi[$swapJenisTr]['showPoStatus']) ? $this->configUi[$swapJenisTr]['showPoStatus'] : array();
                        $cekStateLocation = ($this->session->login['cabang_id'] > 0) ? "cabang" : "pusat";

                        if ($row->sub_step_number > 0) {

                            $tmp['state'] = "<div class='panel panel-warning' style='padding: 3px;margin-bottom: 5px;' ><span style='color:" . $this->configUi[$swapJenisTr]['steps'][$row->sub_step_number]['stateColor'] . "'>" . $this->configUi[$swapJenisTr]['steps'][$row->sub_step_number]['stateLabel'] . "</span>";
                            $tmp['state'] .= "<br>" . createStateSign($row->sub_step_number, $row->step_avail, $swapJenisTr) . "</div>";

                            // cek PO
                            $arrTransactionSource = array();
                            $id_master = $row->id_master;
                            $id_top1 = $row->id_top;
                            $this->load->model("MdlTransaksi");
                            $l = new MdlTransaksi();
                            $l->setFilters(array());
                            $l->addFilter("transaksi_data.valid_qty>0");
                            $l->addFilter("id_master='" . $id_master . "'");
                            $l->addFilter("jenis_master='" . $swapJenisTr . "'");
                            $l->addFilter("link_id=0");
                            $tmpTS = $l->lookupJoined()->result();

                            $arrsub_step_number = array();
                            $arrstep_avail = array();
                            $arrext_blob = array();
                            $arrjenis_master = array();
                            $arrtransaksi_no = array();
                            $arrketerangan = array();

                            if (sizeof($tmpTS) > 0) {
                                foreach ($tmpTS as $kk => $arVL) {
                                    $id = $arVL->id;
                                    $id_master = $arVL->id_master;
                                    $id_top2 = $arVL->id_top;
                                    $produk_id = $arVL->produk_id;
                                    $arrTransactionSource[$id_top1] = $produk_id;
                                    $arrsub_step_number[$id_top1] = $arVL->sub_step_number;
                                    $arrstep_avail[$id_top1] = $arVL->step_avail;
                                    $arrext_blob[$id_top1][$kk] = isset($arVL->ext_blob) ? ($arVL->ext_blob != "" ? blobDecode($arVL->ext_blob) : "") : "";
                                }

                                if (sizeof($arrext_blob[$id_top1]) > 0) {
                                    foreach ($arrext_blob[$id_top1] as $ky => $aVal) {
                                        if ($aVal != "") {
                                            foreach ($arrext_blob[$id_top1][$ky]['static'] as $numb => $numData) {
                                                $arrtransaksi_no[$id_top1][$numb] = formatField_he_format("nomer", $numb);
                                                $arrjenis_master[$id_top1][$numb] = $numData['jenis'];
                                                $arrketerangan[$id_top1][$numb] = $numData['keterangan'];
                                            }
                                        }
                                    }
                                }
                            }

                            if ($arrext_blob[$id_top1][$ky] != "") {
                                $tmp['state'] .= "<div class='panel panel-danger bg-green' style='padding: 3px;margin-bottom: 5px;'>";
                                if ($cekStateLocation == "cabang") {
                                    $tmp['state'] .= "<div><b>diproses oleh PUSAT</b></div>";
                                }
                                if (sizeof($arrtransaksi_no[$id_top1]) > 0) {
                                    foreach ($arrtransaksi_no[$id_top1] as $numb_) {
                                        $tmp['state'] .= "<div><span class='fa fa-check-circle text-warning'></span> " . $numb_ . "</div>";
                                    }
                                }
                                $tmp['state'] .= "</div>";
                            }

                        }
                        else {
                            $tmp['state'] = "<span style='color:#777777'>canceled</span>";
                        }

                        $tmp['action'] = "";
                        $nextStepNum = ($row->next_substep_num);
                        $currentStepNum = ($row->sub_step_number);
                        $currentStepCode = ($row->jenis);
                        $nextStepCode = ($row->next_step_code);

                        if ($row->sub_step_number > 0) {
                            $allowFollowup = true;
                            $actionLabel = "review " . $this->configUi[$swapJenisTr]['steps'][$currentStepNum]['label'];
                        }

                        if (isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum])) {
                            if (isset($this->accessList[$jenisTr])) {
                                if (isset($this->accessList[$swapJenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"])) {
                                    $allowFollowup = $this->accessList[$swapJenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"];
                                    $actionLabel = $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['actionLabel'];
                                }
                            }
                            else {
                                if (in_array($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['userGroup'], $this->session->login['membership'])) {
                                    $allowFollowup = true;
                                    $actionLabel = $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['actionLabel'];
                                }
                                else {
                                    $allowFollowup = true;
                                    $actionLabel = "review " . $this->configUi[$swapJenisTr]['steps'][$currentStepNum]['label'];
                                }
                            }
                        }

                        if ($allowFollowup) {
                            $allowJoin = isset($this->configUi[$swapJenisTr]["steps"][$nextStepNum]['allowJoin']) && $this->configUi[$swapJenisTr]["steps"][$nextStepNum]['allowJoin'] == true ? $this->configUi[$jenisTr]["steps"][$nextStepNum]['allowJoin'] : false;
                            $stepLabel = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['label']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['label'] : "";
                            $isCancelPacking = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['isCancelPacking']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['isCancelPacking'] : false;
                            $allowCancel = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['allowCancel']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['allowCancel'] : false;

                            $targetFollowupLink = $isCancelPacking == true ? "followupCancelPackingPrePreview" : "followupPrePreview";
                            $followupLink = "top.$('#result').load('" . base_url() . "Transaksi/$targetFollowupLink/" . $row->transaksi_id . "/$nextStepNum/" . $row->sub_step_number . "');";

                            $tmp['action'] = "<div class='input-group'>";
                            $tmp['action'] .= "<a class='btn btn-primary btn-block' title='turn this entry into $stepLabel' href='JavaScript:void(0)' onClick =\"top.open_holdon();$followupLink\">" . $actionLabel . "</a>";
                            if ($allowJoin) {
                                $tmp['action'] .= "<span class='input-group-addon'>";
                                $tmp['action'] .= "<a title='process many items at once' href='" . base_url() . "Transaksi/viewIncomplete/" . $this->jenisTr . "/$currentStepNum'><span class='fa fa-dedent'></span></a>";
                                $tmp['action'] .= "</span class='input-group-addon'>";
                            }
                            $tmp['action'] .= "</div class='input-group'>";

                            if ($allowCancel) {
                                $tmp['action'] .= "<div class='input-group'>";
                                $tmp['action'] .= "<a class='btn btn-primary btn-block' title='turn this entry into $stepLabel' href='JavaScript:void(0)' onClick =\"top.open_holdon();$followupLink\">" . $actionLabel . "</a>";
                                if ($allowJoin) {
                                    $tmp['action'] .= "<span class='input-group-addon'>";
                                    $tmp['action'] .= "<a title='process many items at once' href='" . base_url() . "Transaksi/viewIncomplete/" . $this->jenisTr . "/$currentStepNum'><span class='fa fa-dedent'></span></a>";
                                    $tmp['action'] .= "</span class='input-group-addon'>";
                                }
                                $tmp['action'] .= "</div class='input-group'>";
                            }
                        }
                        else {

                        }
                        $arrayOnprePre[] = $tmp;
                        $arrayOnprePreGroup[$currentStepNum][] = $tmp;
                    }
                }
            }
            else {
                $arrayOnprePre = array();
            }
        }
        else {
            $arrayOnprePre = array();
        }
        //endregion prePre

        //region lookup preDistribution (khusus push PO distribution Supplies ke branch)
        $preDistributionFields = $historyFields;
        $preDistributionFields['state'] = "status";
        $preDistributionFields['action'] = "action";
        $swapJenisTr = isset($this->configUi[$jenisTr]['distributionCode']['masterCode']) ? $this->configUi[$jenisTr]['distributionCode']['masterCode'] : array();
        $arrayOnpreDistribution = array();
        $arrayOnpreDistributionGroup = array();
        if (sizeof($swapJenisTr) > 0) {

            $steps = $this->configUi[$swapJenisTr]['steps'];

            //            cekHere("swapJenisTr: " . $swapJenisTr);
            //            arrPrint($steps);

            $arrFilters = array();
            if (sizeof($steps) > 1) {

                $this->load->model("MdlTransaksi");
                $tr = new MdlTransaksi();
                $stepCodes = array();
                $jmlStep = count($steps);

                if (isset($this->accessList[$swapJenisTr]) && sizeof($this->accessList) > 0) {
                    $indsteps = "(";
                    foreach ($this->accessList[$swapJenisTr] as $stepNumber => $stepSpec) {
                        if ($stepNumber <= $jmlStep) {
                            foreach ($stepSpec as $targetCode => $filters) {
                                $indsteps .= "'$targetCode',";
                                $stepCodes[] = $targetCode;
                                if ($filters['allowFollowUp'] == "true") {
                                    $arrFilters["allowFollowUp"][] = $targetCode;
                                }
                            }
                        }
                    }
                    $indsteps = rtrim($indsteps, ",");
                    $indsteps .= ")";
                    if (sizeof($arrFilters) > 0) {
                        $tr->addFilter("next_step_code in $indsteps");
                    }
                    else {
                        $tr->addFilter("transaksi.oleh_id='" . $this->session->login['id'] . "'");
                    }
                }
                else {

                }

                $tr->addFilter("div_id='" . $this->session->login['div_id'] . "'");
                $tr->addFilter("jenis_top='" . $steps[1]['target'] . "'");
                $tr->addFilter("next_substep_code<>''");
                $tr->addFilter("sub_step_number>0");
                $tr->addFilter("valid_qty>0");

                $tmpHist = $tr->lookupRecentUndoneEntries_joined($sesionReplacer)->result();
                //                cekHitam($this->db->last_query());
                //                cekOrange("arrayOnpreDistribution");
                //                arrPrint($tmpHist);

                if (sizeof($tmpHist) > 0) {
                    foreach ($tmpHist as $row) {
                        if (sizeof($pairRegistries) > 0) {
                            $trReg = new MdlTransaksi();
                            $trReg->setFilters(array());
                            $trReg->addFilter("param in ('" . implode("','", $pairRegistries) . "')");
                            $trReg->addFilter("transaksi_id='" . $row->transaksi_id . "'");
                            $tmpReg = $trReg->lookupRegistries()->result();
                            if (sizeof($tmpReg) > 0) {
                                foreach ($tmpReg as $regRow) {
                                    $param = $regRow->param;
                                    $$param = blobDecode($regRow->values);
                                }
                                foreach ($pairRegistries as $eReg) {
                                    foreach ($$eReg as $k => $v) {
                                        if (!isset($row->$k)) {
                                            $row->$k = $v;
                                        }
                                    }
                                }
                            }
                        }

                        $tmp = array();
                        foreach ($historyFields as $fName => $fLabel) {
                            $tmp[$fName] = isset($row->$fName) ? formatField_he_format($fName, $row->$fName) : formatField_he_format($fName, 0);
                        }

                        if ($row->sub_step_number > 0) {
                            $tmp['state'] = "<span style='color:" . $this->configUi[$swapJenisTr]['steps'][$row->sub_step_number]['stateColor'] . "'>" . $this->configUi[$swapJenisTr]['steps'][$row->sub_step_number]['stateLabel'] . "</span>";
                            $tmp['state'] .= "<br>" . createStateSign($row->sub_step_number, $row->step_avail, $swapJenisTr);
                        }
                        else {
                            $tmp['state'] = "<span style='color:#777777'>canceled</span>";
                        }

                        $tmp['action'] = "";
                        $nextStepNum = ($row->next_substep_num);
                        $currentStepNum = ($row->sub_step_number);
                        $currentStepCode = ($row->jenis);
                        $nextStepCode = ($row->next_step_code);

                        if ($row->sub_step_number > 0) {
                            $allowFollowup = true;
                            $actionLabel = "review " . $this->configUi[$swapJenisTr]['steps'][$currentStepNum]['label'];
                        }

                        if (isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum])) {
                            if (isset($this->accessList[$jenisTr])) {
                                if (isset($this->accessList[$swapJenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"])) {
                                    $allowFollowup = $this->accessList[$swapJenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"];
                                    $actionLabel = $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['actionLabel'];
                                }
                            }
                            else {
                                if (in_array($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['userGroup'], $this->session->login['membership'])) {
                                    $allowFollowup = true;
                                    $actionLabel = $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['actionLabel'];
                                }
                                else {
                                    $allowFollowup = true;
                                    $actionLabel = "review " . $this->configUi[$swapJenisTr]['steps'][$currentStepNum]['label'];
                                }
                            }
                        }

                        if ($allowFollowup) {
                            $allowJoin = isset($this->configUi[$swapJenisTr]["steps"][$nextStepNum]['allowJoin']) && $this->configUi[$swapJenisTr]["steps"][$nextStepNum]['allowJoin'] == true ? $this->configUi[$jenisTr]["steps"][$nextStepNum]['allowJoin'] : false;
                            $stepLabel = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['label']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['label'] : "";
                            $isCancelPacking = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['isCancelPacking']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['isCancelPacking'] : false;
                            $allowCancel = isset($this->configUi[$swapJenisTr]['steps'][$nextStepNum]['allowCancel']) ? $this->configUi[$swapJenisTr]['steps'][$nextStepNum]['allowCancel'] : false;

                            $targetFollowupLink = $isCancelPacking == true ? "followupCancelPackingPrePreview" : "followupPrePreview";
                            $followupLink = "top.$('#result').load('" . base_url() . "Transaksi/$targetFollowupLink/" . $row->transaksi_id . "/$nextStepNum/" . $row->sub_step_number . "');";

                            $tmp['action'] = "<div class='input-group'>";
                            $tmp['action'] .= "<a class='btn btn-primary btn-block' title='turn this entry into $stepLabel' href='JavaScript:void(0)' onClick =\"top.open_holdon();$followupLink\">" . $actionLabel . "</a>";
                            if ($allowJoin) {
                                $tmp['action'] .= "<span class='input-group-addon'>";
                                $tmp['action'] .= "<a title='process many items at once' href='" . base_url() . "Transaksi/viewIncomplete/" . $this->jenisTr . "/$currentStepNum'><span class='fa fa-dedent'></span></a>";
                                $tmp['action'] .= "</span class='input-group-addon'>";
                            }
                            $tmp['action'] .= "</div class='input-group'>";

                            if ($allowCancel) {
                                $tmp['action'] .= "<div class='input-group'>";
                                $tmp['action'] .= "<a class='btn btn-primary btn-block' title='turn this entry into $stepLabel' href='JavaScript:void(0)' onClick =\"top.open_holdon();$followupLink\">" . $actionLabel . "</a>";
                                if ($allowJoin) {
                                    $tmp['action'] .= "<span class='input-group-addon'>";
                                    $tmp['action'] .= "<a title='process many items at once' href='" . base_url() . "Transaksi/viewIncomplete/" . $this->jenisTr . "/$currentStepNum'><span class='fa fa-dedent'></span></a>";
                                    $tmp['action'] .= "</span class='input-group-addon'>";
                                }
                                $tmp['action'] .= "</div class='input-group'>";
                            }
                        }
                        else {

                        }
                        $arrayOnpreDistribution[] = $tmp;
                        $arrayOnpreDistributionGroup[$currentStepNum][] = $tmp;
                    }
                }

            }
            else {
                $arrayOnpreDistribution = array();
            }

        }
        else {
            $arrayOnpreDistribution = array();
        }
        //        arrPrint($arrayOnpreDistribution);
        //endregion preDistribution
// cekMerah($jenisTr);
        //region lookup on-going transactions
        $progressFields = $historyFields;
        $progressFields['state'] = "status";
        $progressFields['action'] = "action";
        $steps = $this->configUi[$jenisTr]['steps'];

        $arrFilters = array();
        if (sizeof($steps) > 1) {

            $this->load->model("MdlTransaksi");
            $tr = new MdlTransaksi();
            $stepCodes = array();
            $jmlStep = count($steps);

            if (isset($this->accessList[$jenisTr]) && sizeof($this->accessList) > 0) {
                $indsteps = "(";
                foreach ($this->accessList[$jenisTr] as $stepNumber => $stepSpec) {
                    if ($stepNumber <= $jmlStep) {
                        foreach ($stepSpec as $targetCode => $filters) {
                            $indsteps .= "'$targetCode',";
                            $stepCodes[] = $targetCode;
                            if ($filters['allowFollowUp'] == "true") {
                                $arrFilters["allowFollowUp"][] = $targetCode;
                            }

                        }
                    }
                }
                $indsteps = rtrim($indsteps, ",");
                $indsteps .= ")";
                if (sizeof($arrFilters) > 0) {
                    $tr->addFilter("next_step_code in $indsteps");
                }
                else {
                    $tr->addFilter("transaksi.oleh_id='" . $this->session->login['id'] . "'");
                    $tr->addFilter("next_step_code!=''");
                }
            }
            else {

            }

            $tr->addFilter("div_id='" . $this->session->login['div_id'] . "'");
            $tr->addFilter("jenis_top='" . $steps[1]['target'] . "'");
            $tr->addFilter("next_substep_code<>''");
            $tr->addFilter("sub_step_number>0");
            $tr->addFilter("valid_qty>0");
            if ($this->session->login['employee_type'] == "employee_freelance") {
                $tr->addFilter("seller_id='" . $this->session->login['id'] . "'");
            }

            $tmpHist = $tr->lookupRecentUndoneEntries_joined($sesionReplacer)->result();
            // cekHitam($this->db->last_query());
            $arrayOnprogress = array();
            $arrayOnprogressGroup = array();
            $arrayOnprogressPartialMark = array();
            $arrayOnprogressGroupPartialMark = array();

            $extData = "";
            $extact = "";
            $selectProcessor = "";
            //end resetor jembreng ppn
            if (sizeof($tmpHist) > 0) {
                $arrTransID = array();
                $arrTransTopID = array();
                $arrIdsHist = array();
                $arrTransHist = array();
                $arrNextAction = array();
                foreach ($tmpHist as $row) {
                    $arrTransID[] = $row->transaksi_id;
                    $arrTransTopID[] = $row->id_top;
                    $arrNextAction[$row->transaksi_id] = array(
                        "next_step_num"  => $row->next_substep_num,
                        "next_step_code" => $row->next_substep_code,
                    );
                    if ($row->ids_his != "") {
                        $hist = blobDecode($row->ids_his);
                        foreach ($hist as $hisSpec) {
                            $arrIdsHist[$row->id][$hisSpec['step']] = array(
                                "step"  => $hisSpec['step'],
                                "trID"  => $hisSpec['trID'],
                                "nomer" => $hisSpec['nomer'],
                            );
                            $arrTransHist[] = $hisSpec['trID'];
                        }
                    }
                }
                //                arrprint($arrIdsHist);
                $tmpReg_result = array();
                $trReg = new MdlTransaksi();
                $trReg->setFilters(array());
                $trReg->addFilter("param='main'");
                $trReg->addFilter("transaksi_id in ('" . implode("','", $arrTransID) . "')");
                $tmpReg = $trReg->lookupRegistries()->result();

                if (sizeof($tmpReg) > 0) {
                    foreach ($tmpReg as $regRow) {
                        $param = $regRow->param;
                        $tmpReg_result[$regRow->transaksi_id][$param] = blobDecode($regRow->values);
                    }
                }

                $arrNextPIC = callNextPIC($arrNextAction);

                if (sizeof($arrIdsHist) > 0) {
                    $tr = new MdlTransaksi();
                    $tr->setFilters(array());
                    $tr->addFilter("id in ('" . implode("','", $arrTransHist) . "')");
                    $tmpTransHist = $tr->lookupAll()->result();


                    if (sizeof($tmpTransHist) > 0) {
                        foreach ($tmpTransHist as $histSpec) {
                            $tmpTransHist_result[$histSpec->id] = array(
                                "oleh_id"   => $histSpec->oleh_id,
                                "oleh_nama" => $histSpec->oleh_nama,
                            );
                        }
                    }

                    foreach ($arrIdsHist as $trID => $histSpec) {
                        foreach ($histSpec as $step => $detailSpec) {
                            if (array_key_exists($detailSpec['trID'], $tmpTransHist_result)) {
                                $detailSpec['main'] = $tmpTransHist_result[$detailSpec['trID']];
                            }
                            $arrTransMainHist[$trID][$step] = $detailSpec;
                        }
                    }
                }
                //$arrTrIDs_data = array();
                //$arrTrIDs_datas = array();
                $numb = 0;
                foreach ($tmpHist as $row) {
                    //                                        arrPrint($row);
                    //                    $arrTrIDs_data[$row->step_number][] = $row->transaksi_id;

                    if (sizeof($pairRegistries) > 0) {
                        if ((sizeof($tmpReg_result) > 0) && (isset($tmpReg_result[$row->transaksi_id]))) {
                            foreach ($tmpReg_result[$row->transaksi_id] as $param => $eReg) {
                                foreach ($eReg as $k => $v) {
                                    if (!isset($row->$k)) {
                                        $row->$k = $v;
                                    }
                                }
                            }
                        }
                    }

                    //                    $arrTrIDs_datas[$row->step_number][$row->transaksi_id]['ppn'] = $row->ppn;


                    $numb++;

                    $tmp = array();
                    foreach ($historyFields as $fName => $fLabel) {
                        if (isset($row->$fName)) {
                            if (is_numeric($row->$fName)) {
                                if (!isset($sumFooter[$fName])) {
                                    $sumFooter[$fName] = 0;
                                }
                                $sumFooter[$fName] += $row->$fName;
                            }
                        }

                        if (is_array($fLabel)) {
                            $hisStep = $fLabel['step'];
                            $hisKey = $fLabel['key'];

                            if (isset($row->ids_his)) {
                                if ($hisKey == "nomer") {
                                    $returnVal = showHistoriGlobalNumbers($row->ids_his, $hisStep, true);
                                    if ($returnVal == "") {
                                        $tmp[$fName] = "-";
                                    }
                                    else {
                                        $tmp[$fName] = $returnVal;
                                    }
                                }
                                else {
                                    $ids_his_decode = blobDecode($row->ids_his);
                                    if (isset($ids_his_decode[$hisStep][$hisKey])) {
                                        $tmp[$fName] = $ids_his_decode[$hisStep][$hisKey];
                                    }
                                    else {
                                        $tmp[$fName] = "-";
                                    }
                                }
                            }
                            else {
                                $tmp[$fName] = "-";
                            }
                        }
                        else {
                            $tmp[$fName] = isset($row->$fName) ? formatField_he_format($fName, $row->$fName) : formatField_he_format($fName, 0);
                        }

                        if ($fName == "no") {
                            $tmp[$fName] = formatField_he_format($fName, $numb);
                        }

                    }

                    if (sizeof($row->cancel_packing_source_id) > 0) {
                        arrPrint($row->cancel_packing_source_id);
                        $trx = new MdlTransaksi();
                        $trx->addFilter("id='" . $row->cancel_packing_source_id . "'");
                        $tmpTrx = $trx->lookupAll()->result();

                        //                        $tmp['nomer_top'] = $tmpTrx[0]->nomer;
                        $tmp['nomer_top'] = formatField_he_format("nomer_top", $tmpTrx[0]->nomer);
                        //                        arrPrint($tmpTrx[0]->nomer);
                    }


                    if ($row->sub_step_number > 0) {
                        $tmp['state'] = "<span style='color:" . $this->configUi[$jenisTr]['steps'][$row->sub_step_number]['stateColor'] . "'>" . $this->configUi[$jenisTr]['steps'][$row->sub_step_number]['stateLabel'] . "</span>";
                        $tmp['state'] .= "<br>" . createStateSign($row->sub_step_number, $row->step_avail, $jenisTr);
                    }
                    else {
                        $tmp['state'] = "<span style='color:#777777'>canceled</span>";
                    }


                    $tmp['next_pic'] = "-";
                    if (sizeof($arrNextPIC) > 0) {
                        if (isset($arrNextPIC[$row->next_substep_code][$row->next_substep_num])) {
                            $next_pic = "";
                            $nob = 1;
                            foreach ($arrNextPIC[$row->next_substep_code][$row->next_substep_num] as $spec) {
                                if ($row->cabang_id == $spec['cabang_id']) {

                                    if ($next_pic == "") {
                                        $next_pic = "$nob. " . $spec['nama'];
                                    }
                                    else {
                                        $nob++;
                                        $next_pic = $next_pic . "<br>" . "$nob. " . $spec['nama'];
                                    }

                                }

                            }
                            $tmp['next_pic'] = $next_pic;
                            //                            cekHitam($next_pic);
                        }
                    }


                    $tmp['action'] = "";
                    $nextStepNum = ($row->next_substep_num);
                    $currentStepNum = ($row->sub_step_number);
                    $currentStepCode = ($row->jenis);
                    $nextStepCode = ($row->next_step_code);


                    if ($row->sub_step_number > 0) {
                        //                        cekHere("koq");
                        $allowFollowup = true;
                        $actionLabel = "review " . $this->configUi[$jenisTr]['steps'][$currentStepNum]['label'];
                    }

                    if (isset($this->configUi[$jenisTr]['steps'][$nextStepNum])) {
                        if (isset($this->accessList[$jenisTr])) {
                            if (isset($this->accessList[$jenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"])) {
                                $allowFollowup = $this->accessList[$jenisTr][$nextStepNum][$nextStepCode]["allowFollowUp"];
                                $actionLabel = $this->configUi[$jenisTr]['steps'][$nextStepNum]['actionLabel'];
                            }


                        }
                        else {
                            if (in_array($this->configUi[$jenisTr]['steps'][$nextStepNum]['userGroup'], $this->session->login['membership'])) {
                                $allowFollowup = true;
                                $actionLabel = $this->configUi[$jenisTr]['steps'][$nextStepNum]['actionLabel'];
                            }
                            else {
                                $allowFollowup = true;
                                $actionLabel = "review " . $this->configUi[$jenisTr]['steps'][$currentStepNum]['label'];
                            }
                        }
                    }
                    $req_cancel_qty = $row->req_cancel_qty != '' ? $row->req_cancel_qty : 0;
                    $valid_qty = $row->valid_qty != '' ? $row->valid_qty : 0;


                    if ($allowFollowup) {
                        $allowJoin = isset($this->configUi[$jenisTr]["steps"][$nextStepNum]['allowJoin']) && $this->configUi[$jenisTr]["steps"][$nextStepNum]['allowJoin'] == true ? $this->configUi[$jenisTr]["steps"][$nextStepNum]['allowJoin'] : false;
                        $stepLabel = isset($this->configUi[$jenisTr]['steps'][$nextStepNum]['label']) ? $this->configUi[$jenisTr]['steps'][$nextStepNum]['label'] : "";
                        $isCancelPacking = isset($this->configUi[$jenisTr]['steps'][$nextStepNum]['isCancelPacking']) ? $this->configUi[$jenisTr]['steps'][$nextStepNum]['isCancelPacking'] : false;
                        $allowCancel = isset($this->configUi[$jenisTr]['steps'][$nextStepNum]['allowCancel']) ? $this->configUi[$jenisTr]['steps'][$nextStepNum]['allowCancel'] : false;

                        $targetFollowupLink = $isCancelPacking == true ? "followupCancelPackingPrePreview" : "followupPrePreview";

                        $followupLink = "top.$('#result').load('" . base_url() . "Transaksi/$targetFollowupLink/" . $row->transaksi_id . "/$nextStepNum/" . $row->sub_step_number . "');";

                        $tmp['action'] = "<div class='input-group'>";
                        $tmp['action'] .= "<a class='btn btn-primary btn-block' title='turn this entry into $stepLabel' href='JavaScript:void(0)' onClick =\"top.open_holdon();$followupLink\">" . $actionLabel . "</a>";
                        if ($allowJoin) {
                            $tmp['action'] .= "<span class='input-group-addon'>";
                            $tmp['action'] .= "<a title='process many items at once' href='" . base_url() . "Transaksi/viewIncomplete/" . $this->jenisTr . "/$currentStepNum'><span class='fa fa-dedent'></span></a>";
                            $tmp['action'] .= "</span class='input-group-addon'>";
                        }
                        $tmp['action'] .= "</div class='input-group'>";

                        if ($req_cancel_qty > 0 && $valid_qty == 0) {
                            $tmp['action'] = "<div class='btn-group' role='group' aria-label='cancel packing on progress'>";
                            $tmp['action'] .= "<button type='button' disabled class='btn btn-warning' title='sedang dalam process cancel packing' href='JavaScript:void(0)'>menuggu approve cancel</button>";
                            //                            $tmp['action'] .= "<button type='button' class='btn btn-warning' title='sedang dalam process cancel packing' href='JavaScript:void(0)'>x</button>";
                            $tmp['action'] .= "</div>";
                        }

                    }
                    else {

                    }

                    $tmpMark = array();
                    $tmp['keterangan'] = "-";
                    if ($row->partial == 1) {
                        $tmpMark['style'] = "background-color:yellow;";
                        $tmp['keterangan'] = "<span style='color:red;'>transaksi diproses sebagian</span>";
                    }


                    $arrayOnprogress[] = $tmp;
                    $arrayOnprogressGroup[$currentStepNum][] = $tmp;

                    $arrayOnprogressPartialMark[] = $tmpMark;
                    $arrayOnprogressGroupPartialMark[$currentStepNum][] = $tmpMark;

                    //                    break;
                }
            }
            //arrPrint($arrTrIDs_data[3]);
            //arrPrint($arrTrIDs_datas[3]);
            //cekHere(implode(",", $arrTrIDs_data[3]));


        }
        else {

            if (!$paymentConfig) {
                $arrayOnprogress = array();
                //ini bagian auto jembreng shopingcart
                $extData = "";
                $extact = "";
                $selectProcessor = "";
            }
            else {

                $targetJenis = $this->uri->segment(3);
                heInitCart($targetJenis);
                //==dapatkan srcJenis
                $extData = "";
                $extact = "";
                $selectProcessor = "";
                if (!isset($this->configUi[$targetJenis]['shopingcartSource'])) {
                    $paymentSources = null != ($this->config->item("payment_source")) ? $this->config->item("payment_source") : array();
                    $readerDueDate = isset($this->configUi[$targetJenis]['dueDateReader']) ? $this->configUi[$targetJenis]['dueDateReader'] : false;

                    if (sizeof($paymentSources) > 0) {
                        foreach ($paymentSources as $src => $mainSpecs) {
                            if (sizeof($mainSpecs) > 0) {
                                foreach ($mainSpecs as $step => $sSpecTemp) {
                                    $sCtr = 0;
                                    foreach ($sSpecTemp as $sSpec) {
                                        if (isset($sSpec['jenisTarget']) && $sSpec['jenisTarget'] == $targetJenis) {
                                            $srcJenis = $sSpec['jenisSrc'];
                                            $rawSrcJenis = $src;
                                            $srcIndex = $sCtr;
                                            $srcStep = $step;
                                        }
                                        else {
                                            $srcJenis = isset($sSpec['jenisSrc']) ? $sSpec['jenisSrc'] : "";
                                            $rawSrcJenis = "";
                                            $step = "";
                                            $srcIndex = "";
                                            $srcStep = "";
                                        }
                                    }
                                    $sCtr++;
                                }
                            }
                        }
                    }
                    //                    matiHEre($srcJenis." LINE ".__LINE__);
                    $defItemLabels = array(
                        "extern_nama"    => isset($paymentSources[$rawSrcJenis][$srcStep][$srcIndex]['externSrc']['extLabel']) ? $paymentSources[$rawSrcJenis][$srcStep][$srcIndex]['externSrc']['extLabel'] : "",
                        "tagihan"        => "due amount",
                        "terbayar"       => "paid",
                        "diskon"         => "discount",
                        "sisa"           => "due remain",
                        "tagihan_valas"  => "due amount",
                        "terbayar_valas" => "paid",
                        "diskon_valas"   => "discount",
                        "sisa_valas"     => "due remain",
                    );
                    $itemLabels = (isset($this->configUi[$targetJenis]["shoppingCartReferenceExternFields"])) ? $this->configUi[$targetJenis]["shoppingCartReferenceExternFields"] : $defItemLabels;
                    $itemLabels["due_date"] = "due date";
                    $itemLabels["aging"] = "aging(days)";
                    $itemLabels["over_due"] = "over due";

                    $tr = new MdlTransaksi();
                    $tr->setFilters(array());
                    $tr->addFilter("transaksi_payment_source.cabang_id='" . $this->session->login['cabang_id'] . "'");
                    $tr->addFilter("sisa>0.9");
                    if ($myPaymentConfig == true) {
                        //                        cekMerah("may payment true");
                        $tr->addFilter("extern_id='" . $this->session->login['id'] . "'");
                    }
                    $tmpSrc = $tr->lookupPaymentSrcByJenis($targetJenis)->result();
                    $tmpSrcDue = array();
                    $dueEmployee = array();
                    if ($readerDueDate) {
                        $tr->setFilters(array());
                        $tr->addFilter("status='1'");
                        $tmpSrcDue = $tr->lookupAllDueDate()->result();
                        $tempDataDues = array();
                        $validDate = array();
                        foreach ($tmpSrcDue as $tmpSrcDue_tmp) {
                            $tempDataDues[$tmpSrcDue_tmp->customers_id][] = array(
                                "due_date"    => $tmpSrcDue_tmp->due_date,
                                "aging_dtime" => $tmpSrcDue_tmp->dtime,
                            );
                        }
                        $dtime_now = strtotime(date("Y-m-d"));
                        foreach ($tempDataDues as $cus_id => $tempDataDues_0) {
                            $dueVal = array();
                            $dtimeVal = array();
                            foreach ($tempDataDues_0 as $dtime_val) {
                                $keyIndex = strtotime($dtime_val['due_date']);
                                $dueVal[] = $keyIndex;
                                $dtimeVal[$keyIndex] = array(
                                    "due_date" => $dtime_val['due_date'],
                                    "aging"    => $dtime_val['aging_dtime'],
                                );
                            }
                            asort($dueVal);
                            $key_index = $dueVal['0'];
                            $date_due = $dtimeVal[$key_index]['due_date'];
                            $aging = $dtimeVal[$key_index]['aging'];
                            if ($dtime_now > $key_index) {
                                $dueEmployee[$cus_id] = array(
                                    "due_date" => formatField_he_format("dtime", $date_due),
                                    "over_due" => umurDay($date_due) > 0 ? umurDay($date_due) : "0",
                                    "aging"    => umurDay($aging) > 0 ? umurDay($aging) : "0",
                                );
                            }
                        }
                    }
                    $items = array();
                    $externs = array();
                    $tagihans = array();
                    $terbayars = array();
                    $sisas = array();
                    $diskons = array();
                    $tagihans_valas = array();
                    $terbayars_valas = array();
                    $sisas_valas = array();
                    $diskons_valas = array();
                    $srcLabel = "";
                    if (sizeof($tmpSrc) > 0) {
                        foreach ($tmpSrc as $row) {
                            $tmp = array();
                            $classMarking = "";
                            if (isset($dueEmployee[$row->extern_id])) {
                                $classMarking = "bg-danger";
                            }

                            if (!in_array($row->extern_id, $externs)) {
                                if (!isset($tagihans[$row->extern_id])) {
                                    $tagihans[$row->extern_id] = 0;
                                    $terbayars[$row->extern_id] = 0;
                                    $diskons[$row->extern_id] = 0;
                                    $sisas[$row->extern_id] = 0;
                                    $tagihans_valas[$row->extern_id] = 0;
                                    $terbayars_valas[$row->extern_id] = 0;
                                    $sisas_valas[$row->extern_id] = 0;
                                    $diskons_valas[$row->extern_id] = 0;
                                }

                                $tmp = (array)$row;
                                $tmp["link"] = base_url() . get_class($this) . "/selectPaymentSrc/$targetJenis/" . $row->extern_id;
                                $tmp["due_date"] = isset($dueEmployee[$row->extern_id]['due_date']) ? formatField_he_format("dtime", $dueEmployee[$row->extern_id]['due_date']) : "-";
                                $tmp["aging"] = isset($dueEmployee[$row->extern_id]['aging']) ? $dueEmployee[$row->extern_id]['aging'] : "-";
                                $tmp["over_due"] = isset($dueEmployee[$row->extern_id]['over_due']) ? $dueEmployee[$row->extern_id]['over_due'] : "-";
                                $tmp["class_marking"] = $classMarking;
                                $items[$row->extern_id] = $tmp;
                                $externs[] = $row->extern_id;
                                $externName = $row->extern_nama;
                            }
                            $tagihans[$row->extern_id] += isset($row->tagihan) ? $row->tagihan : 0;
                            $terbayars[$row->extern_id] += isset($row->terbayar) ? $row->terbayar : 0;
                            $sisas[$row->extern_id] += isset($row->sisa) ? $row->sisa : 0;
                            $diskons[$row->extern_id] += isset($row->diskon) ? $row->diskon : 0;
                            $tagihans_valas[$row->extern_id] += isset($row->tagihan_valas) ? $row->tagihan_valas : 0;
                            $terbayars_valas[$row->extern_id] += isset($row->terbayar_valas) ? $row->terbayar_valas : 0;
                            $sisas_valas[$row->extern_id] += isset($row->sisa_valas) ? $row->sisa_valas : 0;
                            $diskons_valas[$row->extern_id] += isset($row->diskon_valas) ? $row->diskon_valas : 0;
                            $srcLabel = $row->label;
                        }
                        foreach ($items as $externID => $iSpec) {
                            $items[$externID]['tagihan'] = $tagihans[$externID];
                            $items[$externID]['terbayar'] = $terbayars[$externID];
                            $items[$externID]['diskon'] = $diskons[$externID];
                            $items[$externID]['sisa'] = $sisas[$externID];
                            $items[$externID]['tagihan_valas'] = $tagihans_valas[$externID];
                            $items[$externID]['terbayar_valas'] = $terbayars_valas[$externID];
                            $items[$externID]['diskon_valas'] = $diskons_valas[$externID];
                            $items[$externID]['sisa_valas'] = $sisas_valas[$externID];
                        }
                    }
                    $arrayOnprogress = $items;
                }
                else {
                    //ini rencana du shopincart
                    //                    cekHitam("dual shopingcart");
                    $defaultItemSrc = array(
                        "extern_date2"  => "date e-faktur",
                        "extern_label2" => "e-faktur",
                        "extern_nama"   => "vendor",
                        "nomer"         => "invoice",
                        "extern_nilai2" => "tax base",
                        "sisa"          => "input vat",
                    );
                    $defaultItemTrg = array(
                        "extern_date2"  => "tgl faktur",
                        "extern_label2" => "no faktur",
                        //                        "extern_nama" => "vendor",
                        "nomer"         => "no nota",
                        "extern_nilai2" => "tax base",
                        "sisa"          => "output vat",
                    );
                    $defaultItemTrgEditable = array(
                        "extern_label2",
                    );

                    $paymentSources = null != ($this->config->item("payment_source")) ? $this->config->item("payment_source") : array();
                    $selectedTarget = $this->configUi[$targetJenis]['shopingcartSource']['target'];
                    $returnRoutes = null != ($this->config->item("transaksi_returnRoutes")) ? $this->config->item("transaksi_returnRoutes") : array();

                    $jenisSrc = null;
                    if (sizeof($paymentSources) > 0) {
                        foreach ($paymentSources as $src => $sSpec) {
                            $payConfigs = $paymentSources[$src];
                            if (sizeof($payConfigs) > 0) {
                                //                    $sCtr = 0;
                                foreach ($payConfigs as $paymentSrcConfigTmp) {
                                    $sCtr = 0;
                                    foreach ($paymentSrcConfigTmp as $paymentSrcConfig) {
                                        if (isset($paymentSrcConfig['jenisTarget']) && $paymentSrcConfig['jenisTarget'] == $selectedTarget) {
                                            $srcJenis = $paymentSrcConfig['jenisSrc'];
                                            $rawSrcJenis = $src;
                                            $srcIndex = $sCtr;
                                            $jenisSrc = $srcJenis;
                                        }
                                        $sCtr++;
                                    }

                                }
                            }
                        }
                    }

                    $references = array();
                    if ($jenisSrc != null) {
                        if (isset($returnRoutes[$jenisSrc])) {
                            $retCode = $returnRoutes[$jenisSrc];
                            $trr = new MdlTransaksi();
                            $trr->setFilters(array());
                            $trr->addFilter("param='main'");
                            $trr->addFilter("jenis='$retCode'");
                            $tmpR = $trr->lookupRegistries_joined()->result();
                            if (sizeof($tmpR) > 0) {
                                foreach ($tmpR as $row) {
                                    $main = blobDecode($row->values);
                                    //                        arrprint($main);
                                    $references[$main['referenceID']] = array(
                                        "id"       => $row->transaksi_id,
                                        "nomer"    => $row->nomer,
                                        "refID"    => $main['referenceID'],
                                        "refJenis" => $main['referenceJenis'],
                                        "refNum"   => $main['referenceNomer'],
                                        "harga"    => isset($main['harga']) ? $main['harga'] : 0,
                                        "nett"     => isset($main['nett']) ? $main['nett'] : 0,


                                    );
                                }
                            }
                        }
                    }

                    //region items source
                    $tr = new MdlTransaksi();
                    $tr->setFilters(array());
                    $tr->addFilter("transaksi_payment_source.cabang_id='" . $this->session->login['cabang_id'] . "'");
                    $tr->addFilter("sisa>0.9");
                    //                    $tmpSrc = $tr->lookupPaymentSrcByJenis($selectedTarget)->result();
                    $tmpSrc = $tr->lookupPaymentSrcByJenis_joined($selectedTarget)->result();
                    $itemsSource = array();
                    $externs = array();
                    $tagihans = array();
                    $terbayars = array();
                    $sisas = array();
                    $diskons = array();
                    $tagihans_valas = array();
                    $terbayars_valas = array();
                    $sisas_valas = array();
                    $diskons_valas = array();
                    $extern_nilai2 = array();
                    $srcLabel = "";
                    $sumFooter = array();
                    if (sizeof($tmpSrc) > 0) {
                        foreach ($tmpSrc as $row) {
                            //                                                        arrPrintWebs($row);
                            $tmp = array();

                            $jenis = $row->jenis;
                            $transaksi_id = $row->id;

                            $tmp['class_bg'] = "";


                            $tmp['refID'] = array_key_exists($row->transaksi_id, $references) ? $references[$row->transaksi_id]['refID'] : "";
                            $tmp['refNum'] = array_key_exists($row->transaksi_id, $references) ? $references[$row->transaksi_id]['refNum'] : "";
                            $tmp['refValue'] = array_key_exists($row->transaksi_id, $references) ? $references[$row->transaksi_id]['nett'] : "";


                            if (isset($ppnDisabledConfig['enabled']) && $ppnDisabledConfig['enabled'] == true) {
                                //                    if (($row->ppn_sisa > 0) && ($row->ppn_status == 1)) {
                                if (($row->ppn_status == 1)) {
                                    $ppnDisabled[] = $row->transaksi_id;
                                    $tmp['notes'] = isset($ppnDisabledConfig['notes']) ? "<span style='color:red;font-size:10px;'>" . $ppnDisabledConfig['notes'] . "</span>" : "-";
                                }
                            }

                            $itemsSource[] = (array)$row + $tmp;
                            $externName = $row->extern_nama;

                            $trIDs[] = $row->transaksi_id;

                        }
                        foreach ($defaultItemSrc as $fName => $fLabel) {
                            foreach ($tmpSrc as $rowsTmp) {
                                if (isset($rowsTmp->$fName) && is_numeric($rowsTmp->$fName)) {
                                    if (!isset($sumFooter['itemsSrc'][$fName])) {
                                        $sumFooter['itemsSrc'][$fName] = 0;
                                    }
                                    $sumFooter['itemsSrc'][$fName] += $rowsTmp->$fName;
                                }
                            }

                        }
                    }
                    if (sizeof($trIDs) > 0) {
                        $this->load->model("Mdls/MdlLockerTransaksi");
                        $lt = New MdlLockerTransaksi();
                        $lt->addFilter("transaksi_id in ('" . implode("','", $trIDs) . "')");
                        $lt->addFilter("state='active'");
                        $lt->addFilter("jumlah='0'");
                        $lt_tmp = $lt->lookupAll()->result();
                        if (sizeof($lt_tmp) > 0) {
                            foreach ($lt_tmp as $lt_row) {
                                $lockerDisabled[] = $lt_row->transaksi_id;
                            }
                        }
                    }
                    //endregion

                    //region items
                    $jenisSrc = null;
                    if (sizeof($paymentSources) > 0) {
                        foreach ($paymentSources as $src => $sSpec) {
                            $payConfigs = $paymentSources[$src];
                            if (sizeof($payConfigs) > 0) {
                                //                    $sCtr = 0;
                                foreach ($payConfigs as $paymentSrcConfigTmp) {
                                    $sCtr = 0;
                                    foreach ($paymentSrcConfigTmp as $paymentSrcConfig) {
                                        if (isset($paymentSrcConfig['jenisTarget']) && $paymentSrcConfig['jenisTarget'] == $targetJenis) {
                                            $srcJenis = $paymentSrcConfig['jenisSrc'];
                                            $rawSrcJenis = $src;
                                            $srcIndex = $sCtr;
                                            $jenisSrc = $srcJenis;
                                        }
                                        $sCtr++;
                                    }

                                }
                            }
                        }
                    }

                    $references = array();
                    if ($jenisSrc != null) {
                        if (isset($returnRoutes[$jenisSrc])) {
                            $retCode = $returnRoutes[$jenisSrc];


                            $trr = new MdlTransaksi();
                            $trr->setFilters(array());
                            $trr->addFilter("param='main'");
                            $trr->addFilter("jenis='$retCode'");
                            $tmpR = $trr->lookupRegistries_joined()->result();
                            //cekHere($this->db->last_query());

                            if (sizeof($tmpR) > 0) {
                                foreach ($tmpR as $row) {
                                    $main = blobDecode($row->values);
                                    //                        arrprint($main);
                                    $references[$main['referenceID']] = array(
                                        "id"       => $row->transaksi_id,
                                        "nomer"    => $row->nomer,
                                        "refID"    => $main['referenceID'],
                                        "refJenis" => $main['referenceJenis'],
                                        "refNum"   => $main['referenceNomer'],
                                        "harga"    => isset($main['harga']) ? $main['harga'] : 0,
                                        "nett"     => isset($main['nett']) ? $main['nett'] : 0,


                                    );
                                }
                            }
                        }
                    }

                    $elementConfigs = isset($this->configUi[$this->jenisTr]['receiptElements']) ? $this->configUi[$this->jenisTr]['receiptElements'] : array();

                    //==dapatkan daftar kolom dari srcJenis
                    $tr = new MdlTransaksi();
                    $tr->setFilters(array());
                    $tr->addFilter("transaksi_payment_source.cabang_id='" . $this->session->login['cabang_id'] . "'");
                    //                    $tr->addFilter("extern_id='$externID'");
                    $tr->addFilter("sisa>0.9");

                    $tmpSrc = $tr->lookupPaymentSrcByJenis_joined($targetJenis)->result();
                    $externName = "";
                    $items = array();
                    $tempDueDate = array();
                    $ppnDisabled = array();
                    $lockerDisabled = array();
                    $trIDs = array();
                    if (sizeof($tmpSrc) > 0) {
                        //                        $sumFooter = array();
                        foreach ($tmpSrc as $rows) {
                            $tmp = array();

                            $jenis = $rows->jenis;
                            $transaksi_id = $rows->id;
                            $tmp['class_bg'] = "";
                            $tmp['refID'] = array_key_exists($rows->transaksi_id, $references) ? $references[$rows->transaksi_id]['refID'] : "";
                            $tmp['refNum'] = array_key_exists($rows->transaksi_id, $references) ? $references[$rows->transaksi_id]['refNum'] : "";
                            $tmp['refValue'] = array_key_exists($rows->transaksi_id, $references) ? $references[$rows->transaksi_id]['nett'] : "";


                            $items[] = (array)$rows + $tmp;
                            $externName = $rows->extern_nama;
                            //                            foreach($defaultItemTrg as $fname =>$fLabel){
                            //                                if (is_numeric($row->$fName)) {
                            //                                    if (!isset($sumFooter[$fName])) {
                            //                                        $sumFooter[$fName] = 0;
                            //                                    }
                            //                                    $sumFooter['items'][$fName] += $row->$fName;
                            //                                }
                            //                            }


                            $trIDs[] = $rows->transaksi_id;
                            foreach ($defaultItemTrg as $fName => $fLabel) {
                                //                                cekHitam($fName);
                                if (isset($row->$fName) && is_numeric($rows->$fName)) {
                                    if (!isset($sumFooter['items'][$fName])) {
                                        $sumFooter['items'][$fName] = 0;
                                    }
                                    $sumFooter['items'][$fName] += $rows->$fName;
                                }
                            }
                        }

                        if (sizeof($trIDs) > 0) {
                            $this->load->model("Mdls/MdlLockerTransaksi");
                            $lt = New MdlLockerTransaksi();
                            $lt->addFilter("transaksi_id in ('" . implode("','", $trIDs) . "')");
                            $lt->addFilter("state='active'");
                            $lt->addFilter("jumlah='0'");
                            $lt_tmp = $lt->lookupAll()->result();
                            if (sizeof($lt_tmp) > 0) {
                                foreach ($lt_tmp as $lt_row) {
                                    $lockerDisabled[] = $lt_row->transaksi_id;
                                }
                            }
                        }

                        foreach ($defaultItemTrg as $fName => $fLabel) {
                            foreach ($tmpSrc as $rowsTmp2) {
                                if (isset($rowsTmp2->$fName) && is_numeric($rowsTmp2->$fName)) {
                                    if (!isset($sumFooter['items'][$fName])) {
                                        $sumFooter['items'][$fName] = 0;
                                    }
                                    $sumFooter['items'][$fName] += $rowsTmp2->$fName;
                                }
                            }

                        }
                    }
                    //                    arrPrint(sizeof($items));
                    //                    arrPrint($items);
                    $arrayOnprogress = array(
                        "itemsSrc" => $itemsSource,
                        "items"    => $items,
                    );

                    unset($progressFields);

                    $progressFields = array(
                        "itemsSrc" => $defaultItemSrc,
                        "items"    => $defaultItemTrg,
                    );
                    //endregion

                    $extData = "continue " . $this->configUi[$this->jenisTr]['steps'][1]['label'];
                    $extact = "top.$('#result').load('" . base_url() . "Transaksi/validate/" . $targetJenis . "?');";
                    $selectProcessor = array(
                        "items"    => $this->configUi[$this->jenisTr]["selectorProcessor"],
                        "itemsSrc" => $this->configUi[$this->jenisTr]["selectorProcessor2"],
                    );

                }

            }
        }

        //endregion

        //region step distribution
        $arrayOnProgressView = array();
        // $arrayOnProgressView = $this->viewIncompleteStepAntarCabang();
        $incompleteTransaksiLink = base_url().$this->modul . "/Create/viewIncompleteStepAntarCabang/$jenisTr";
        $arrayOnProgressView = "<div id='incomplete'></div>";
        $arrayOnProgressView .= "<script>$('#incomplete').load('$incompleteTransaksiLink');</script>";
        if (sizeof($stepHistoryFields) > 0) {
            $stepHistoryFields['state'] = "status";
        }
        //endregion

        //region lookup histories
        $this->load->model("MdlTransaksi");
        $tr = new MdlTransaksi();
        //session replacer
        if (sizeof($sesionReplacer) > 0) {
            $tr->addFilter("transaksi.cabang_id='" . $this->session->login['cabang_id'] . "'");
            $tr->addFilter("gudang_id='" . $this->session->login['gudang_id'] . "'");
        }
        $tr->addFilter("jenis_master='" . $this->jenisTr . "'");
        if (sizeof($arrFilters) > 0) {
        }
        else {

            if ($this->session->login['employee_type'] == "employee_freelance") {
                $tr->addFilter("seller_id='" . $this->session->login['id'] . "'");
            }
            else {
                $tr->addFilter("transaksi.oleh_id='" . $this->session->login['id'] . "'");
            }
        }

        /* ---------------------------------------------------
         * limit untuk keperluan testing semata
         * ---------------------------------------------------*/
        $this->db->limit(5);
        $tmpHist_0 = $tr->lookupAll()->result();
        // cekLime($this->db->last_query());
        $tr->setFilters(array());


        $arrayHistory = array();
        if (sizeof($tmpHist_0) > 0) {
            $master = "(";
            foreach ($tmpHist_0 as $row0) {
                $master .= "'$row0->id_master',";
            }
            $master = rtrim($master, ",");
            $master .= ")";
            //           // ambil dari id master
            $trHis = new MdlTransaksi();
            if (strlen($master) > 2) {
                $trHis->addFilter("id_master in $master");
            }

            $tmpHist = $trHis->lookupRecentHistories(5)->result();
            // showLast_query("lime");

            $arrTransID = array();
            $arrTransTopID = array();
            $arrIdsHist = array();
            $arrTransHist = array();
            $arrNextAction = array();
            foreach ($tmpHist as $row) {
                $arrTransID[] = $row->id;
                $arrTransTopID[] = $row->id_top;
                //                $arrNextAction[$row->id] = array(
                //                    "next_step_num" => $row->next_step_num,
                //                    "next_step_code" => $row->next_step_code,
                //                );
                if ($row->ids_his != "") {
                    $hist = blobDecode($row->ids_his);
                    foreach ($hist as $hisSpec) {
                        $arrIdsHist[$row->id][$hisSpec['step']] = array(
                            "step"  => $hisSpec['step'],
                            "trID"  => $hisSpec['trID'],
                            "nomer" => $hisSpec['nomer'],
                        );
                        $arrTransHist[] = $hisSpec['trID'];
                    }
                }
            }
            $tmpReg_result = array();
            $trReg = new MdlTransaksi();
            $trReg->setFilters(array());
            $trReg->addFilter("param='main'");
            $trReg->addFilter("transaksi_id in ('" . implode("','", $arrTransID) . "')");
            $tmpReg = $trReg->lookupRegistries()->result();

            if (sizeof($tmpReg) > 0) {
                foreach ($tmpReg as $regRow) {
                    $param = $regRow->param;
                    $tmpReg_result[$regRow->transaksi_id][$param] = blobDecode($regRow->values);
                }
            }
            if (sizeof($arrIdsHist) > 0) {
                $tr = new MdlTransaksi();
                $tr->setFilters(array());
                $tr->addFilter("id in ('" . implode("','", $arrTransHist) . "')");
                $tmpTransHist = $tr->lookupAll()->result();


                if (sizeof($tmpTransHist) > 0) {
                    foreach ($tmpTransHist as $histSpec) {
                        $tmpTransHist_result[$histSpec->id] = array(
                            "oleh_id"   => $histSpec->oleh_id,
                            "oleh_nama" => $histSpec->oleh_nama,
                        );
                    }
                }

                foreach ($arrIdsHist as $trID => $histSpec) {
                    foreach ($histSpec as $step => $detailSpec) {
                        if (array_key_exists($detailSpec['trID'], $tmpTransHist_result)) {
                            $detailSpec['main'] = $tmpTransHist_result[$detailSpec['trID']];
                        }
                        $arrTransMainHist[$trID][$step] = $detailSpec;
                    }
                }
            }
            $numb = 0;

            foreach ($tmpHist as $row) {
                if (sizeof($pairRegistries) > 0) {
                    if ((sizeof($tmpReg_result) > 0) && (isset($tmpReg_result[$row->id]))) {
                        foreach ($tmpReg_result[$row->id] as $param => $eReg) {
                            foreach ($eReg as $k => $v) {
                                if (!isset($row->$k)) {
                                    $row->$k = $v;
                                }
                            }
                        }
                    }
                }

                $numb++;


                $tmp = array();
                $tmp['dtime'] = $row->dtime;
                foreach ($historyFields as $fName => $fLabel) {
                    if (is_array($fLabel)) {
                        $hisStep = $fLabel['step'];
                        $hisKey = $fLabel['key'];

                        if (isset($row->ids_his)) {
                            $returnVal = showHistoriGlobalNumbers($row->ids_his, $hisStep, true);
                            if ($returnVal == "") {
                                $tmp[$fName] = "-";
                            }
                            else {
                                $tmp[$fName] = $returnVal;
                            }
                        }
                        else {
                            $tmp[$fName] = "-";
                        }
                    }
                    else {
                        $tmp[$fName] = isset($row->$fName) ? formatField_he_format($fName, $row->$fName) : formatField_he_format($fName, 0);
                    }

                    if ($fName == "no") {
                        $tmp[$fName] = formatField_he_format($fName, $numb);
                    }
                }
                $tmp['next_pic'] = "-";


                $arrayHistory[] = $tmp;
            }
        }

        //endregion

        //region link to add new transaction

        //tambahin hak akses custom

        if (placeCanMakeTrans_he_menu($this->session->login['membership'], $this->session->login['cabang_id'], $this->session->login['gudang_id'], $this->jenisTr, $this->configUiJenis)) {
            //        if (in_array($this->configUi[$jenisTr]["steps"][1]['userGroup'], $this->session->login['membership'])) {
            $createIndexes = (null != $this->config->item("transaksi_createIndex")) ? $this->config->item("transaksi_createIndex") : array();
            $isDisableMakeTrans = isset($this->configUi[$this->jenisTr]['isDisableMakeTrans']) ? $this->configUi[$this->jenisTr]['isDisableMakeTrans'] : false;
            if (array_key_exists($this->jenisTr, $createIndexes)) {
                $targetUrl = base_url() . $createIndexes[$this->jenisTr] . "/" . $this->jenisTr;
            }
            else {
                $targetUrl = base_url() . "Transaksi/createForm/" . $this->jenisTr;
            }

            if ($isDisableMakeTrans) {
                $addLink = null;
                //                $_SESSION['errMsg'] = "test error dari 1982";
                //                arrPrint( $this->session->errMsg );
            }
            else {
                $addLink = array(
                    "link"  => $targetUrl,
                    "label" => "<span class='glyphicon glyphicon-plus'></span> create new " . $this->configUi[$jenisTr]["steps"][1]['label'],
                );
            }

        }
        else {
            $addLink = null;
        }
        //endregion

        //region generate activity reports
        $this->load->model("MdlTransaksi");
        $tr = new MdlTransaksi();
        $tr->addFilter("transaksi.cabang_id='" . $this->session->login['cabang_id'] . "'");
        $tr->addFilter("jenis_master='" . $this->jenisTr . "'");
        $tr->addFilter("month(dtime)='" . date("m") . "'");
        $tr->addFilter("year(dtime)='" . date("Y") . "'");
        $tr->addFilter("day(dtime)='" . date("d") . "'");
        if ($this->session->login['employee_type'] == "employee_freelance") {
            $tr->addFilter("seller_id='" . $this->session->login['id'] . "'");
        }
        if (sizeof($tmpHist_0) > 0) {
            if (strlen($master) > 2) {
                $tr->addFilter("id_master in $master");
            }
        }

        $tmpRecap = $tr->lookupAll()->result();

        $sumFields = isset($this->config->item("heTransaksi_layout")[$this->jenisTr]['reportSumFields']) ? $this->config->item("heTransaksi_layout")[$this->jenisTr]['reportSumFields'] : array();
        $arrayRecap = array();

        // arrPrint($this->configUi[$this->jenisTr]);
        $recapCodes = array();
        foreach ($this->configUi[$this->jenisTr]['steps'] as $stepSpec) {
            $recapCodes[$stepSpec['target']] = "<a href='" . base_url() . get_class($this) . "/viewHistory/" . $this->jenisTr . "/" . $stepSpec['target'] . "'>" . $stepSpec['label'] . "</a>";
        }
        $recapProp = array();
        $entities = array();
        if (sizeof($tmpRecap) > 0) {
            foreach ($tmpRecap as $row) {
                //cekHere($row->id);

                if (isset($sumFields) && sizeof($sumFields) > 0) {
                    foreach ($sumFields as $idField => $nameField) {
                        if (!array_key_exists($row->$idField, $entities)) {
                            $entities[$row->$idField] = $row->$nameField;
                        }
                        if (!isset($recapProp[$row->jenis][$row->$idField])) {
                            $recapProp[$row->jenis][$row->$idField] = array(
                                "freq"  => 0,
                                "value" => 0,
                            );
                        }
                        $recapProp[$row->jenis][$row->$idField]['freq'] += 1;
                        $recapProp[$row->jenis][$row->$idField]['value'] += $row->transaksi_nilai;
                    }
                }
            }
        }


        if (sizeof($entities) > 0) {
            foreach ($entities as $eID => $eName) {
                $tmp = array();
                $tmp["name"] = $eName;
                foreach ($recapCodes as $cID => $cName) {
                    $fieldValue = isset($recapProp[$cID][$eID]['value']) ? $recapProp[$cID][$eID]['value'] : 0;
                    $tmp[$cID] = "<span class='btn-block text-right'>" . number_format($fieldValue) . "</span>";
                }
                $arrayRecap[] = $tmp;
            }
        }

        $recapLabels['name'] = isset($this->configUi[$this->jenisTr]['pihakLabel']) ? $this->configUi[$this->jenisTr]['pihakLabel'] : "label";
        $recapLabels = $recapLabels + $recapCodes;
        //endregion

        //        $sumFooterResult = array();
        //        if (isset($sumFooter) && sizeof($sumFooter) > 0) {
        //            foreach ($sumFooter as $key => $val) {
        //                $sumFooterResult[$key] = formatField_he_format($key, $val);
        //            }
        //        }
        //        arrPrint($selectProcessor);
        //        matiHEre();

        $jenisTrsub = isset($_GET['step']) ? $_GET['step'] : 1;
        $historyFieldsDt = isset($this->configUi[$jenisTr]['historyFields'][$jenisTrsub]) ? $this->configUi[$jenisTr]['historyFields'][$jenisTrsub] : $this->configUi[$jenisTr]['shortHistoryFields'];
        $availDbTable = $tr->getAvailTable($historyFieldsDt);

        //-----------------------------------------------------
        $arrJenisTrCek = array("587", "687", "1587", "1687");
        if (in_array($jenisTr, $arrJenisTrCek)) {
            $transaksiName = isset($this->configUi[$jenisTr]['label']) ? $this->configUi[$jenisTr]['label'] : NULL;
            $subplace = isset($this->configUi[$jenisTr]['steps'][1]['subplace']) ? $this->configUi[$jenisTr]['steps'][1]['subplace'] : NULL;
            if ($subplace != NULL) {
                if (($subplace == "warehouse") && ($this->session->login['gudang_id'] < 0)) {
                    //                    cekPink("SESUAI");
                    $msg = NULL;
                }
                elseif (($subplace == "warehouse_ng") && ($this->session->login['gudang_id'] > 0)) {
                    //                    cekPink("SESUAI NOT GOOD");
                    $msg = NULL;
                }
                else {
                    $msg = "Anda tidak memiliki kewenangan untuk membuat request $transaksiName";
                    $addLink = array();
                }
            }
        }
        //        arrPrintWebs($this->session->login);
        //-----------------------------------------------------
        $endtime = microtime(true); // Bottom of page
        $val = $endtime - $starttime;
        // cekMerah("Grabing data " . $val . " Seconds @" . __LINE__ ." ". __METHOD__);
        $this->allSteps = isset($configUi[$this->jenisTr]['steps']) ? $configUi[$this->jenisTr]['steps'] : array();
        //region prepare params to viewer
        $data = array(
            "mode"                 => "index",
            "isMobile"             => $isMob,
            "errMsg"               => $this->session->errMsg,
            "template"             => $this->configUi[$jenisTr]["template"],
            "title"                => $this->configUi[$jenisTr]["label"],
            "subTitle"             => $this->configUi[$jenisTr]["steps"][1]['label'],
            "jenisTr"              => $jenisTr,
            "trName"               => $this->configUi[$jenisTr]["label"],
            'addLink'              => $addLink,
            "allSteps"             => $this->allSteps,
            //            "historyTitle" => "<span class='glyphicon glyphicon-time'></span> " . $this->configUi[$jenisTr]["label"] . " histories",
            "historyTitle"         => "<span class='glyphicon glyphicon-time'></span> recent " . $this->configUi[$jenisTr]["label"] . " histories",
            "arrayHistoryLabels"   => array("dtime" => "time") + $historyFields,
            "arrayHistoryLabelsDt" => $historyFieldsDt,
            "availDbTable"         => $availDbTable,
            "arrayHistory"         => $arrayHistory,
            //            "onprogressTitle" => "<span class='glyphicon glyphicon-alert'></span> incomplete " . $this->configUi[$jenisTr]["label"],
            "onprogressTitle"      => "<span class='glyphicon glyphicon-alert'></span> TRANSAKSI YANG PERLU ACTION ",
            "arrayProgressLabels"  => $progressFields,
            "arrayOnProgressToPay" => $paymentConfig,
            "itemLabels"           => isset($itemLabels) ? $itemLabels : "",
            "srcLabel"             => isset($srcLabel) ? $srcLabel : "",
            //            "arrayOnProgress" => array_merge($arrayOnprogress, $arrayOnprePre, $arrayOnpreDistribution),
            "steps"                => $steps,
            "arrayOnProgress"      => (isset($arrayOnprogress) && sizeof($arrayOnprogress) > 0) ? $arrayOnprogress : array(),
            "arrayOnprogressGroup" => (isset($arrayOnprogressGroup) && (sizeof($arrayOnprogressGroup) > 0)) ? $arrayOnprogressGroup : array(),

            "arrayOnprePre"      => $arrayOnprePre,
            "arrayOnprePreGroup" => $arrayOnprePreGroup,

            "arrayOnpreDistribution"      => $arrayOnpreDistribution,
            "arrayOnpreDistributionGroup" => $arrayOnpreDistributionGroup,

            "entities"         => $entities,
            //            "recapTitle" => "<span class='fa fa-newspaper-o'></span> today " . $this->configUi[$jenisTr]["label"] . " reports (" . date("F Y") . ")",
            "recapTitle"       => "<span class='fa fa-newspaper-o'></span> today " . $this->configUi[$jenisTr]["label"] . " reports",
            "arrayRecapLabels" => $recapLabels,
            "arrayRecap"       => $arrayRecap,

            "onprogressViewTitle"    => "<span class='fa fa-eye'></span> show incomplete step " . $this->configUi[$jenisTr]["label"],
            "onprogressViewSubTitle" => "<span class='text-black'>(daftar transaksi yang masih stanby di cabang tujuan)</span>",
            "arrayOnProgressView"    => $arrayOnProgressView,
            "stepHistoryFields"      => $stepHistoryFields,
            //            "selectProcessor" => isset($this->configUi[$jenisTr]["mode"]) ? $this->configUi[$jenisTr]["selectorProcessor"] : "",
            "selectProcessor"        => $selectProcessor,
            "sumFooter"              => (isset($sumFooterResult) && sizeof($sumFooterResult) > 0) ? $sumFooter : array(),
            //            "sumFooter" => $sumFooterResult,
            "scriptBottom"           => $scriptBottom,
            "btnLabel"               => $extData,
            "actionTarget"           => $extact,
            "sumFooter"              => isset($sumFooter) ? $sumFooter : "",

            "arrayOnprogressPartialMark"      => (isset($arrayOnprogressPartialMark) && sizeof($arrayOnprogressPartialMark) > 0) ? $arrayOnprogressPartialMark : array(),
            "arrayOnprogressGroupPartialMark" => (isset($arrayOnprogressGroupPartialMark) && sizeof($arrayOnprogressGroupPartialMark) > 0) ? $arrayOnprogressGroupPartialMark : array(),

            "defaultItemTrgEditable" => isset($defaultItemTrgEditable) ? $defaultItemTrgEditable : array(),
            "editItemTrg"            => base_url() . "_followupLiveEdit/editEfaktur/" . $this->jenisTr . "/",
        );
        //endregion
        $this->load->view("transaksi", $data);

    }

}
