public void search(final boolean print) {

    Date dtStart = diStart.getValueAsDate();
    Date dtEnd = diEnd.getValueAsDate();
    ArrayList<String> criterias = createCriteria();
    SplashDialog.showSplash();
    DocFlow.docFlowService.getDocListForType(
        docTypeId,
        dtStart.getTime(),
        dtEnd.getTime(),
        DocFlow.language_id,
        criterias,
        print,
        new AsyncCallback<DocTypeWithDocList>() {

          @Override
          public void onFailure(Throwable caught) {
            SplashDialog.hideSplash();
            SC.say(caught.getMessage());
          }

          @Override
          public void onSuccess(DocTypeWithDocList result) {
            SplashDialog.hideSplash();
            if (!print) {
              stDocCount.setValue(result.getDocList().size());
              DocFlowSectionStack.docFlowSectionStack.documentHistoryListGrid.setDocListAndType(
                  result);
              DocFlowSectionStack.docFlowSectionStack.detailTabPane.setDocType(result.getDocType());
            }
          }
        });
  }
  public DocumentSearchForm() {
    instance = this;
    setTop(20);
    setCellPadding(6);
    setNumCols(5);
    setStyleName("defaultBorder");
    setTitleOrientation(TitleOrientation.TOP);

    findItem = new ButtonItem("Find");
    findItem.setIcon("silk/find.png");
    findItem.setWidth(70);
    findItem.setEndRow(false);
    HashMap<String, String> listSqls = new HashMap<String, String>();
    listSqls.put("" + ClSelection.T_REGION, "" + ClSelection.T_REGION);
    listSqls.put(
        "" + ClSelection.T_DOC_STATUS,
        "" + ClSelection.T_DOC_STATUS + "_" + ClSelection.T_LANGUAGE + "_" + DocFlow.language_id);
    siDocStatus = new SelectItem("siDocStatus", "Doc Status");
    diStart = new CurrentTimeItem("diStart", "Start");
    diStart.setUseTextField(false);
    diEnd = new CurrentTimeItem("diEnd", "End");
    diEnd.setUseTextField(false);

    setCurrentDate();
    tiUserName = new TextItem("tiUserName", "User Name");
    iiZona = new IntegerItem("iiZona", "Zona");
    iiCustomer = new IntegerItem("iiCustomer", "Customer");
    tiContent = new TextItem("tiContent", "Content");
    tiDocId = new IntegerItem("tiDocId", "Doc ID");
    tiCancelary = new IntegerItem("tiCancelary", "Cancelary");
    DocFlow.docFlowService.getListTypesForDocument(
        listSqls,
        -1,
        new AsyncCallback<HashMap<String, ArrayList<ClSelectionItem>>>() {

          @Override
          public void onFailure(Throwable caught) {
            setResults(null);
          }

          @Override
          public void onSuccess(HashMap<String, ArrayList<ClSelectionItem>> result) {
            setResults(result);
          }
        });
    findItem.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            search(false);
          }
        });
    stDocCount = new StaticTextItem("stDocCount", "Result Count");

    if (true) {
      showStatusItem = new ButtonItem("showStatusItem", "Report");
      showStatusItem.setStartRow(false);
      showStatusItem.setEndRow(false);
      showStatusItem.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              Date dtStart = diStart.getValueAsDate();
              Date dtEnd = diEnd.getValueAsDate();
              int language = DocFlow.language_id;
              int doctype = docTypeId;
              long startdate = dtStart.getTime();
              long enddate = dtEnd.getTime();
              int userid =
                  DocFlow.hasPermition(PermissionNames.VIEW_ALL_DOCUMENTS) ? 0 : DocFlow.user_id;
              String _url =
                  "reportgenerator.jsp?language="
                      + language
                      + "&doctype="
                      + doctype
                      + "&startdate="
                      + startdate
                      + "&enddate="
                      + enddate
                      + "&userid="
                      + userid;
              ArrayList<String> criterias = createCriteria();
              String ret = "";
              Document doc = XMLParser.createDocument();
              Element rootElem = doc.createElement("DocDef");
              doc.appendChild(rootElem);

              for (String key : criterias) {
                Element val = doc.createElement("Val");
                val.setAttribute("V", key);
                rootElem.appendChild(val);
              }
              ret = doc.toString();
              _url += "&xml=" + URL.encode(ret);
              Window.open(
                  _url, "yourWindowName", "location=yes,resizable=yes,scrollbars=yess,status=yes");
            }
          });

      bashConfirm = new ButtonItem("bashConfirm", "Bash Confirm");
      bashConfirm.setStartRow(false);
      bashConfirm.setEndRow(false);
      bashConfirm.setDisabled(true);

      bashConfirm.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              WBashConfirmDocuments.showWindow(docTypeId);
            }
          });
    }
  }
 public void setCurrentDate() {
   diStart.setValue(DocFlow.getCurrentDate());
   diEnd.setValue(new Date(DocFlow.currenttime + (1000 * 60 * 60 * 24)));
 }