/* Cash and Bank */
// Payment <=250rb
function search_payment(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt').datagrid('load',{
		payment_number 	: $('#txt_no').val(),
		payment_dsc 	: $('#txt_description').val(),
		date_from 		: $('#txt_from_date').datebox('getValue'),
		date_to 		: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});
}
// Deposit
function search_deposit(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt_deposit').datagrid('load',{
		deposit_no		: $('#txt_deposit_no').val(),
		deposit_memo	: $('#txt_deposit_memo').val(),
		from_date   	: $('#txt_from_date').datebox('getValue'),
		to_date     	: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});		
}

// Sweep Bank
function search_swapbank(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt_swapbank').datagrid('load',{
		swapbank_no		: $('#txt_swapbank_no').val(),
		swapbank_memo	: $('#txt_swapbank_memo').val(),
		from_date   	: $('#txt_from_date').datebox('getValue'),
		to_date     	: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});	
}

// Piutang Afiliasi
function search_afiliasi(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt').datagrid('load',{
		transfer_from	: $('#txt_transferfrom').val(),
		transfer_to		: $('#txt_transferto').val(),
		date_from   	: $('#txt_from_date').datebox('getValue'),
		date_to     	: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});
}

// Payment Afiliasi
function search_payment_afiliasi(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt').datagrid('load',{
		transfer_from	: $('#txt_transferfrom').val(),
		transfer_to		: $('#txt_transferto').val(),
		date_from   	: $('#txt_from_date').datebox('getValue'),
		date_to     	: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});
}

// Piutang Karyawan
function search_piutang_karyawan(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt_piutang').datagrid('load',{
		piutang_no		: $('#txt_piutang_no').val(),
		piutang_memo	: $('#txt_piutang_memo').val(),
		date_from   	: $('#txt_from_date').datebox('getValue'),
		date_to     	: $('#txt_to_date').datebox('getValue'),
		status			: TransStatus
	});
}

// Payment Karyawan
function search_payment_karyawan(){
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
	$('#tt_payment').datagrid('load',{
		payment_karyawan_no		: $('#txt_payment_karyawan_no').val(),
		payment_karyawan_memo	: $('#txt_payment_karyawan_memo').val(),
		from_date   			: $('#txt_from_date').datebox('getValue'),
		to_date     			: $('#txt_to_date').datebox('getValue'),
		status					: TransStatus
	});
}


// Transfer to Petty Cash
function search_trasfer_to_petty_cash(){
	$('#tt').datagrid('load',{
		transfer_from	: $('#txt_transferfrom').val(),
		transfer_to 	: $('#txt_transferto').val(),
		from_date 		: $('#txt_from_date').datebox('getValue'),
		to_date 		: $('#txt_to_date').datebox('getValue'),
		status			: $('input[name=rdo_status]:checked').val()
	});
}
/*End of Cash and Bank*/

/* Purchase */
function search_purchase(){
    TransStatus	= new Array();
    
    $.each($("input[name='TransStatus']:checked"), function() {
        TransStatus.push($(this).val());	 
    });
	
    $('#tt').datagrid('load',{
        id          : $('#txt_no').val(),
        desc        : $('#txt_desc').val(),
        vendor_id   : $('#cmb_vendor').val(),
        date_from   : $('#txt_date_from').datebox('getValue'),
        date_to     : $('#txt_date_to').datebox('getValue'), 
        status      : TransStatus
    });  	
}
/* End of Purchase */

/* Sales */
function search_sales(){
	TransStatus	= new Array();
	$.each($("input[name='chk_transstatus']:checked"), function() {
		TransStatus.push($(this).val());	 
	});
	
    $('#tt').datagrid('load',{
		id		 	: $('#txt_no').val(),
		desc  		: $('#txt_desc').val(),
		date_from   : $('#txt_date_from').datebox('getValue'),
		date_to     : $('#txt_date_to').datebox('getValue'), 
		status		: TransStatus
	});  
}
/* End of Sales */

