<?php

    
    if($_REQUEST['id']==0) {
        $where=" WHERE ftpayroll_slip_no='{$_REQUEST['ftpayroll_slip_no']}' AND
                       ftemployee_code='{$_REQUEST['ftemployee_code']}' #";

        $ssql="SELECT fnid
                FROM txpayroll_slip_emp
                {$where}";

        $_REQUEST['id']=RetRstField($ssql);
    }
    else {
         $ssql="SELECT ftpayroll_slip_no 
                FROM txpayroll_slip_emp
                WHERE fnid='{$_REQUEST['id']}'";
          $_REQUEST['ftpayroll_slip_no']=RetRstField($ssql);
         $ssql="SELECT ftemployee_code
                FROM txpayroll_slip_emp
                WHERE fnid='{$_REQUEST['id']}'";
          $_REQUEST['ftemployee_code']=RetRstField($ssql);
           $where=" WHERE ftpayroll_slip_no='{$_REQUEST['ftpayroll_slip_no']}' AND
                       ftemployee_code='{$_REQUEST['ftemployee_code']}' #";
    
         
    }
    
            $ssql1x="select sum(fcamount) as fcamount from txpayroll_slip_inc where ftemployee_code='".($_REQUEST['ftemployee_code'])."' AND  ftpayroll_slip_no='".($_REQUEST['ftpayroll_slip_no'])."'";
            $ssql2x="select sum(fcamount) as fcamount from txpayroll_slip_dec where ftemployee_code='".($_REQUEST['ftemployee_code'])."' AND  ftpayroll_slip_no='".($_REQUEST['ftpayroll_slip_no'])."'";
            $fcincome_amountD0=(RetRstField($ssql1x));
            $fcdeduction_amountD0=(RetRstField($ssql2x));
            $fcamountD0=($fcincome_amountD0-$fcdeduction_amountD0);
             $fcincome_amountD0=number_format($fcincome_amountD0,2);
            $fcdeduction_amountD0=number_format($fcdeduction_amountD0,2);
            $fcamountD0=number_format($fcamountD0,2);
            
            $strAutoNumber0="
               var gContainer=window.opener;              
//               alert(gContainer.document.getElementById('fnindex_grid0').value);
               
             
                   gContainer.document.getElementById('fcincome_amountD0'+gContainer.document.getElementById('fnindex_grid0').value).value='{$fcincome_amountD0}';
                   gContainer.document.getElementById('fcdeduction_amountD0'+gContainer.document.getElementById('fnindex_grid0').value).value='{$fcdeduction_amountD0}';
                   gContainer.document.getElementById('fcamountD0'+gContainer.document.getElementById('fnindex_grid0').value).value='{$fcamountD0}';
//                   ElementCurrencyOnBlur(document.getElementById('fcincome_amountD0'+gContainer.document.getElementById('fnindex_grid0').value));
//                   ElementCurrencyOnBlur(document.getElementById('fcdeduction_amountD0'+gContainer.document.getElementById('fnindex_grid0').value));
//                   ElementCurrencyOnBlur(document.getElementById('fcamountD0'+gContainer.document.getElementById('fnindex_grid0').value));

              

            ";



$objAxpDB->FormJS($strAutoNumber0);
        
	$objAxpDB->ViewName("Daftar Slip Gaji Tipe 2");
	$objAxpDB->ViewSQL("SELECT a.fnid, a.ftpayroll_slip_no, a.fdtrans_date
                            FROM txpayroll_slip_hdr a 
                            WHERE a.fnsalary_type=0
                            order by a.ftpayroll_slip_no desc, a.fdtrans_date desc");
    $objAxpDB->ViewCaption("ID, No. Slip Gaji,
                                 Tgl. Transaksi");

    $objAxpDB->FormName("Slip Gaji Tipe 2");
	$objAxpDB->FormSQL("SELECT ftpayroll_slip_no, ftemployee_code FROM txpayroll_slip_emp");
	$objAxpDB->FormCaption("No. Slip Gaji, Karyawan");
	$objAxpDB->FormPosition("TL, TR");
	$objAxpDB->ViewPeriod(False);
	$objAxpDB->FormName("Slip Gaji Tipe 2");
	$objAxpDB->GridName(0, "Daftar Pendapatan");
	$objAxpDB->GridSQL(0, "select fnindex, ftsalary_code,fcamount from txpayroll_slip_inc $where  ");
	$objAxpDB->GridCaption(0, "No., Nama Gaji, Jumlah  ");
//	$objAxpDB->GridScript(0,2," onChange=\"ValSlipGajiIncome();\"");
	$objAxpDB->GridName(1, "Daftar Potongan");
	$objAxpDB->GridSQL(1, "select fnindex, ftsalary_code,fcamount from txpayroll_slip_dec $where ");
	$objAxpDB->GridCaption(1, "No., Nama Gaji, Jumlah ");
//	$objAxpDB->GridScript(1,2," onChange=\"ValSlipGajiDeduction();\"");
	$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("ftemployee_code", "SELECT ftemployee_code, ftemployee_name FROM tlemployee", "ftemployee_code", "ftemployee_name", -1, False);
	


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


    $ssql="SELECT fnstatus FROM txpayroll_slip_hdr WHERE ftpayroll_slip_no='{$_REQUEST['ftpayroll_slip_no']}' ";
    $fnstatus=RetRstField($ssql);

    if ($fnstatus == 0) {
        $objAxpDB->ButtonShow("simpan,tutup");
        $objAxpDB->GridLocked(0, "1, 1, 0");
        $objAxpDB->GridLocked(1, "1, 1, 0");
    }
    else {
        $objAxpDB->ButtonShow("tutup");
        $objAxpDB->GridLocked(0, "1, 1, 1");
        $objAxpDB->GridLocked(1, "1, 1, 1");
    }
	
	 $objAxpDB->Process();
    $objAxpDB->WriteHtmlTable();


?>