private void search() {
    try {

      String calendar_state_id = calendarStateItem.getValueAsString();
      Criteria criteria = new Criteria();
      if (calendar_state_id != null && !calendar_state_id.trim().equals("")) {
        criteria.setAttribute("calendar_state_id", new Integer(calendar_state_id));
      }
      String calendar_event_id = secCalendarTypeItem.getValueAsString();
      if (calendar_event_id != null && !calendar_event_id.trim().equals("")) {
        criteria.setAttribute("calendar_event_id", new Integer(calendar_event_id));
      }
      boolean checkedDate = byCalendarDayItem.getValueAsBoolean();
      if (checkedDate) {
        Date calendar_day = calendarDayItem.getValueAsDate();
        if (calendar_day != null) {
          criteria.setAttribute("calendar_day", calendar_day);
        }
      }
      String calendar_description = descriptionItem.getValueAsString();
      if (calendar_description != null && !calendar_description.trim().equals("")) {
        criteria.setAttribute("calendar_description", calendar_description);
      }
      String calendar_comment = commentItem.getValueAsString();
      if (calendar_comment != null && !calendar_comment.trim().equals("")) {
        criteria.setAttribute("calendar_comment", calendar_comment);
      }

      DSRequest dsRequest = new DSRequest();
      dsRequest.setAttribute("operationId", "searchAllSecularCalendars");
      listGrid.invalidateCache();
      listGrid.filterData(
          criteria,
          new DSCallback() {
            @Override
            public void execute(DSResponse response, Object rawData, DSRequest request) {}
          },
          dsRequest);
    } catch (Exception e) {
      SC.say(e.toString());
    }
  }
  public ReportReceiveLayout_2(final User currentUser) {
    setWidth(950);
    setHeight100();

    HLayout searchLayout = new HLayout();
    searchLayout.setHeight(20);

    final DynamicForm searchForm = new DynamicForm();
    searchForm.setWidth(450);
    searchForm.setHeight(30);
    searchForm.setMargin(5);
    searchForm.setNumCols(4);
    searchForm.setCellPadding(2);
    searchForm.setAutoFocus(true);
    searchForm.setSelectOnFocus(true);
    searchForm.setIsGroup(true);
    searchForm.setDataSource(TransferDS.getInstance());
    searchForm.setUseAllDataSourceFields(false);
    searchForm.setGroupTitle("ตัวกรอง");

    final SelectItem statusSelected = new SelectItem("status", "สถานะ");
    statusSelected.setWrapTitle(false);
    // statusSelected.setValueMap("รอแก้ไข", "รออนุมัติ", "อนุมัติแล้ว");
    statusSelected.setValueMap(TransferStatus.getValueMap());
    statusSelected.setAllowEmptyValue(true);
    statusSelected.setEmptyDisplayValue("ทั้งหมด");
    statusSelected.setOperator(OperatorId.EQUALS);
    final TextItem jidText = new TextItem("plan_id", "รหัสแผนการผลิต");
    jidText.setWrapTitle(false);
    jidText.setOperator(OperatorId.REGEXP);
    //		final TextItem smidText = new TextItem("smid", "รหัสช่าง");
    //		smidText.setWrapTitle(false);
    //		smidText.setOperator(OperatorId.REGEXP);

    //		final DynamicForm dateForm = new DynamicForm();
    //		dateForm.setWidth(300);
    //		dateForm.setHeight(30);
    //		dateForm.setMargin(5);
    //		dateForm.setNumCols(2);
    //		dateForm.setCellPadding(2);
    //		dateForm.setSelectOnFocus(true);
    //		dateForm.setIsGroup(true);
    //		dateForm.setGroupTitle("วันที่ขอโอนสินค้า");
    DateRange dateRange = new DateRange();
    dateRange.setRelativeStartDate(new RelativeDate("-1w"));
    dateRange.setRelativeEndDate(RelativeDate.TODAY);
    final DateItem from = new DateItem("create_from", "ตั้งแต่");
    final DateItem to = new DateItem("create_to", "ถึง");
    from.setDefaultChooserDate(dateRange.getStartDate());
    from.setDefaultValue(dateRange.getStartDate());
    from.setUseTextField(true);
    to.setDefaultChooserDate(dateRange.getEndDate());
    to.setDefaultValue(dateRange.getEndDate());
    to.setUseTextField(true);

    searchForm.setItems(jidText, statusSelected, from, to);
    // searchForm.setItems(planText, jidText);
    //        dateForm.setItems(from, to);

    final ListGrid orderListGrid = new ListGrid();

    orderListGrid.setAutoFetchData(true);
    orderListGrid.setCanMultiSort(true);
    orderListGrid.setShowRowNumbers(true);
    orderListGrid.setShowGridSummary(true);

    AdvancedCriteria criteria =
        new AdvancedCriteria(
            OperatorId.AND,
            new Criterion[] {
              // new Criterion("status", OperatorId.NOT_EQUAL, "3_to_next_process"),
              // new Criterion("created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(),
              // to.getValueAsDate())
              new Criterion(
                  "created_date",
                  OperatorId.BETWEEN_INCLUSIVE,
                  dateRange.getStartDate(),
                  dateRange.getEndDate())
            });
    orderListGrid.setCriteria(criteria);

    orderListGrid.setDataSource(TransferDS.getInstance());
    orderListGrid.setInitialSort(
        new SortSpecifier[] {
          new SortSpecifier("status", SortDirection.DESCENDING),
          new SortSpecifier("created_date", SortDirection.DESCENDING)
        });
    orderListGrid.setUseAllDataSourceFields(false);
    orderListGrid.setSelectionType(SelectionStyle.NONE);

    ListGridField transfer_id = new ListGridField("transfer_id", 100);
    transfer_id.setSummaryFunction(
        new SummaryFunction() {
          public Object getSummaryValue(Record[] records, ListGridField field) {
            return records.length + " รายการ";
          }
        });
    transfer_id.setShowGridSummary(true);

    ListGridField status = new ListGridField("status", 120);
    ListGridField plan_id = new ListGridField("plan_id", 100);
    ListGridField transfer_by = new ListGridField("transfer_by");
    ListGridField transfer_date = new ListGridField("transfer_date", 150);

    ListGridField total_weight = new ListGridField("total_sent_weight", 120);
    total_weight.setCellFormatter(FieldFormatter.getNumberFormat());
    total_weight.setAlign(Alignment.RIGHT);
    total_weight.setSummaryFunction(SummaryFunctionType.SUM);
    total_weight.setShowGridSummary(true);

    ListGridField total_amount = new ListGridField("total_sent_amount", 120);
    total_amount.setCellFormatter(FieldFormatter.getNumberFormat());
    total_amount.setAlign(Alignment.RIGHT);
    total_amount.setSummaryFunction(SummaryFunctionType.SUM);
    total_amount.setShowGridSummary(true);

    orderListGrid.setFields(
        transfer_date, transfer_id, status, plan_id, transfer_by, total_weight, total_amount);

    // orderListGrid.hideField("status");

    HLayout buttonLayout = new HLayout();
    buttonLayout.setMargin(10);
    buttonLayout.setMembersMargin(5);
    buttonLayout.setHeight(30);
    IButton searchButton = new IButton("ค้นหาคำขอโอนสินค้า");
    searchButton.setIcon("icons/16/reports-icon.png");
    searchButton.setWidth(170);
    searchButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Criterion search = new Criterion();
            search.addCriteria(searchForm.getValuesAsCriteria());
            AdvancedCriteria criteria =
                new AdvancedCriteria(
                    OperatorId.AND,
                    new Criterion[] {
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate()),
                      search
                    });
            reportDate.setContents(
                "ตั้งแต่วันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
                    + " ถึงวันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
            orderListGrid.fetchData(criteria);
            orderListGrid.deselectAllRecords();
          }
        });

    IButton listAllButton = new IButton("ล้างรายการค้นหา");
    listAllButton.setIcon("[SKIN]actions/refresh.png");
    listAllButton.setWidth(150);
    listAllButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            AdvancedCriteria criteria =
                new AdvancedCriteria(
                    OperatorId.AND,
                    new Criterion[] {
                      new Criterion(
                          "created_date",
                          OperatorId.BETWEEN_INCLUSIVE,
                          from.getValueAsDate(),
                          to.getValueAsDate())
                    });
            searchForm.reset();
            reportDate.setContents(
                "ตั้งแต่วันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
                    + " ถึงวันที่ "
                    + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
            orderListGrid.fetchData(criteria);
            orderListGrid.deselectAllRecords();
          }
        });

    IButton printButton = new IButton("พิมพ์รายงาน");
    printButton.setIcon("icons/16/print.png");
    printButton.setWidth(120);

    buttonLayout.addMembers(searchButton, listAllButton, printButton);

    searchLayout.addMembers(searchForm);
    // reviseLayout.
    addMember(searchLayout);

    // reviseLayout.
    addMember(buttonLayout);

    final VLayout gridLayout = new VLayout();
    gridLayout.setWidth100();
    gridLayout.setHeight(500);
    Label text = new Label();
    text.setContents("รายงานการโอนสินค้าเข้าคลังสินค้า");
    text.setAlign(Alignment.CENTER);
    text.setHeight(10);
    text.setStyleName("printTitle");
    reportDate = new Label();
    reportDate.setContents(
        "ตั้งแต่วันที่ "
            + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate())
            + " ถึงวันที่ "
            + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate()));
    reportDate.setAlign(Alignment.CENTER);
    reportDate.setHeight(10);
    reportDate.setStyleName("printDetails");

    gridLayout.addMember(text);
    gridLayout.addMember(reportDate);
    gridLayout.addMember(orderListGrid);
    addMember(gridLayout);

    printButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Canvas.showPrintPreview(gridLayout);
          }
        });
  }