/* Ferry / 01/01/2015 / fro Search COA by AccountSubType */
function search_coa(){
    var account_type    = $('#account_type').combogrid('grid');	// get datagrid object
    var type_selected   = account_type.datagrid('getSelected');// get the selected row
    
    var month_type      = $('#cbo_period_month').combobox('getValue');
    var year_type       = $('#nsp_period_year').val();
    
    var type 		= null;
    var trans_status	= new Array();
	
    $.each($('input:checkbox[name="TransStatus[]"]:checked'),function(){
        trans_status.push($(this).val());
    });
    
    if(type_selected !== null ){
        type = type_selected.AccountSubTypeID;
    }
    
    $('#tt').datagrid('load',{
        account	: $('#account_no').val(),
        name	: $('#account_name').val(),
        type	: type, 
        status	: trans_status,
        month   : month_type,
        year    : year_type
    });		
}

function search_bank(){
    chk_TransStatus = new Array();

    $.each($('input[name="chk_TransStatus"]:checked'),function(){
        chk_TransStatus.push($(this).val());
    });

    $('#tt').datagrid('load',{
        BankCode	: $('#txt_BankCode').val(),
        BankName	: $('#txt_BankName').val(),
        TransStatus	: chk_TransStatus
    });	
}	

function search_pricelist(){
    $('#dtg_price_list').datagrid('load',{
        item_name: $('#txt_item_name').val(),
        branch_name: $('#txt_branch_name').val()			
    });		
}

function search_branch(){
    trans_status = new Array();

    $.each($("input[name='chk_status[]']:checked"), function() {
        trans_status.push($(this).val());	 
    });
	
    $('#tt').datagrid('load',{
        branch_code : $('#txt_find_branch_code').val(),
        branch_name	: $('#txt_find_branch_name').val(),
        status 		: trans_status
    });
}

//search company branch fine master
function search_company_branch_new(company_code){
    trans_status = new Array();

    $.each($("input[name='chk_status[]']:checked"), function() {
        trans_status.push($(this).val());	 
    });
	
    $('#tt').datagrid('load',{
        branch_code : $('#txt_find_branch_code').val(),
        branch_name	: $('#txt_find_branch_name').val(),
        status 		: trans_status
    });
}


function search_customers(){
	chk_TransStatus = new Array();
	$.each($("input[name='chk_TransStatus']:checked"), function() {
	  chk_TransStatus.push($(this).val());	 
	});
	
    $('#tt').datagrid('load',{
        CustomerCode    : $('#txt_CustomerCode').val(),
        CustomerName 	: $('#txt_CustomerName').val(),
		CustomerCity	: $('#cmb_CustomerCity').combobox('getValue'), 
        CurrencyCode 	: $('#cmb_CurrencyCode').combobox('getValue'),
		BranchCode 		: $('#cmb_branch').combobox('getValue'),
        TransStatus		: chk_TransStatus
    });
}

function search_vendors(){
    TransStatus = new Array();

    $.each($('input:checkbox[name="TransStatus[]"]:checked'),function(){
        TransStatus.push($(this).val());
    });

    $('#tt').datagrid('load',{
        vendor_no	: $('#vendorno').val(),
        vendor_name : $('#vendorname').val(),
        currency 	: $('#cmb_currency').combobox('getValue'),
		VendorCity 	: $('#cmb_VendorCity').combobox('getValue'),
        status 		: TransStatus
    });
}

function search_inv_adjustment(){
	/* var adjust_type = new Array();
	$.each($("input[name='chk_adjusttype[]']:checked"), function() {
	  adjust_type.push($(this).val());	 
	}); */

    $('#tt').datagrid('load',{
        adjust_no       : $('#adjustment_no').val(),
        type_name	: $('#type_name').val(),
        adj_val 	: $('input[name=chk_adjust_type_value]:checked').val(),
        adj_qty 	: $('input[name=chk_adjust_type_qty]:checked').val(),
        from_date 	: $('#txt_from_date').datebox('getValue'),
        to_date 	: $('#txt_to_date').datebox('getValue'),
        status 		: $('input[name=rdo_status]:checked').val()
    });
}

function search_reconcile(){
	$('#tt').datagrid('load',{
		AccountNo 		: $('#cmb_bank_account').combobox('getValue'),
		from_date 		: $('#txt_from_date').datebox('getValue'),
		to_date 		: $('#txt_to_date').datebox('getValue')
	});
}

function search_payment_account_popup(){
	$('#tt_choose_payment').datagrid('load',{
		AccountNo 	: $('#txt_account_number').val(),
		AccountName : $('#txt_account_name').val()
	});
}

