function Page_BeforeShow(&$sender)
{
    $Page_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $t_laporan_denda_tgl_bayar;
    //Compatibility
    //End Page_BeforeShow
    //Custom Code @572-2A29BDB7
    // -------------------------
    // Write your own code here.
    $doAction = CCGetFromGet('doAction');
    global $Label1;
    $param_arr['end_date'] = CCGetFromGet('date_end_laporan');
    $param_arr['start_date'] = CCGetFromGet('date_start_laporan');
    $param_arr['p_vat_type_dtl_id'] = CCGetFromGet('p_vat_type_dtl_id', '');
    $param_arr['status_bayar'] = CCGetFromGet('ListBox1');
    $param_arr['vat_code'] = CCGetFromGet('vat_code');
    if ($doAction == 'view_html') {
        $Label1->SetText(GetCetakHTML($param_arr));
    }
    if ($doAction == 'view_rekap_html') {
        $Label1->SetText(GetCetakRekapHTML($param_arr));
    }
    if ($doAction == 'cetak_excel') {
        CetakExcel($param_arr);
    }
    if ($doAction == 'cetak_rekap_excel') {
        CetakRekapExcel($param_arr);
    }
    // -------------------------
    //End Custom Code
    //Close Page_BeforeShow @1-4BC230CD
    return $Page_BeforeShow;
}
function Page_BeforeShow(&$sender)
{
    $Page_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $t_laporan_history_potensi_piutang;
    //Compatibility
    //End Page_BeforeShow
    //Custom Code @572-2A29BDB7
    // -------------------------
    // Write your own code here.
    $doAction = CCGetFromGet('doAction');
    global $Label1;
    $param_arr['p_year_period_id'] = CCGetFromGet('p_year_period_id');
    $param_arr['p_finance_period_id'] = CCGetFromGet('p_finance_period_id');
    $param_arr['p_finance_period_id1'] = CCGetFromGet('p_finance_period_id1');
    $param_arr['p_vat_type_id'] = CCGetFromGet('p_vat_type_id', '');
    $param_arr['status_bayar'] = CCGetFromGet('ListBox1');
    $param_arr['ketetapan'] = CCGetFromGet('ListBox2', 4);
    $param_arr['tgl_penerimaan'] = CCGetFromGet('tgl_penerimaan', '');
    $param_arr['tgl_penerimaan_last'] = CCGetFromGet('tgl_penerimaan_last', '');
    $param_arr['vat_code'] = CCGetFromGet('vat_code');
    $param_arr['year_code'] = CCGetFromGet('year_code');
    $param_arr['code'] = CCGetFromGet('code');
    $param_arr['code1'] = CCGetFromGet('code1');
    if ($doAction == 'view_html') {
        $Label1->SetText(GetCetakHTML($param_arr));
    }
    if ($doAction == 'cetak_excel') {
        CetakExcel($param_arr);
    }
    // -------------------------
    //End Custom Code
    //Close Page_BeforeShow @1-4BC230CD
    return $Page_BeforeShow;
}
function Page_BeforeShow(&$sender)
{
    $Page_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $t_laporan_posisi_surat_teguran;
    //Compatibility
    //End Page_BeforeShow
    global $Label1;
    global $t_rep_sisa_piutangSearch;
    //Custom Code @566-2A29BDB7
    // -------------------------
    // Write your own code here.
    // -------------------------
    //End Custom Code
    $doAction = CCGetFromGet('doAction');
    if ($doAction == 'view_html') {
        $data = array();
        $param_arr = array();
        $param_arr['p_year_period_id'] = CCGetFromGet('p_year_period_id');
        $param_arr['p_finance_period_id'] = CCGetFromGet('p_finance_period_id');
        $param_arr['p_vat_type_id'] = CCGetFromGet('p_vat_type_id');
        $param_arr['tahun_periode'] = CCGetFromGet('tahun_periode');
        $param_arr['pajak_periode'] = CCGetFromGet('pajak_periode');
        $param_arr['jenis_pajak'] = CCGetFromGet('jenis_pajak');
        $param_arr['status'] = CCGetFromGet('status', 1);
        $t_rep_sisa_piutangSearch->p_year_period_id->SetValue($param_arr['p_year_period_id']);
        $t_rep_sisa_piutangSearch->p_finance_period_id->SetValue($param_arr['p_finance_period_id']);
        $t_rep_sisa_piutangSearch->p_vat_type_id->SetValue($param_arr['p_vat_type_id']);
        $t_rep_sisa_piutangSearch->year_code->SetValue($param_arr['tahun_periode']);
        $t_rep_sisa_piutangSearch->code->SetValue($param_arr['pajak_periode']);
        $t_rep_sisa_piutangSearch->vat_code->SetValue($param_arr['jenis_pajak']);
        if (!empty($param_arr['p_finance_period_id']) and !empty($param_arr['p_vat_type_id'])) {
            $tanggal = CCGetFromGet('date_end_laporan', '31-12-2014');
            $dbConn = new clsDBConnSIKP();
            $query = "select b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.* \r\n\t\t\t\tfrom f_posisi_surat_teguran_test_2(" . $param_arr['p_vat_type_id'] . "," . $param_arr['p_finance_period_id'] . ",'" . $tanggal . "') a\r\n\t\t\t\tleft join t_cust_account b on a.npwpd = b.npwd\r\n\t\t\t\tORDER BY company_brand,npwpd, surat_teguran_3,surat_teguran_2,surat_teguran_1";
            //echo $query;exit;
            $data = array();
            $dbConn->query($query);
            while ($dbConn->next_record()) {
                $data[] = $dbConn->Record;
            }
            $dbConn->close();
            $Label1->SetText(GetCetakHTML($data, $param_arr));
        } else {
            /* Tampilkan Alert */
            echo '<script> alert("Semua Filter Harus Diisi"); </script>';
        }
    } elseif ($doAction == 'download_excel') {
        $data = array();
        $param_arr = array();
        $param_arr['p_year_period_id'] = CCGetFromGet('p_year_period_id');
        $param_arr['p_finance_period_id'] = CCGetFromGet('p_finance_period_id');
        $param_arr['p_vat_type_id'] = CCGetFromGet('p_vat_type_id');
        $param_arr['tahun_periode'] = CCGetFromGet('tahun_periode');
        $param_arr['pajak_periode'] = CCGetFromGet('pajak_periode');
        $param_arr['jenis_pajak'] = CCGetFromGet('jenis_pajak');
        $param_arr['status'] = CCGetFromGet('status', 1);
        $t_rep_sisa_piutangSearch->p_year_period_id->SetValue($param_arr['p_year_period_id']);
        $t_rep_sisa_piutangSearch->p_finance_period_id->SetValue($param_arr['p_finance_period_id']);
        $t_rep_sisa_piutangSearch->p_vat_type_id->SetValue($param_arr['p_vat_type_id']);
        $t_rep_sisa_piutangSearch->year_code->SetValue($param_arr['tahun_periode']);
        $t_rep_sisa_piutangSearch->code->SetValue($param_arr['pajak_periode']);
        $t_rep_sisa_piutangSearch->vat_code->SetValue($param_arr['jenis_pajak']);
        if (!empty($param_arr['p_finance_period_id']) and !empty($param_arr['p_vat_type_id'])) {
            $tanggal = CCGetFromGet('date_end_laporan', '31-12-2014');
            $dbConn = new clsDBConnSIKP();
            $query = "select b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.* \r\n\t\t\t\tfrom f_posisi_surat_teguran_test_2(" . $param_arr['p_vat_type_id'] . "," . $param_arr['p_finance_period_id'] . ",'" . $tanggal . "') a\r\n\t\t\t\tleft join t_cust_account b on a.npwpd = b.npwd\r\n\t\t\t\tORDER BY company_brand,npwpd, surat_teguran_3,surat_teguran_2,surat_teguran_1";
            //echo $query;exit;
            $data = array();
            $dbConn->query($query);
            while ($dbConn->next_record()) {
                $data[] = $dbConn->Record;
            }
            $dbConn->close();
            CetakExcel($data, $param_arr);
        } else {
            /* Tampilkan Alert */
            echo '<script> alert("Semua Filter Harus Diisi"); </script>';
        }
    }
    //Close Page_BeforeShow @1-4BC230CD
    return $Page_BeforeShow;
}
function Page_BeforeShow(&$sender)
{
    $Page_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $t_rep_sisa_piutang;
    //Compatibility
    //End Page_BeforeShow
    global $Label1;
    global $t_rep_sisa_piutangSearch;
    //Custom Code @566-2A29BDB7
    // -------------------------
    // Write your own code here.
    // -------------------------
    //End Custom Code
    $doAction = CCGetFromGet('doAction');
    if ($doAction == 'view_html') {
        $data = array();
        $param_arr = array();
        $param_arr['p_year_period_id'] = CCGetFromGet('p_year_period_id');
        $param_arr['p_finance_period_id'] = CCGetFromGet('p_finance_period_id');
        $param_arr['p_vat_type_id'] = CCGetFromGet('p_vat_type_id');
        $param_arr['tahun_periode'] = CCGetFromGet('tahun_periode');
        $param_arr['pajak_periode'] = CCGetFromGet('pajak_periode');
        $param_arr['jenis_pajak'] = CCGetFromGet('jenis_pajak');
        $param_arr['status'] = CCGetFromGet('status');
        $t_rep_sisa_piutangSearch->p_year_period_id->SetValue($param_arr['p_year_period_id']);
        $t_rep_sisa_piutangSearch->p_finance_period_id->SetValue($param_arr['p_finance_period_id']);
        $t_rep_sisa_piutangSearch->p_vat_type_id->SetValue($param_arr['p_vat_type_id']);
        $t_rep_sisa_piutangSearch->year_code->SetValue($param_arr['tahun_periode']);
        $t_rep_sisa_piutangSearch->code->SetValue($param_arr['pajak_periode']);
        $t_rep_sisa_piutangSearch->vat_code->SetValue($param_arr['jenis_pajak']);
        $t_rep_sisa_piutangSearch->ListBox1->SetValue($param_arr['status']);
        if (!empty($param_arr['p_finance_period_id']) and !empty($param_arr['p_vat_type_id'])) {
            $dbConn = new clsDBConnSIKP();
            if (empty($param_arr['status'])) {
                /* GLOBAL */
                $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.* \r\n\t\t\t\tFROM f_rep_status_piutang (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\tORDER BY company_brand, npwd";
            } else {
                if ($param_arr['status'] == '1') {
                    /* BELUM BAYAR */
                    $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.*\r\n\t\t\t\t\t\tFROM f_rep_status_piutang2 (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\t\t\tWHERE ((f_teg1_amount is null) OR (f_teg1_amount < 1)) AND\r\n\t\t\t\t\t\t\t  ((f_teg2_amount is null) OR (f_teg2_amount < 1)) AND\r\n\t\t\t\t\t\t\t  ((f_teg3_amount is null) OR (f_teg3_amount < 1))\r\n\t\t\t\t\t\t\t  AND NOT textregexeq(f_action_sts,'^[[:digit:]]+(\\.[[:digit:]]+)?\$')\r\n\t\t\t\t\t\tORDER BY company_brand, npwd";
                } else {
                    if ($param_arr['status'] == '2') {
                        /* SUDAH BAYAR */
                        $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.*, (f_amount IS NULL AND f_teg1_amount IS NULL AND f_teg2_amount IS NULL AND f_teg3_amount IS NULL AND f_action_sts > 0) AS bayar_setelah\r\n\t\t\t\t\t\tFROM f_rep_status_piutang (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\t\t\tWHERE (f_teg1_amount > 0) OR \r\n\t\t\t\t\t\t\t  (f_teg2_amount > 0) OR \r\n\t\t\t\t\t\t\t  (f_teg3_amount > 0) \r\n\t\t\t\t\t\t\t  OR textregexeq(f_action_sts,'^[[:digit:]]+(\\.[[:digit:]]+)?\$')\r\n\t\t\t\t\t\tORDER BY company_brand, npwd";
                    }
                }
            }
            //echo $query;exit;
            $data = array();
            $dbConn->query($query);
            while ($dbConn->next_record()) {
                $data[] = $dbConn->Record;
            }
            $dbConn->close();
            // ----- AMBIL JATUH TEMPO ------
            $dbConn2 = new clsDBConnSIKP();
            $tgl_jatuh_tempo = '';
            $qJatuhTempo = "SELECT to_char((trunc(start_date) + due_in_day-1),'yyyy-mm-dd') AS jatuh_tempo\r\n\t\t\t\t\t\t\tFROM p_finance_period WHERE to_char(trunc(start_date),'yyyy-mm-dd') IN \r\n\t\t\t\t\t\t\t( \tSELECT to_char((trunc(end_date) + 1), 'yyyy-mm-dd') \r\n\t\t\t\t\t\t\t\tFROM p_finance_period \r\n\t\t\t\t\t\t\t\tWHERE p_finance_period_id = " . $param_arr['p_finance_period_id'] . ")";
            $dbConn2->query($qJatuhTempo);
            while ($dbConn2->next_record()) {
                $tgl_jatuh_tempo = $dbConn2->f('jatuh_tempo');
            }
            $dbConn2->close();
            $Label1->SetText(GetCetakHTML($data, $param_arr['pajak_periode'], $param_arr['jenis_pajak'], $tgl_jatuh_tempo, $param_arr['status']));
        } else {
            /* Tampilkan Alert */
            echo '<script> alert("Semua Filter Harus Diisi"); </script>';
        }
    } elseif ($doAction == 'download_excel') {
        $data = array();
        $param_arr = array();
        $param_arr['p_year_period_id'] = CCGetFromGet('p_year_period_id');
        $param_arr['p_finance_period_id'] = CCGetFromGet('p_finance_period_id');
        $param_arr['p_vat_type_id'] = CCGetFromGet('p_vat_type_id');
        $param_arr['tahun_periode'] = CCGetFromGet('tahun_periode');
        $param_arr['pajak_periode'] = CCGetFromGet('pajak_periode');
        $param_arr['jenis_pajak'] = CCGetFromGet('jenis_pajak');
        $param_arr['status'] = CCGetFromGet('status');
        $t_rep_sisa_piutangSearch->p_year_period_id->SetValue($param_arr['p_year_period_id']);
        $t_rep_sisa_piutangSearch->p_finance_period_id->SetValue($param_arr['p_finance_period_id']);
        $t_rep_sisa_piutangSearch->p_vat_type_id->SetValue($param_arr['p_vat_type_id']);
        $t_rep_sisa_piutangSearch->year_code->SetValue($param_arr['tahun_periode']);
        $t_rep_sisa_piutangSearch->code->SetValue($param_arr['pajak_periode']);
        $t_rep_sisa_piutangSearch->vat_code->SetValue($param_arr['jenis_pajak']);
        $t_rep_sisa_piutangSearch->ListBox1->SetValue($param_arr['status']);
        if (!empty($param_arr['p_finance_period_id']) and !empty($param_arr['p_vat_type_id'])) {
            $dbConn = new clsDBConnSIKP();
            if (empty($param_arr['status'])) {
                /* GLOBAL */
                $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.* \r\n\t\t\t\tFROM f_rep_status_piutang (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\tORDER BY company_brand, npwd";
            } else {
                if ($param_arr['status'] == '1') {
                    /* BELUM BAYAR */
                    $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.*\r\n\t\t\t\t\t\tFROM f_rep_status_piutang2 (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\t\t\tWHERE ((f_teg1_amount is null) OR (f_teg1_amount < 1)) AND\r\n\t\t\t\t\t\t\t  ((f_teg2_amount is null) OR (f_teg2_amount < 1)) AND\r\n\t\t\t\t\t\t\t  ((f_teg3_amount is null) OR (f_teg3_amount < 1))\r\n\t\t\t\t\t\t\t  AND NOT textregexeq(f_action_sts,'^[[:digit:]]+(\\.[[:digit:]]+)?\$')\r\n\t\t\t\t\t\tORDER BY company_brand, npwd";
                } else {
                    if ($param_arr['status'] == '2') {
                        /* SUDAH BAYAR */
                        $query = "SELECT b.company_brand,regexp_replace(b.brand_address_name, '\r|\n', '', 'g')||' '||b.brand_address_no as alamat_merk_dagang,a.*, (f_amount IS NULL AND f_teg1_amount IS NULL AND f_teg2_amount IS NULL AND f_teg3_amount IS NULL AND f_action_sts > 0) AS bayar_setelah\r\n\t\t\t\t\t\tFROM f_rep_status_piutang (" . $param_arr['p_vat_type_id'] . ", " . $param_arr['p_finance_period_id'] . ", 1) a\r\n\t\t\t\t\t\tleft join t_cust_account b on a.t_cust_account_id=b.t_cust_account_id\r\n\t\t\t\t\t\tWHERE (f_teg1_amount > 0) OR \r\n\t\t\t\t\t\t\t  (f_teg2_amount > 0) OR \r\n\t\t\t\t\t\t\t  (f_teg3_amount > 0) \r\n\t\t\t\t\t\t\t  OR textregexeq(f_action_sts,'^[[:digit:]]+(\\.[[:digit:]]+)?\$')\r\n\t\t\t\t\t\tORDER BY company_brand, npwd";
                    }
                }
            }
            $data = array();
            $dbConn->query($query);
            while ($dbConn->next_record()) {
                $data[] = $dbConn->Record;
            }
            $dbConn->close();
            // ----- AMBIL JATUH TEMPO ------
            $dbConn2 = new clsDBConnSIKP();
            $tgl_jatuh_tempo = '';
            $qJatuhTempo = "SELECT to_char((trunc(start_date) + due_in_day-1),'yyyy-mm-dd') AS jatuh_tempo\r\n\t\t\t\t\t\t\tFROM p_finance_period WHERE to_char(trunc(start_date),'yyyy-mm-dd') IN \r\n\t\t\t\t\t\t\t( \tSELECT to_char((trunc(end_date) + 1), 'yyyy-mm-dd') \r\n\t\t\t\t\t\t\t\tFROM p_finance_period \r\n\t\t\t\t\t\t\t\tWHERE p_finance_period_id = " . $param_arr['p_finance_period_id'] . ")";
            $dbConn2->query($qJatuhTempo);
            while ($dbConn2->next_record()) {
                $tgl_jatuh_tempo = $dbConn2->f('jatuh_tempo');
            }
            $dbConn2->close();
            CetakExcel($data, $param_arr['pajak_periode'], $param_arr['jenis_pajak'], $tgl_jatuh_tempo, $param_arr['status']);
        } else {
            /* Tampilkan Alert */
            echo '<script> alert("Semua Filter Harus Diisi"); </script>';
        }
    }
    //Close Page_BeforeShow @1-4BC230CD
    return $Page_BeforeShow;
}