<?php

    Getsecurity("giro_mundur_hutang");

    $objAxpDB->ViewName("Daftar Giro Mundur Hutang");
    #$objAxpDB->ViewTable("vKUGiroMundurHutang");
    $objAxpDB->ViewSQL("SELECT A.fnid, A.ftgiro_no, A.fdgiro_date AS fdtrans_date, A.fdgiro_cliring_date, A.fcamount, A.ftacc_no, D.ftdescription AS ftacc_desc,  A.ftdocument_no, C.ftsupplier_name AS ftsupplier_name,a.ftpf_no,B.fttrans_status_name AS fnstatus_giro
                        FROM txgiro2_hist A INNER JOIN tstransaction_status B ON B.fntrans_group_code = 11 AND A.fnstatus_giro=fntrans_status_code
                                            LEFT JOIN  tlsupplier C ON A.ftsupplier_code=C.ftsupplier_code
                                            LEFT JOIN  tlmaster_bank D ON A.ftacc_no=D.ftcode
                                            LEFT JOIN tlmaster_cast E ON A.ftacc_no= e.ftcode
                        WHERE (('{$_SESSION['strbranch']}' <> 'PUSAT' AND a.ftbranch_code = '{$_SESSION['strbranch']}') OR '{$_SESSION['strbranch']}' = 'PUSAT')");

    $objAxpDB->ViewCaption("ID, No. Giro, Tgl. Giro, Tgl. Cair Giro, Jumlah, No. Perkiraan, Deskripsi Perkiraan , No. transaksi,  Nama Supplier,No.TF, Status ");
    $objAxpDB->ViewPeriod(TRUE);

    $objAxpDB->FormName("Giro Mundur Hutang");
    $objAxpDB->FormSQL("SELECT ftgiro_no, fdgiro_date, fdgiro_cliring_date, fcrate, fcamount, ftacc_no, ftdocument_no, ftsupplier_code, fnstatus_giro FROM txgiro2_hist");
    $objAxpDB->FormCaption("No. Giro, Tgl. Giro, Tgl. Cair Giro, Kurs, Jumlah, No. Perkiraan, No. transaksi, Supplier, Status");
    $objAxpDB->FormPosition("TL,TL, TL, TL, TL, TL, TL, TL, TL");

    $objAxpDB->Lookup("fnstatus_giro", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 11", "fntrans_status_code", "fttrans_status_name", 1,true);
    $objAxpDB->Lookup("ftsupplier_code", "SELECT ftsupplier_code, ftsupplier_name FROM tlsupplier", "ftsupplier_code", "ftsupplier_name", 0,true);


    $ssql="SELECT a.ftcoa_code, a.ftcoa_name FROM tlcoa a INNER JOIN tlcoa_subgroup b ON a.ftcoa_subgroup_code=b.ftcoa_subgroup_code WHERE a.ftcoa_subgroup_code=16 ";

    $objAxpDB->Lookup("ftacc_no", $ssql, "ftcoa_code", "ftcoa_name", 0,true);

    $objAxpDB->SetStatus("id, fnstatus_giro");
    if ($objAxpDB->GetStatus("id") == "") {
    //         $objAxpDB->ButtonShow(" cetak_daftar, export_excel ,tutup");
    } elseif ($objAxpDB->GetStatus("fnstatus_giro") == 0) {   
            $objAxpDB->Lookup("fnstatus_giro", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_status_code<>9 and fntrans_group_code = 11", "fntrans_status_code", "fttrans_status_name", 1,true);
            $objAxpDB->ButtonShow("reset, simpan, tutup");
            $objAxpDB->FormLocked("1, 1, 0, 1, 1, 0, 1, 1, 0");
    } elseif ($objAxpDB->GetStatus("fnstatus_giro") != 9) {
            $objAxpDB->ButtonShow("cetak,update,tutup");
            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1");
    } elseif ($objAxpDB->GetStatus("fnstatus_giro") == 9) {           
            $objAxpDB->FormLocked("1, 1, 1, 1, 1, 1, 1, 1, 1");
            $objAxpDB->ButtonShow("tutup");
    }
    $objAxpDB->Process();

    $objAxpDB->WriteHtmlTable();