function search_payment_department_popup(){
	$('#tt_choose_department_payment').datagrid('load',{
		CodeDepartment 	: $('#txt_department_code').val(),
		NameDepartment  : $('#txt_department_name').val()
	});
}
//==== END 15 10 2014 TAGOR

/*
Author 		  : Wahyu
Last update   : 11/10/2014
Desc          : for search expense cashbon
*/
function search_expense_cashbon(){
	if($('#ByDate').is(':checked')){
	    $("#filter_date").show();
		var cashbon_from_date = $('#cashbon_from_date').datebox('getValue');
		var cashbon_to_date  = $('#cashbon_to_date').datebox('getValue');	
    } else {
		 $("#filter_date").hide();
	}
		
	$('#grid_expense_cashbon').datagrid('load',{
		expense_cashbon_no: $('#txt_cashbon_no').val(),
		expense_cashbon_memo:  $('#txt_cashbon_memo').val(),
		TransStatus		: $('input[name=TransStatus]:checked').val(),
		cashbon_from_date   : cashbon_from_date,
		cashbon_to_date     : cashbon_to_date	
	});		
}

function search_payment_cashbon(){
	TransStatus	= new Array();
	
	$.each($("input[name='TransStatus']:checked"), function() {
		TransStatus.push($(this).val());	 
	});
	
    $('#list_expense_payment').datagrid('load',{
		id		 	: $('#txt_no').val(),
		memo  		: $('#txt_memo').val(),
		date_from   : $('#txt_date_from').datebox('getValue'),
		date_to     : $('#txt_date_to').datebox('getValue'), 
		status		: TransStatus
	});
}

function search_currency(){
	TransStatus = new Array();
	
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	
    $('#tt').datagrid('load',{
		currency_code: $('#txt_currency_code').val(),
		currency_name: $('#txt_currency_name').val(),
		TransStatus		: TransStatus
	});	
}

function search_department(){
	TransStatus = new Array();
	
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	
    $('#tt').datagrid('load',{
		department_code: $('#txt_department_code').val(),
		department_name: $('#txt_department_name').val(),
		TransStatus	   : TransStatus
	});	
	//alert(TransStastus);
}

function search_journal_voucher(){
	txt_DateFrom	= ''
	txt_DateTo		= '';
	if($('#ByDate').is(':checked')){
		txt_DateFrom = $('#txt_DateFrom').datebox('getValue');
		txt_DateTo  = $('#txt_DateTo').datebox('getValue');	
    }
		
	$('#journal_voucher').datagrid('load',{
		JVchNumber		: $('#txt_JVchNumber').val(),
		JVchDesc		: $('#txt_JVchDesc').val(),
		JVchDateFrom	: txt_DateFrom,
		JVchDateTo		: txt_DateTo
	});		
}

function search_account_balance(){
	/* var TransStatus = new Array();
		$.each($("input[name='TransStatus[]']:checked"), function() {
		  TransStatus.push($(this).val());	 
		}); */
    $('#t_account_balance').datagrid('load',{
		account_number: $('#txt_account_no').val(),
		account_name: $('#txt_account_name').val(),
		account_type: $('#type_account').val()
	});	
}

function search_payment_listing_cashbon(){
	var TransStatus = new Array();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	
	if($('#ByDate').is(':checked')){
	    $("#filter_date").show();
		var listing_from_date = $('#listing_from_date').datebox('getValue');
		var listing_to_date  = $('#listing_to_date').datebox('getValue');	
    } else {
		 $("#filter_date").hide();
	}
		
	$('#grid_payment_list_cashbon').datagrid('load',{
		TransStatus		: TransStatus,
		listing_from_date   : listing_from_date,
		listing_to_date     : listing_to_date	
	});		
}	

function search_choose_item(){
    var item_category = $('#cmb_item_category').combobox('getValue');

    if(item_category){
        $('#tt_choose_item').datagrid('load',{
            item_categori : item_category,
            item_code :  $('#txt_item_code').val(),	
            item_desc :  $('#txt_item_desc').val()	
        });
        
        $('#cmb_item_category').combobox('readonly');
    }   
}

