<?php
    $objAxpDB->ViewName("Filter Nama Barang");
    $objAxpDB->ViewSQL("SELECT a.fnid, a.ftspk_no,a.fdtrans_date,
                                a.ftpos_no,d.ftprocess_name,a.ftnotes, c.fttrans_status_name AS ftstatus
                                FROM txspk_hdr a 
								LEFT JOIN tstransaction_status c ON a.fnstatus = c.fntrans_status_code AND c.fntrans_group_code = 2
								LEFT JOIN tlprocess_setengah_jadi d ON a.ftdepartment_code=d.ftprocess_code
								WHERE a.ftdepartment_code='BP'");
    $objAxpDB->ViewCaption("ID, No. SPK, Tgl. Transaksi, No. POS,Department, Keterangan, Status");

    $objAxpDB->FormName("Filter Nama Barang");
    $objAxpDB->FormSQL("select ftbom_type,ftitem_code from tlbom_header");
    $objAxpDB->FormCaption("Jenis Barang,Kode / Nama Barang");
    $objAxpDB->FormPosition("TL,TL");

    $objAxpDB->GridSQL(0, "SELECT fnindex,ftitemdetail_code,ftitemdetail_name,ftoumdetail_code FROM tlbom_detail");
    $objAxpDB->GridCaption(0,"No.,Kode Barang, Nama Barang, Satuan" );
	$objAxpDB->GridSize(0, " ,40,110 ,28 ");
	$objAxpDB->GridAutoAdd(0, False);
	$objAxpDB->Lookup('ftbom_type', "SELECT 0 AS A,'Barang Bahan Proses' AS B UNION ALL SELECT 1 AS A,'Barang Bahan Jadi' AS B", "A", "B", -1, true);
	
    $ajaxGrid="ajax_do_grid0('ppic.php?form=".$_REQUEST['form']."&mode=".$_REQUEST['mode']."&id=0&ajax=1&code=grid&ftbom_type='+ document.getElementById('ftbom_type').value + '&ftitem_code='+ document.getElementById('ftitem_code').value);";
	$ajax1=" OnClick=\"if(ValFilterBarang()==false) { return false; } {$ajaxGrid}\"";
	$objAxpDB->FormLayout(1,"&nbsp;<input type='button' id='cmd_grid_list' name='cmd_grid_list' value='Cari' {$ajax1}>");

    $objAxpDB->SetStatus("id, fnstatus");
    if ($objAxpDB->GetStatus("id") == "")
            $objAxpDB->ButtonShow("baru, cetak_daftar, export_excel ,  tutup");
    elseif ($objAxpDB->GetStatus("id") == 0) {
            $objAxpDB->FormLocked("0,0,0,1,0,0,1");
            $objAxpDB->ButtonShow("reset, simpan, tutup");
            $objAxpDB->GridLocked(0, "1,1,1,1,1,0,0,0,0,1");

    } elseif ($objAxpDB->GetStatus("fnstatus") == 1) {
            $objAxpDB->FormLocked("1,1,1,1,1,1,1,1");
            $objAxpDB->ButtonShow("cetak, batal, tutup");
            $objAxpDB->GridLocked(0, "1,1,1,1,1,1,1,1,1,1");
    } 	
    if($_REQUEST['ajax']) {
           switch($_REQUEST['code']) {
           case "grid":
               ob_start();
                       $objAxpDB->GridSQL(0, "SELECT  b.fnindex AS fnindex,a.ftitem_code as ftitemdetail_code,a.ftitem_name as ftitemdetail_name,a.ftuom_code as ftoumdetail_code
												FROM vBomTypeHeader a
											  LEFT JOIN tlbom_detail b ON 1=0
												WHERE a.ftitem_type='{$_REQUEST['ftbom_type']}'
																					AND a.ftitem_code LIKE '%{$_REQUEST['ftitem_code']}%'
																					OR  a.ftitem_name LIKE '%{$_REQUEST['ftitem_code']}%' #");
					   $objAxpDB->GridSize(0, "5,41,106 ,18 ");
					   // $ajaxGrid="&ftitem_code='+ document.getElementById('ftitemdetail_codeD0_N_').value +'&ftitem_name='+ document.getElementById('ftitemdetail_nameD0_N_').value";
					   // $x="document.getElementById('ftitemdetail_codeD0_N_').value";
					   // $x.="Nama Barang = + document.getElementById('ftitemdetail_nameD0_N_').value \\n";
					   // $x.="document.getElementById('ftoumdetail_codeD0_N_').value ";
					   // $ajaxGrid="alert({$x})";
					   // $ajaxGrid="window.close()";
					   $ajaxGrid="&ftbom_type='+ document.getElementById('ftbom_type').value +'&ftitem_code='+ document.getElementById('ftitemdetail_codeD0_N_').value";
					   $ajaxGrid="open('?form=bom&mode=edit&id=0{$ajaxGrid},'mywindow','width=900,height=800,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,screenX=100,screenY=2')";
					   $ajaxGrid="OnClick=\"{$ajaxGrid}\"";
					   $objAxpDB->GridLayout(0,3,"&nbsp;<input type='button' id='cmd_grid_list' name='cmd_grid_list' value='PILIH' {$ajaxGrid}>");
                       $objAxpDB->GridCaption(0,"No., Kode Barang, Nama Barang, Satuan" );
					   $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;
                    RowIndex0();
                    reSize();
               <?
               break;
           }
           die("");
           exit;
    }

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

?>
