<?php
	if($_REQUEST['ajax']) {
		switch($_REQUEST['code']) {
			case "transno":
				if(RetRstField("SELECT fnid FROM txpurchase_request_hdr WHERE ftpr_no='{$_REQUEST['fttrans_no']}'"))
				{
					?>
						alert('No. transaksi sudah dipakai...\n System akan mengenerate No. transaksi kembali ...\n Silahkan ulangi proses penyimpanan...  ');
						OnChangeDate_fdtrans_date();
					<?php
				}
				else 
				{
					?>
						submitbutton('Simpan','','','','');
					<?php
				}
				die("");
			break;
			
			case "formula":
				if($_REQUEST['fnpr_type']==0)
				{
					$ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
						FROM tlstock_multi_det_bahan_baku
						WHERE ftitem_code='{$_REQUEST['ftitem_code']}' 
						and ftuom_code_multi='{$_REQUEST['ftuom_code']}'
						";
				}
				else if($_REQUEST['fnpr_type']==1)
				{
					$ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
						FROM tlstock_multi_det_setengah_jadi
						WHERE ftitem_code='{$_REQUEST['ftitem_code']}' 
						and ftuom_code_multi='{$_REQUEST['ftuom_code']}'
						";
				}
				else if($_REQUEST['fnpr_type']==2)
				{
					$ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
						FROM tlstock_multi_det_sparepart
						WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
						and ftuom_code_multi='{$_REQUEST['ftuom_code']}'
						";
				}
                                else if($_REQUEST['fnpr_type']==3)
				{
					$ssql="SELECT IFNULL(SUM(ffformula),1) as ffformula
                                                FROM tlstock_multi_det
                                                WHERE ftitem_code='{$_REQUEST['ftitem_code']}'
                                                and ftuom_code_multi='{$_REQUEST['ftuom_code']}'
                                                ";
				}

                                $ffformula=RetRstField($ssql);
                                $ffQtyMulti=(double)$ffformula*(double)CCur($_REQUEST['fnqty']);
                
                                ?>
                                document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffformula; ?>';
                                document.getElementById('fnqty_baseD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffQtyMulti; ?>';
                                <?php 
			break;


			case "item":
				if($_REQUEST['fnpr_type']==0)
				{
					$ftUOM_Code1=RetRstField("SELECT UCASE(ftUOM_Code) as ftUOM_Code  FROM tlstock_hdr_bahan_baku WHERE ftitem_code='{$_REQUEST['ftitem_code']}'");
					$ftUOM_Code="SELECT UCASE(a.ftUOM_Code) AS ftuom_code ,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_hdr_bahan_baku a
										INNER JOIN tluom b ON a.ftuom_code=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftUOM_Code
									UNION ALL
									SELECT UCASE(a.ftuom_code_multi) AS ftuom_code,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_multi_det_bahan_baku a
										INNER JOIN tluom b ON a.ftuom_code_multi=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftuom_code_multi";
                                }
                                else if($_REQUEST['fnpr_type']==1)
                                {
                                    	$ftUOM_Code1=RetRstField("SELECT UCASE(ftUOM_Code) as ftUOM_Code  FROM tlstock_hdr_setengah_jadi WHERE ftitem_code='{$_REQUEST['ftitem_code']}'");
					$ftUOM_Code="SELECT UCASE(a.ftUOM_Code) AS ftuom_code ,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_hdr_setengah_jadi a
										INNER JOIN tluom b ON a.ftuom_code=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftUOM_Code
									UNION ALL
									SELECT UCASE(a.ftuom_code_multi) AS ftuom_code,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_multi_det_setengah_jadi a
										INNER JOIN tluom b ON a.ftuom_code_multi=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftuom_code_multi";
                                }
                                else if($_REQUEST['fnpr_type']==2)
                                {
                                    	$ftUOM_Code1=RetRstField("SELECT UCASE(ftUOM_Code) as ftUOM_Code  FROM tlstock_hdr_sparepart WHERE ftitem_code='{$_REQUEST['ftitem_code']}'");
					$ftUOM_Code="SELECT UCASE(a.ftUOM_Code) AS ftuom_code ,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_hdr_sparepart a
										INNER JOIN tluom b ON a.ftuom_code=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftUOM_Code
									UNION ALL
									SELECT UCASE(a.ftuom_code_multi) AS ftuom_code,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_multi_det_sparepart a
										INNER JOIN tluom b ON a.ftuom_code_multi=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftuom_code_multi";
                                }
                                else if($_REQUEST['fnpr_type']==3)
				{
					$ftUOM_Code1=RetRstField("SELECT UCASE(ftUOM_Code) as ftUOM_Code  FROM tlstock_hdr WHERE ftitem_code='{$_REQUEST['ftitem_code']}'");
					$ftUOM_Code="SELECT UCASE(a.ftUOM_Code) AS ftuom_code ,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_hdr a
										INNER JOIN tluom b ON a.ftuom_code=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftUOM_Code
									UNION ALL
									SELECT UCASE(a.ftuom_code_multi) AS ftuom_code,UCASE(b.ftuom_name) AS ftuom_name FROM tlstock_multi_det a
										INNER JOIN tluom b ON a.ftuom_code_multi=b.ftuom_code
									WHERE a.ftitem_code='{$_REQUEST['ftitem_code']}'
									GROUP BY a.ftuom_code_multi";
                                }
                                
                                $rs=mysql_query($ftUOM_Code);
                                ?>     
                                        var ObjSelect=document.getElementById('<?php echo $_REQUEST['ObjLokasi']; ?>');
                                        var len = ObjSelect.length;
                                        for (var idx=0; idx < len; idx++)
                                        {
                                                if (ObjSelect.options[ObjSelect.length-1].value!='') {
                                                          ObjSelect.remove(ObjSelect.length-1);
                                                }
                                        }
                                <?php
                                $i=0;
                                
                                while($r=mysql_fetch_assoc($rs))
                                {      
                                        $i++;
                                        echo "
                                                try
                                                        {
                                                                ObjSelect.add(new Option('{$r['ftuom_code']}--{$r['ftuom_name']}','{$r['ftuom_code']}'),null,null);
                                                        }
                                                        catch(ex)
                                                        {
                                                                ObjSelect.add(new Option('{$r['ftuom_code']}--{$r['ftuom_name']}','{$r['ftuom_code']}'),$i,$i);
                                                        } ";
                                }
                                $ffdefault='1';

                                ?>      
                                        document.getElementById('ftuom_codeD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ftUOM_Code1; ?>';
                                        document.getElementById('ftuom_code_baseD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ftUOM_Code1; ?>';
                                        document.getElementById('ffformulaD0<?php echo $_REQUEST['index']; ?>').value='<?php echo $ffdefault; ?>';

                                        if (document.getElementById('fnstatusD0<?php echo $_REQUEST['index']; ?>').value == '') {
                                            document.getElementById('fnstatusD0<?php echo $_REQUEST['index']; ?>').value= '1';
                                        }
                                <?php
				
				die("");
                                break;
		}
	}

    Getsecurity("pembelian_purchase_request");
    $objAxpDB->LookupMagicQuotes(True);
    
    $objAxpDB->ViewName("Daftar Purchase Request");
    $ssql="SELECT a.fnid,a.fdtrans_date,a.ftpr_no,e.fttrans_status_name AS fttype,c.fttrans_status_name AS ftstatus
                FROM (txpurchase_request_hdr a LEFT JOIN tstransaction_status c
                ON((a.fnstatus = c.fntrans_status_code) AND (c.fntrans_group_code = 2)))
                LEFT JOIN tstransaction_status e ON(((a.fnpr_type = e.fntrans_status_code) AND (e.fntrans_group_code = 35)))
                WHERE (('{$_SESSION['strbranch']}' <> 'PUSAT' AND a.ftbranch_code = '{$_SESSION['strbranch']}') OR '{$_SESSION['strbranch']}' = 'PUSAT')
                ORDER BY a.fdtrans_date DESC,a.ftpr_no DESC";

    $objAxpDB->ViewSQL($ssql);
    $objAxpDB->ViewCaption("ID, Tgl. PR, No. PR,Tipe PR, Status");
    $objAxpDB->ViewPeriod(TRUE);

    $objAxpDB->FormName("Purchase Request");
    $objAxpDB->FormSQL("SELECT  ftpr_no, fnpr_type, ftreference, ftrequest_user, fdtrans_date, ftnotes, fnstatus FROM txpurchase_request_hdr");
    $objAxpDB->FormCaption("No. PR, Tipe PR,No. Referensi, Permintaan User, Tgl. Transaksi, Catatan, Status ");
    $objAxpDB->FormPosition("TL, TL, TL, TR, TR, BL, BR");

    $objAxpDB->GridSQL(0, "SELECT fnindex, ftitem_code,fnqty,ftuom_code,ffformula,fnqty_base,ftuom_code_base,ifnull(fnqty_accept,0) as fnqty_accept,ifnull(fnqty_accept_base,0) as fnqty_accept_base, fdclosing_date,fnstatus FROM txpurchase_request_det");
    $objAxpDB->GridCaption(0, "No., Kode Barang, Qty, Satuan, Qty Formula, Qty Base, Satuan Base,Qty Sisa,Qty Sisa Base, Tgl. Status, Status");

    if($_REQUEST['id']=='0') {
        $where_ftitem_code=" WHERE fnstatus=1";
    }
        
    if(!$_REQUEST['id'])
    {
                
                $strAutoNumber1="ajax_do('query2.php?code=2&ftmodule_code=pu001&thbln=' + document.getElementById(\"fdtrans_date\").value + '&field_name=ftpr_no&no_trans=ftpr_no&table_name=txpurchase_request_hdr&ftbranch_code={$_SESSION['strbranch']}')";
                $ajaxGrid1="ajax_do_grid0('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=grid&fnpr_type='+ document.getElementById('fnpr_type').value);";
		$strAutoNumber0="function OnChangeDate_fdtrans_date()
                                 {
                                    {$strAutoNumber1}
                                 }
						
                                 OnChangeDate_fdtrans_date();
				 ";
		$objAxpDB->FormJS($strAutoNumber0);
    }
     
    $objAxpDB->Lookup("ftbranch_code", "SELECT ftbranch_code, ftbranch_name FROM tlbranch where ftbranch_code='{$_SESSION['strbranch']}'", "ftbranch_code", "ftbranch_name", 0,true);
    $objAxpDB->Lookup("fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2", "fntrans_status_code", "fttrans_status_name",0, True);
    $objAxpDB->Lookup("fnpr_type", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 35 AND fntrans_status_code='3'", "fntrans_status_code", "fttrans_status_name", 0,True);
    $objAxpDB->Lookup("fnreceive_status", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 18", "fntrans_status_code", "fttrans_status_name", 1, True);
    $objAxpDB->Lookup("ftuom_code", "SELECT ftuom_code, ftuom_name FROM tluom", "ftuom_code", "ftuom_name", -1,true);
//    $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
    $objAxpDB->LookupGrid(0,"fnstatus", "SELECT fntrans_status_code, fttrans_status_name FROM tstransaction_status WHERE fntrans_group_code = 2 and (fntrans_status_code=1 or fntrans_status_code=9 or fntrans_status_code=5)", "fntrans_status_code", "fttrans_status_name",0, True);
    
    $objAxpDB->FormScript(1, "onChange=\"{$ajaxGrid1}{OnChangeDate_fdtrans_date()}\"");
    $objAxpDB->FormScript(2,"onChange=\"OnChangeDate_fdtrans_date();\"");
    $objAxpDB->FormScript(3,"onChange=\"{$ajaxftcurrency_code}{$ajaxAddress}\"");
    $objAxpDB->FormScript(13,"onChange=\"OnChangeDate_fdtrans_date();\"");
    
    $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnpo_include=1 and fnstatus = 1 ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
    
    $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value +'&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
    $objAxpDB->GridScript(0,1," onChange=\"{$ajaxItem}\"");

    $ajaxFormula="OnChange=\"ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=formula&index=_N_&fnpr_type='+ document.getElementById('fnpr_type').value +'&index=_N_&ftitem_code='+ document.getElementById('ftitem_codeD0_N_').value+'&ftuom_code='+ document.getElementById('ftuom_codeD0_N_').value+'&fnqty='+ document.getElementById('fnqtyD0_N_').value+'&ffformula='+ document.getElementById('ffformulaD0_N_').value);\"";
    $objAxpDB->GridScript(0,2, $ajaxFormula );
    $objAxpDB->GridScript(0,3, $ajaxFormula );
    $objAxpDB->SetStatus("id, fnreceive_status, fnstatus,fntax_code");
	
    if ($objAxpDB->GetStatus("id") == "") 
    {
        $objAxpDB->ButtonShow("baru,  cetak_daftar, export_excel , tutup");
    } 
    elseif ($objAxpDB->GetStatus("id") == 0)
    {
        $objAxpDB->FormLocked("1,1,0,0,0,0,1,0,1");
        $objAxpDB->GridLocked(0,"1,0,0,1,1,1,1,1,1,1,1");
        $objAxpDB->GridHidden(0,"0,0,0,0,1,1,1,1,1,0,0");
	$objAxpDB->ButtonShow("reset, simpan, tutup");
	$objAxpDB->GridAllowAddNew(0, TRUE);
	$objAxpDB->GridAllowDelete(0, TRUE);
		
    }
    elseif ($objAxpDB->GetStatus("fnstatus") == 0){
      $objAxpDB->FormLocked("1,1,0,0,1,0,1,1");
      $objAxpDB->GridLocked(0,"1,0,0,1,1,1,1,1,1,1,1");
      $objAxpDB->GridHidden(0,"0,0,0,0,1,1,1,1,1,0,0");
      $objAxpDB->GridAllowAddNew(0, TRUE);
      $objAxpDB->GridAllowDelete(0, TRUE);
      $objAxpDB->ButtonShow("cetak, baru, update, final, batal, tutup");
    }
   
    elseif ($objAxpDB->GetStatus("fnstatus") == 1)
    {
            $objAxpDB->ButtonShow("cetak, close_pr, baru, batal, tutup");
            $objAxpDB->FormLocked("1,1,1,1,1,1,1,1");
            $objAxpDB->GridLocked(0,"1,1,1,1,1,1,1,1,1,1,1");
            $objAxpDB->GridHidden(0,"0,0,0,0,1,1,1,1,1,0,0");
    }
    elseif (($objAxpDB->GetStatus("fnstatus") == 2) || ($objAxpDB->GetStatus("fnstatus") == 5))
    {
            $objAxpDB->ButtonShow("cetak, baru, tutup");
            $objAxpDB->FormLocked("1,1,1,1,1,1,1,1");
            $objAxpDB->GridLocked(0,"1,1,1,1,1,1,1,1,1,1,1");
            $objAxpDB->GridHidden(0,"0,0,0,0,1,1,1,1,1,0,0");

    } elseif (($objAxpDB->GetStatus("fnstatus") == 3) || ($objAxpDB->GetStatus("fnstatus") == 9)) {
            $objAxpDB->ButtonShow("tutup");
            $objAxpDB->FormLocked("1,1,1,1,1,1,1,1");
            $objAxpDB->GridLocked(0,"1,1,1,1,1,1,1,1,1,1,1");
            $objAxpDB->GridHidden(0,"0,0,0,0,1,1,1,1,1,0,0");
    }
   
    
    
    if($_REQUEST['ajax']) 
	{
		switch($_REQUEST['code']) 
		{
			case "grid":
                            ob_start();
                            $_REQUEST['id']=0;
                            if($_REQUEST['fnpr_type']==0) {
                                $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name,ftsupplier_code FROM tlstock_hdr_bahan_baku {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
                                $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value +'&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
                                $objAxpDB->GridScript(0,1," onChange=\"{$ajaxItem}\"");
                            }
                            elseif($_REQUEST['fnpr_type']==1)
                            {
                                $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr_setengah_jadi {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
                                $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value +'&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
                                $objAxpDB->GridScript(0,1," onChange=\"{$ajaxItem}\"");
                            }
                            elseif($_REQUEST['fnpr_type']==2){
                                $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code,ftitem_name FROM tlstock_hdr_sparepart {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
                                $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value +'&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
                                $objAxpDB->GridScript(0,1," onChange=\"{$ajaxItem}\"");
                            }
                            elseif($_REQUEST['fnpr_type']==3){
                                $objAxpDB->Lookup("ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr WHERE fnpo_include=1 and fnstatus = 1 ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
                                $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value +'&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
                                $objAxpDB->GridScript(0,1," onChange=\"{$ajaxItem}\"");
                            }

                            $objAxpDB->GridSQL(0, "SELECT fnindex, ftitem_code,fnqty,ftuom_code,ffformula,fnqty_base,ftuom_code_base,fnqty-ifnull(fnqty_accept,0) as fnqty_accept,fnqty_base-ifnull(fnqty_accept_base,0) as fnqty_accept_base, fdclosing_date,fnstatus FROM txpurchase_request_det");
                            $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;
                                RowBuild0();
                            <?php
                            break;
                }
                die("");
                exit;
    }

    if(isset($_REQUEST['id'])&&($_REQUEST['id'])!=0)
    {
        $ssql="SELECT fnpr_type
                     FROM txpurchase_request_hdr
                        WHERE fnid='{$_REQUEST['id']}'";
        $fnpr_type=RetRstField($ssql);

        if($fnpr_type=="0") {
            $objAxpDB->LookupGrid(0, "ftitem_code", "SELECT ftitem_code, ftitem_name,ftsupplier_code FROM tlstock_hdr_bahan_baku {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
            $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value + '&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
        }
        elseif($fnpr_type=="1")
        {
            $objAxpDB->LookupGrid(0, "ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr_setengah_jadi {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
            $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value + '&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
        }
        elseif($fnpr_type=="2")
        {
            $objAxpDB->LookupGrid(0, "ftitem_code", "SELECT ftitem_code, ftitem_name FROM tlstock_hdr_sparepart {$where_ftitem_code} ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
            $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value + '&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
        }
        elseif($fnpr_type=="3")
        {   
            $objAxpDB->LookupGrid(0, "ftitem_code", "SELECT ftitem_code,ftitem_name FROM tlstock_hdr WHERE fnpo_include=1 and fnstatus = 1 ORDER BY ftitem_code", "ftitem_code", "ftitem_name", -1, False);
            $ajaxItem="ajax_do('pembelian.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=item&fnpr_type='+ document.getElementById('fnpr_type').value + '&ObjLokasi=ftuom_codeD0_N_&ftitem_code=' + this.value + '&index=_N_');";
        }
       
       $objAxpDB->GridScript(0, 1, " onChange=\"{$ajaxItem}\"");
    }

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