function search_choose_item2(){
    var item_category = $('#cmb_item_category').combobox('getValue');
        
    $('#tt_choose_item').datagrid('load',{
        item_categori : item_category,
        item_code :  $('#txt_item_code').val(),	
        item_desc :  $('#txt_item_desc').val()	
    });
}

function search_choose_item3(){
    $('#tt_choose_servis').datagrid('load',{
        item_code :  $('#txt_item_code_servis').val(),	
        item_desc :  $('#txt_item_desc_servis').val()	
    });
}

function search_choose_item4(){
    $('#tt_choose_advance').datagrid('load',{
        item_code :  $('#txt_item_code_advance').val(),	
        item_desc :  $('#txt_item_desc_advance').val()	
    });
}

function search_inventory(){
    $('#tt_choose_inventory').datagrid('load',{
        item_categori 	: $('#cmb_inventory_category').combobox('getValue'),
        item_code 		: $('#txt_inventory_code').val(),	
        item_desc 		: $('#txt_inventory_desc').val()	
    });		
}

/* Author : Fachri / fungsi untuk search job cos, daily production dan daily production amount */
function search_production(){
   var item_category=$('#cmb_item_category_production').combobox('getValue');
   if(item_category){
		$('#tt_choose_production').datagrid('load',{
			item_categori : item_category,
			item_code :  $('#txt_item_code_production').val(),	
			item_desc :  $('#txt_item_desc_production').val()	
		});	
	}   
}
function search_production_amount(){
   var item_category=$('#cmb_item_category_production_amount').combobox('getValue');
   if(item_category){
		$('#tt_choose_production_amount').datagrid('load',{
			item_categori : item_category,
			item_code :  $('#txt_item_code_production').val(),	
			item_desc :  $('#txt_item_desc_production').val()	
		});	
	}   
}

function search_job_costing(id_item){
   var item_category=$('#cmb_item_job_costing').combobox('getValue');
   if(item_category){
		$('#tt_choose_job_costing').datagrid('load',{
			item_categori : id_item,
			item_code :  $('#txt_item_code_job_costing').val(),	
			item_desc :  $('#txt_item_desc_job_costing').val()	
		});	
	}   
}

/* end */

/*
Author 		  : Herpan
Last update   : 23/7/2014
Desc          : for search purchase requisition
*/
function search_purchase_requisition(){
    var PReqDateStart 	='';
	var PReqDateEnd   	='';
	var TransStatus 	= new Array();
	//var approval		= $('input[name=rdo_approval]:checked').val();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	if($('#ByDate').is(':checked')){
		PReqDateStart=$('#PReqDateStart').datebox('getValue');
		PReqDateEnd  =$('#PReqDateEnd').datebox('getValue');			
	}
    $('#tt').datagrid('load',{
		PReqNumber 		: $('#PReqNumber').val(),
		PReqDesc  		: $('#PReqDesc').val(),
		TransStatus		: TransStatus,
		PReqDateStart   : PReqDateStart,
		PReqDateEnd     : PReqDateEnd,
        approval 		: $('input[name=rdo_approval]:checked').val()		
	});		
}

/*
Author 		  : Ladur
Last update   : 23/7/2014
Desc          : for search sales quotatin
*/
function search_sales(){
	var customer ='';
    var SQuoDateStart ='';
	var SQuoDateEnd   ='';
	var TransStatus = new Array();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	console.log(TransStatus);
	if($('#ByDate').is(':checked')){
			SQuoDateStart=$('#SQuoDateStart').datebox('getValue');
			SQuoDateEnd  =$('#SQuoDateEnd').datebox('getValue');			
		}
    $('#tt').datagrid('load',{
		customer  		: $('#cmb_sales_order_by').val(),
		SQuoNumber 		: $('#SQuoNumber').val(),
		SQuoDesc  		: $('#SQuoDesc').val(),
		TransStatus		: TransStatus,
		SQuoDateStart   : SQuoDateStart,
		SQuoDateEnd     : SQuoDateEnd		
	});		
}

