<?php

	
   if(!Getsecurity("pegawai_diluar_hrd")) {
		$where=" where a.fntype=0 ";
   }
   $objAxpDB->ViewName("Daftar Pegawai Pendapatan Dan Potongan");
   $objAxpDB->ViewTable("vHRPegawaiPendapatanDanPotongan");
   $objAxpDB->ViewSQL("SELECT a.fnid, a.ftemployee_code, a.ftemployee_name,b.fttrans_status_name,a.ftshift_code,f.ftshift_name,
                                a.ftdivision_code, d.ftdivision_name,
                                a.ftdepartment_code, c.ftdepartment_name,
                                a.ftposition_code,e.ftposition_name
                        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
						 {$where} 
                         order by a.fnstatus,a.ftemployee_code,a.fdstart_date
                        ");

    $objAxpDB->ViewCaption("ID, Kode Pegawai, Nama Pegawai, Tipe Pengajian, Kode Shift, Nama Shift, Kode Devisi, Nama Divisi, Kode Departement,Nama Departement, Kode Jabatan, Nama Jabatan");
    $objAxpDB->ViewName("Daftar Pegawai Pendapatan Dan Potongan");
    $objAxpDB->ViewNewWindow(true);


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


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

    }  elseif ($objAxpDB->GetStatus("id") == 0) {
        
    } elseif ($objAxpDB->GetStatus("id") != 0) {
        $fnsalary_type=RetRstField("SELECT fnsalary_type FROM tlemployee WHERE fnid='".$objAxpDB->GetStatus("id")."'");
        if($fnsalary_type==0) {
           if(Getsecurity("slip_gaji")) {
                 $objAxpDB->GridName(0, "Pendapatan");
                $objAxpDB->GridSQL(0, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_inc");
                $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->GridName(1, "Potongan");
                $objAxpDB->GridSQL(1, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_dec");
                $objAxpDB->GridCaption(1, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
                $ajaxGrid="ajax_do('hrd.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=ftsalary_code3&ftsalary_code='+ this.value +'&index=_N_');";
                $objAxpDB->GridScript(1,1,"OnChange=\"$ajaxGrid\"");
           }         
        }
        elseif($fnsalary_type==1) {
            if(Getsecurity("slip_gaji2")) {
                $objAxpDB->GridName(0, "Pendapatan");
                $objAxpDB->GridSQL(0, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_inc");
                $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->GridName(1, "Potongan");
                $objAxpDB->GridSQL(1, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_dec");
                $objAxpDB->GridCaption(1, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
                $ajaxGrid="ajax_do('hrd.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=ftsalary_code3&ftsalary_code='+ this.value +'&index=_N_');";
                $objAxpDB->GridScript(1,1,"OnChange=\"$ajaxGrid\"");
            }
        }
         elseif($fnsalary_type==2) {
            if(Getsecurity("slip_gaji3")) {
                $objAxpDB->GridName(0, "Pendapatan");
                $objAxpDB->GridSQL(0, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_inc");
                $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->GridName(1, "Potongan");
                $objAxpDB->GridSQL(1, "select fnindex, ftsalary_code, fcamount,fnsalary_period,fnpayroll_slip from tlemployee_salary_dec");
                $objAxpDB->GridCaption(1, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
                $ajaxGrid="ajax_do('hrd.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=ftsalary_code3&ftsalary_code='+ this.value +'&index=_N_');";
                $objAxpDB->GridScript(1,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->GridAllowAddNew(1, TRUE);
    $objAxpDB->GridAllowDelete(1, TRUE);



    $objAxpDB->GridLocked(0, "1, 0, 0, 0");
    $objAxpDB->GridLocked(1, "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");
    }

	 if($_REQUEST['ajax']) {
           switch($_REQUEST['code']) {
           case "grid_salary2":

               ob_start();
				$ssql="SELECT fnindex, ftsalary_code, fcsalary_amount AS fcamount,fnsalary_period, fnpayroll_slip
						FROM tlsalary
						WHERE fnsalary_type=0   #   ";
				$_REQUEST["id"]=0.5;

				$objAxpDB->GridSQL(0,$ssql);
				$objAxpDB->GridCaption(0, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
				$objAxpDB->Process();
				$objAxpDB->setGrid2(0);
				$html = ob_get_contents();
				ob_end_clean();
               ?>

                    div = document.getElementById('txtHint0');
                    var m='<?php echo js_esc($html); ?>';
                    m= m.replace(/^\s*|\s*$/g,"");

                    div.innerHTML =m;
                     TransactionDetailRowID0 =document.getElementsByName('fnindexD0[]').length;
                    RowIndex0();
                   // reSize();

               <?
			  case "grid_salary3":
				 ob_start();
				$ssql="SELECT fnindex,ftsalary_code, fcsalary_amount AS fcamount,fnsalary_period, fnpayroll_slip
						FROM tlsalary
						WHERE fnsalary_type=1 #   ";
				$_REQUEST["id"]=0.5;
				$objAxpDB->GridSQL(1,$ssql);
				$objAxpDB->GridCaption(1, "No., Kode Gaji, Jumlah Gaji, Periode, Pengajian");
				$objAxpDB->Process();
				$objAxpDB->setGrid2(1);
				$html = ob_get_contents();
				ob_end_clean();
               ?>

                    div = document.getElementById('txtHint1');
                    var m='<?php echo js_esc($html); ?>';
                    m= m.replace(/^\s*|\s*$/g,"");

                    div.innerHTML =m;
                    TransactionDetailRowID1 =document.getElementsByName('fnindexD1[]').length;
                    RowIndex1();
                    reSize();

               <?

               break;

           }
           die("");
           exit;
    }

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


?>
