<?php
	/*
        if(!Getsecurity("pegawai_diluar_hrd"))
        {
		$where=" where a.fntype=0 ";
        }
        */
        if(!Getsecurity("pegawai_diluar_hrd"))
        {
            $objAxpDB->ViewTable("vHRPegawaiPendatanTambahan2");
        }
        else
        {
            $objAxpDB->ViewTable("vHRPegawaiPendatanTambahan1");
        }
   $objAxpDB->ViewName("Daftar Pendapatan Tambahan");
   #$objAxpDB->ViewTable("vHRPegawai");
   $objAxpDB->ViewSQL("SELECT a.fnid, a.ftemployee_code, a.ftemployee_name,
                                 d.ftdivision_name,
                                 c.ftdepartment_name,
                                 e.ftposition_name,
				ifnull(g.ftsalary_name,'') as ftsalary_name ,ifnull(f.fcamount,0) as fcamount,
                        h.fttrans_status_name as periode
                        from tlemployee  a 
                        left join tldivision d on a.ftdivision_code=d.ftdivision_code
                        left join tldepartment c on a.ftdepartment_code=c.ftdepartment_code
                        left join tlposition e on a.ftposition_code=e.ftposition_code
                        left join (SELECT distinct ftshift_code, ftshift_name FROM tlshift) f on a.ftshift_code=f.ftshift_code
                        LEFT JOIN tstransaction_status b ON b.fntrans_status_code=a.fnsalary_type AND b.fntrans_group_code = 33
                        left join tlemployee_salary_inc_plus2 f on a.ftemployee_code=f.ftemployee_code
                        left join tlsalary g on f.ftsalary_code=g.ftsalary_code
                        LEFT JOIN tstransaction_status h ON h.fntrans_status_code=f.fnsalary_period AND h.fntrans_group_code = 25
						{$where} 
                         order by a.fnstatus,a.ftemployee_code,a.fdstart_date
                        ");


    $objAxpDB->ViewCaption("ID, Kode Pegawai, Nama Pegawai, Nama Divisi, Nama Departement, Nama Jabatan,Tunjangan, Jumlah, Periode");
    $objAxpDB->ViewNewWindow(true);


    $objAxpDB->FormName("Pendapatan Tambahan");
    $objAxpDB->FormSQL("select ftemployee_code, ftemployee_name
								from tlemployee");
    $objAxpDB->FormCaption(" Kode Pegawai, Nama Pegawai");
    $objAxpDB->FormPosition("TL, TR");


    $objAxpDB->SetStatus("id");
     if ($objAxpDB->GetStatus("id") == "") {

    }  elseif ($objAxpDB->GetStatus("id") == 0) {

    } elseif ($objAxpDB->GetStatus("id") != 0) {

        $objAxpDB->GridName(0, "Pendapatan");
        $objAxpDB->GridSQL(0, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_inc_plus2");
        $objAxpDB->GridCaption(0, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
        $ajaxGrid="ajax_do('hrd.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=ftsalary_code2&ftsalary_code='+ this.value +'&index=_N_');";
        $objAxpDB->GridScript(0,1,"OnChange=\"$ajaxGrid\"");

    }

    $objAxpDB->Lookup("fnsex", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 23", "fntrans_status_code", "fttrans_status_name", -1, True);
    $objAxpDB->Lookup("ftreligion", "select ftreligion_code, ftreligion_name from tlreligion order by fnid ", "ftreligion_code", "ftreligion_name", -1, True);
    $objAxpDB->Lookup("fnstatus", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 29", "fntrans_status_code", "fttrans_status_name", 1, True);
    $objAxpDB->Lookup("ftpph21_code", "select ftpph21_code, ftpph21_name from tlpph21 ", "ftpph21_code", "ftpph21_name", 0, True);
    $objAxpDB->Lookup("fnmarried_status", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 24", "fntrans_status_code", "fttrans_status_name", 0, True);
    $objAxpDB->Lookup("ftposition_code", "select ftposition_code, ftposition_name from tlposition ", "ftposition_code", "ftposition_name", -1, True);
    $objAxpDB->Lookup("ftdepartment_code", "select ftdepartment_code, ftdepartment_name from tldepartment ", "ftdepartment_code", "ftdepartment_name", -1, True);
    $objAxpDB->Lookup("ftdivision_code", "select ftdivision_code, ftdivision_name from tldivision ", "ftdivision_code", "ftdivision_name", -1, True);

    $objAxpDB->Lookup('ftload_status', 'SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status where fntrans_group_code=9', 'fntrans_status_code', 'fttrans_status_name', 1,true);
    $objAxpDB->Lookup("ftnotes_type_code", "select ftnotes_type_code, ftnotes_type_name from tlnotes_type ", "ftnotes_type_code", "ftnotes_type_name", -1, True);
    $objAxpDB->Lookup("ftallowance_type_code", "select ftallowance_type_code, ftallowance_type_name from tlallowance_type ", "ftallowance_type_code", "ftnotes_type_name", -1, True);
    $objAxpDB->Lookup("ftsalary_code", "select ftsalary_code, ftsalary_name from tlsalary", "ftsalary_code", "ftsalary_name", -1, False);
    $objAxpDB->Lookup("fteducation_code", "select fteducation_code, fteducation_name from tleducation", "fteducation_code", "fteducation_name", -1, True);

    $objAxpDB->LookupGrid(0,"ftsalary_code", "select ftsalary_code, ftsalary_name from tlsalary WHERE fnsalary_type=0", "ftsalary_code", "ftsalary_name", -1, False);
    $objAxpDB->LookupGrid(1,"ftsalary_code", "select ftsalary_code, ftsalary_name from tlsalary WHERE fnsalary_type=1", "ftsalary_code", "ftsalary_name", -1, False);

    $objAxpDB->Lookup("ftpayroll_type_code", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 25", "fntrans_status_code", "fttrans_status_name", 1, true);
    $objAxpDB->Lookup("ftshift_code", "SELECT distinct ftshift_code, ftshift_name FROM tlshift", "ftshift_code", "ftshift_name", 0, True);
    $objAxpDB->Lookup('fnpayment_status_code', 'SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status where fntrans_group_code=26', 'fntrans_status_code', 'fttrans_status_name', 1,true);
    $objAxpDB->Lookup("fnsalary_period", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 25", "fntrans_status_code", "fttrans_status_name", 1, True);
    $objAxpDB->Lookup("fnpayroll_slip", "select fntrans_status_code, fttrans_status_name from tstransaction_status where fntrans_group_code = 28", "fntrans_status_code", "fttrans_status_name", 1, True);

    $objAxpDB->GridAllowAddNew(0, TRUE);
    $objAxpDB->GridAllowDelete(0, TRUE);

    $objAxpDB->GridLocked(0, "1, 0, 0, 0");

    $objAxpDB->SetStatus("id, fnStatus");
    if ($objAxpDB->GetStatus("id") == "")
            $objAxpDB->ButtonShow("cetak_daftar,  export_excel ,  tutup");
    elseif ($objAxpDB->GetStatus("id") == 0) {
            $objAxpDB->FormLocked("0, 0, 0");
            $objAxpDB->ButtonShow("reset, simpan, tutup");
    } elseif ($objAxpDB->GetStatus("id") != 0) {
            $objAxpDB->FormLocked(" 1, 0");
            $objAxpDB->ButtonShow("update,  tutup");
    }


    $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();


?>