/*
Author 		  : Ladur
Last update   : 23/7/2014
Desc          : for search sales order
*/
function search_sales_order(){
	var customer ='';
    var SOrdDateStart ='';
	var SOrdDateEnd   ='';
	var TransStatus = new Array();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	console.log(TransStatus);
	if($('#ByDate').is(':checked')){
			SOrdDateStart=$('#SOrdDateStart').datebox('getValue');
			SOrdDateEnd  =$('#SOrdDateEnd').datebox('getValue');			
		}
    $('#tt').datagrid('load',{
		customer  		: $('#cmb_sales_order_by').val(),
		SOrdNumber 		: $('#SOrdNumber').val(),
		SOrdDesc  		: $('#SOrdDesc').val(),
		TransStatus		: TransStatus,
		SOrdDateStart   : SOrdDateStart,
		SOrdDateEnd     : SOrdDateEnd		
	});		
}

/*
Author          : Ladur
Last update     : 23/7/2014
Desc            : for search delivery order
*/
function search_delivery_order(){
    var customer ='';
    var DOrdDateStart ='';
    var DOrdDateEnd   ='';
    var TransStatus = new Array();

    $.each($("input[name='TransStatus[]']:checked"), function() {
        TransStatus.push($(this).val());	 
    });

    console.log(TransStatus);

    if($('#ByDate').is(':checked')){
        DOrdDateStart=$('#DOrdDateStart').datebox('getValue');
        DOrdDateEnd  =$('#DOrdDateEnd').datebox('getValue');			
    }
    
    $('#tt').datagrid('load',{
        customer  		: $('#cmb_sales_order_by').val(),
        DOrdNumber 		: $('#DOrdNumber').val(),
        DOrdDesc  		: $('#DOrdDesc').val(),
        TransStatus		: TransStatus,
        DOrdDateStart           : DOrdDateStart,
        DOrdDateEnd             : DOrdDateEnd		
    });		
}

/*
Author 		  : Ladur
Last update   : 23/7/2014
Desc          : for search sales receipt
*/
function search_sales_receipt(){
	var customer ='';
    var SRecDateStart ='';
	var SRecDateEnd   ='';
	var TransStatus = new Array();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	console.log(TransStatus);
	if($('#ByDate').is(':checked')){
			SRecDateStart=$('#SRecDateStart').datebox('getValue');
			SRecDateEnd  =$('#SRecDateEnd').datebox('getValue');			
		}
    $('#tt').datagrid('load',{
		customer  		: $('#cmb_sales_receipt_by').val(),
		SRecNumber 		: $('#SRecNumber').val(),
		SRecDesc  		: $('#SRecDesc').val(),
		TransStatus		: TransStatus,
		SRecDateStart   : SRecDateStart,
		SRecDateEnd     : SRecDateEnd		
	});		
}

/*
Author          : Ladur
Last update     : 23/7/2014
Desc            : for search sales return
*/
function search_sales_return(){
    var customer ='';
    var SRetDateStart ='';
    var SRetDateEnd   ='';
    var TransStatus = new Array();

    $.each($("input[name='TransStatus[]']:checked"), function() {
        TransStatus.push($(this).val());	 
    });

    console.log(TransStatus);

    if($('#ByDate').is(':checked')){
        SRetDateStart=$('#SRetDateStart').datebox('getValue');
        SRetDateEnd  =$('#SRetDateEnd').datebox('getValue');			
    }
    
    $('#tt').datagrid('load',{
        customer  		: $('#cmb_sales_order_by').val(),
        SRetNumber 		: $('#SRetNumber').val(),
        SRetDesc  		: $('#SRetDesc').val(),
        TransStatus		: TransStatus,
        SRetDateStart   : SRetDateStart,
        SRetDateEnd     : SRetDateEnd		
    });		
}

/*
Author 		  : Ladur
Last update   : 23/7/2014
Desc          : for search sales invoice
*/
function search_sales_invoice(){
	var customer ='';
    var SInvDateStart ='';
	var SInvDateEnd   ='';
	var TransStatus = new Array();
	$.each($("input[name='TransStatus[]']:checked"), function() {
	  TransStatus.push($(this).val());	 
	});
	console.log(TransStatus);
	if($('#ByDate').is(':checked')){
			SInvDateStart=$('#SInvDateStart').datebox('getValue');
			SInvDateEnd  =$('#SInvDateEnd').datebox('getValue');			
		}
    $('#tt').datagrid('load',{
		customer  		: $('#cmb_sales_order_by').val(),
		SInvNumber 		: $('#SInvNumber').val(),
		SInvDesc  		: $('#SInvDesc').val(),
		TransStatus		: TransStatus,
		SInvDateStart   : SInvDateStart,
		SInvDateEnd     : SInvDateEnd		
	});		
}

/*
Author          : Ferry
Last update     : 29/10/2014
Desc            : for search Item Product
*/
function search_item(){
    var ItemType	= new Array();
	var TransStatus	= new Array();
    $.each($("input[name='ItemType']:checked"), function() {
      ItemType.push($(this).val());	 
    });
	$.each($("input[name='TransStatus']:checked"), function() {
      TransStatus.push($(this).val());	 
    });

    $('#tt').datagrid('load',{
        no        		: $('#txt_no').val(),
        desc 			: $('#txt_desc').val(),
        item_category  	: $('#cmb_item_category').val(),
        item_type 		: ItemType,
        status 			: TransStatus
    });
}

/*
Author 		  : Fachri
Last update   : 15/01/2015
Desc          : for search purchase requisition
*/
function search_import_type(){
    $('#tt').datagrid('load',{
        type 			: $('input[name=rdo_transaction_type]:checked').val()		
	});		
}

/*

/*
Author          : Ladur
Last update     : 29/10/2014
Desc            : for search Item Product
*/
function search_master(){
//	var DateFrom = $('#txt_date_from').datebox('getValue');
//	var DateTo   = $('#txt_date_to').datebox('getValue');
//	
//	if($('#ByDate').is(':checked')){
//		SInvDateStart=$('#DateStart').datebox('getValue');
//		DateEnd  =$('#DateStart').datebox('getValue');			
//	}
	txt_DateFrom	= '';
	txt_DateTo		= '';
	if($('#ByDate').is(':checked')){
		txt_DateFrom	= $('#txt_date_from').datebox('getValue');
		txt_DateTo		= $('#txt_date_to').datebox('getValue');
	}
	
	TransStatus = new Array();
	$.each($('input[name="TransStatus"]:checked'),function(){
		TransStatus.push($(this).val());
	});
	
    $('#tt').datagrid('load',{
		id 			: $('#txt_no').val(),
		desc  		: $('#txt_desc').val(),
		date_from	: txt_DateFrom,
		date_to		: txt_DateTo,
		status		: TransStatus
	});	
}

function search_inventories(){
    $('#tt').datagrid('load',{
        ItemCode        : $('#txt_item_code').val(),
        ItemDesc 		: $('#txt_item_desc').val(),
        BranchCode  	: $('#cmb_branch').val()
    });
}

function search_account_history(){
    var DateStart	= '';
	var DateEnd 	= '';
	if($('#ByDate').is(':checked')){
		DateStart = $('#txt_DateFrom').datebox('getValue');
		DateEnd  = $('#txt_DateTo').datebox('getValue');
    }
	
	var chk_TransType = new Array();
	$.each($("input[name='chk_TransType']:checked"), function() {
		chk_TransType.push($(this).val());	 
	});
		
    $('#gd_account_history').datagrid('load',{
		AccountNumber	: $('#txt_AccountNo').val(),
		CustomerCode	: $('#cmb_Customer').combobox('getValue'),
		VendorCode		: $('#cmb_Vendor').combobox('getValue'),
		DepartmentCode	: $('#cmb_Department').combobox('getValue'),
		TransType	  	: chk_TransType,
		DateFrom  		: txt_DateFrom,
		DateTo  		: txt_DateTo
	});	
}

function search_warehouse(){
	WarehouseName 	= $('#txt_warehouse_name').val();
	Description 	= $('#txt_description').val();
	TransStatus		= new Array();
	
	$.each($('input[name="chk_trans_status[]"]:checked'),function(){
		TransStatus.push( $(this).val() );
	});
	
	$('#tt').datagrid('load',{
		warehouse_name: WarehouseName, 
		warehouse_desc: Description, 
		TransStatus: TransStatus
	});
}

function search_data(){
    searchParameter = {};

    // For textbox ID or Code
    if($('#txt_IDNumber').val()!=''){
        searchParameter['txt_IDNumber'] = $('#txt_IDNumber').val();
    }
	
    // For textbox Name
    if($('#txt_Name').val()!=''){
        searchParameter['txt_Name'] = $('#txt_Name').val();
    }
	
    // For textbox Description
    if($('#txt_Description').val()!=''){
        searchParameter['txt_Description'] = $('#txt_Description').val();
    }
	
    // For textbox Transfer From
    if($('#txt_TransferFrom').val()!=''){
        searchParameter['txt_TransferFrom'] = $('#txt_TransferFrom').val();
    }
	
    // For textbox Transfer To
    if($('#txt_TransferTo').val()!=''){
        searchParameter['txt_TransferTo'] = $('#txt_TransferTo').val();
    }
	
    // For combobox Customer
    if($('#cmb_Customer').length > 0 && $('#cmb_Customer').combobox('getValue')!=''){
        searchParameter['cmb_Customer'] = $('#cmb_Customer').combobox('getValue');
    }
	
    // For combobox Customer
    if($('#cmb_Vendor').length > 0 && $('#cmb_Vendor').val()!=''){
        searchParameter['cmb_Vendor'] = $('#cmb_Vendor').val();
    }

    // For combobox Department
    if($('#cmb_Department').length > 0 && $('#cmb_Department').combobox('getValue')!=''){
        searchParameter['cmb_Department'] = $('#cmb_Department').combobox('getValue');
    }

    // For combobox Department
    if($('#cmb_Bank').length > 0 && $('#cmb_Bank').combobox('getValue')!=''){
        searchParameter['cmb_Bank'] = $('#cmb_Bank').combobox('getValue');
    }

    // For combobox Item Category
    if($('#cmb_ItemCategory').length > 0 && $('#cmb_ItemCategory').val()!=''){
        searchParameter['cmb_ItemCategory'] = $('#cmb_ItemCategory').val();
    }
	
    // For combobox Customer Location
    if($('#cmb_CustomerCity').length > 0 && $('#cmb_CustomerCity').combobox('getValue')!=''){
        searchParameter['cmb_CustomerCity'] = $('#cmb_CustomerCity').combobox('getValue');
    }

    // For combobox Currency Code
    if($('#cmb_CurrencyCode').length > 0 && $('#cmb_CurrencyCode').combobox('getValue')!=''){
        searchParameter['cmb_CurrencyCode'] = $('#cmb_CurrencyCode').combobox('getValue');
    }

    // for combogrid Account Type
    if($('#cmb_AccountType').length > 0 && $('#cmb_AccountType').combogrid('grid').datagrid('getSelected')!=null){
        searchParameter['cmb_AccountType'] = $('#cmb_AccountType').combogrid('grid').datagrid('getSelected').AccountSubTypeID;
    }
	
    // For textbox Date From and Date To
    if($('#chk_ByDate').is(':checked')){
        searchParameter['txt_DateFrom'] = $('#txt_DateFrom').datebox('getValue');
        searchParameter['txt_DateTo']	= $('#txt_DateTo').datebox('getValue');
    }

    // For checkbox Item Type
    if($('input[name="chk_ItemType"]').length > 0){
        searchParameter['chk_ItemType'] = new Array();

        $.each($('input[name="chk_ItemType"]:checked'),function(){
            searchParameter['chk_ItemType'].push($(this).val());
        });
    }

    // For checkbox Adjustment Type
    if($('input[name="chk_AdjustmentType"]').length > 0){
        searchParameter['chk_AdjustmentType'] = new Array();

        $.each($('input[name="chk_AdjustmentType"]:checked'),function(){
            searchParameter['chk_AdjustmentType'].push($(this).val());
        });
    }
	
    // For checkbox Transaction Type
    if($('input[name="chk_TransType"]').length > 0){
        searchParameter['chk_TransType'] = new Array();

        $.each($('input[name="chk_TransType"]:checked'),function(){
            searchParameter['chk_TransType'].push($(this).val());
        });
    }
	
    // For checkbox TransStatus
    if($('input[name="chk_TransStatus"]').length > 0){
        searchParameter['chk_TransStatus'] = new Array();

        $.each($('input[name="chk_TransStatus"]:checked'),function(){
            searchParameter['chk_TransStatus'].push($(this).val());
        });
    }

    // Load data grid with given parameter
    $('#grid').datagrid('load',{
        param: searchParameter
    });
}