// private Layer getNavigationTree(IWContext iwc) {
  private Layer getNavigationTree() {
    Layer layersNav = new Layer(Layer.DIV);
    layersNav.setOverflow("scroll");
    layersNav.setPositionType("relative");
    layersNav.setWidth("320");
    layersNav.setHeight("400");

    layersNav.setStyleClass("ehealth_div_no_border");
    // layersNav.setMarkupAttribute("class", "ehealth_div");

    layersNav.setBackgroundImage(imageBgVertOut);

    Table table = new Table(3, 20);
    table.setNoWrap();
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);

    table.setWidth("280");
    table.setHeight("350");

    int row = 1;
    int i = 1;

    for (i = 1; i <= 4; i++) {
      table.mergeCells(2, row, 3, row);
      if (i <= 2) {
        table.add(getLayer1(i), 2, row);
        table.setHeight(1, row, "16");
        table.setHeight(2, row, "16");
        table.setWidth(1, row, "16");
        table.setWidth(2, row, "16");
        table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
        table.add(imageCircleD, 1, row++);
      }
      // table.setBackgroundImage(1, row, imageBgVert);
      table.setHeight(2, row, "16");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.add(getLayer2(i), 2, row++);
      table.setBackgroundImage(1, row, imageBgVert);
      table.setHeight(1, row, "20");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.add(getLayer3(i), 2, row++);
      table.setHeight(1, row, "10");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.setBackgroundImage(1, row++, imageBgVert);

      /*table.add(getLayer1(i), 2, row);
      table.add(getLayer2(i), 2, row);
      table.add(getLayer3(i), 2, row);
      */
    }
    table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
    table.setHeight(1, row, "25");
    table.setBackgroundImage(1, row++, imageBgVert);

    layersNav.add(table);
    return layersNav;
  }
  public Table getNavigationTable(IWContext iwc) {

    int usersSize = 0;
    if (this.users != null) {
      usersSize = this.users.size();
    }

    int maxPage = (int) Math.ceil(usersSize / this.USERS_PER_PAGE);

    Table navigationTable = new Table(3, 1);
    navigationTable.setCellpadding(2);
    navigationTable.setCellspacing(0);
    navigationTable.setWidth(Table.HUNDRED_PERCENT);
    navigationTable.setBorder(0);
    navigationTable.setWidth(1, "33%");
    navigationTable.setWidth(2, "33%");
    navigationTable.setWidth(3, "33%");
    navigationTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_CENTER);
    navigationTable.setAlignment(3, 1, Table.HORIZONTAL_ALIGN_RIGHT);

    Text prev = getSmallText(localize("previous", "Previous"));
    Text next = getSmallText(localize("next", "Next"));
    Text info =
        getSmallText(
            localize("page", "Page")
                + " "
                + (this.currentPage + 1)
                + " "
                + localize("of", "of")
                + " "
                + (maxPage + 1));
    if (this.currentPage > 0) {
      Link lPrev = getLink(getSmallText(localize("previous", "Previous")), iwc);
      lPrev.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage - 1));
      lPrev.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lPrev.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lPrev, 1, 1);
    } else {
      navigationTable.add(prev, 1, 1);
    }
    navigationTable.add(info, 2, 1);

    if (this.currentPage < maxPage) {
      Link lNext = getLink(getSmallText(localize("next", "Next")), iwc);
      lNext.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage + 1));
      lNext.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lNext.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lNext, 3, 1);
    } else {
      navigationTable.add(next, 3, 1);
    }
    return navigationTable;
  }
  public Table getSearchTable(IWContext iwc) {
    // *** Search Table *** START - the uppermost table
    Table table = new Table();
    table.setBorder(0);
    table.setCellpadding(0);
    table.setCellspacing(0);

    int col = 1;
    int row = 1;

    Image space1 = (Image) this.transGIF.clone();
    space1.setWidth(6);

    // *** HEADING Search pupil ***
    table.add(space1, col, row);
    Text pupilTxt = new Text(localize(KEY_SEARCH_PUPIL_HEADING, "Search pupil"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "40");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    col = 1;
    row++;
    // User search module - configure and add
    SearchUserModule searchMod = getSearchUserModule();
    table.add(searchMod, col++, row);

    // Get pupil if only one found
    try {
      searchMod.process(iwc);
      User oneChild = searchMod.getUser();
      if (oneChild != null) {
        this.pupil = oneChild;
      }
    } catch (Exception e) {
    }

    return table;
  }
  /**
   * @see
   *     com.idega.presentation.ui.AbstractChooserWindow#displaySelection(com.idega.presentation.IWContext)
   */
  public void displaySelection(IWContext iwc) {
    String uId = iwc.getParameter(this.PARAMETER_USER_ID);
    if (uId != null) {
      try {
        User user = getUserHome().findByPrimaryKey(new Integer(uId));
        Page page = getParentPage();
        page.setOnLoad(SELECT_FUNCTION_NAME + "('" + user.getName() + "','" + uId + "')");
      } catch (RemoteException e) {
      } catch (FinderException e) {
      }
    } else {

      init(iwc);

      addTitle(this.iwrb.getLocalizedString("select_a_user", "Select a user"), TITLE_STYLECLASS);

      this.form.maintainParameter(SCRIPT_PREFIX_PARAMETER);
      this.form.maintainParameter(SCRIPT_SUFFIX_PARAMETER);
      this.form.maintainParameter(DISPLAYSTRING_PARAMETER_NAME);
      this.form.maintainParameter(VALUE_PARAMETER_NAME);

      Table mainTable = new Table(1, 4);
      mainTable.setStyleClass(this.mainTableStyle);
      mainTable.setWidth(Table.HUNDRED_PERCENT);
      mainTable.setBorder(0);

      mainTable.add(getHeaderTable(iwc), 1, 1);
      mainTable.add(getNavigationTable(iwc), 1, 3);
      try {
        mainTable.add(getListTable(iwc), 1, 4);
      } catch (RemoteException r) {
        throw new RuntimeException(r.getMessage());
      }
      this.form.add(mainTable);
      add(this.form, iwc);
    }
  }
Ejemplo n.º 5
0
  // public PresentationObject getVisitForm(IWContext iwc, User userVK) throws
  // java.rmi.RemoteException {
  public UIComponent getDoctorForm() {
    IWResourceBundle iwrb = this.getResourceBundle(_iwc);
    Form myForm = new Form();
    myForm.setName(prmForm);

    Table table = new Table(3, 3);
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);
    table.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(1, 2, Table.VERTICAL_ALIGN_BOTTOM);
    table.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_BOTTOM);

    table.setWidth(400);
    table.setWidth(2, 1, 15);
    table.setWidth(1, 1, 73);

    myForm.add(table);

    Age age = null;
    String doctorInfo = null;

    if (user != null && user.getDateOfBirth() != null) age = new Age(user.getDateOfBirth());
    else if (user != null && user.getPersonalID() != null)
      age = new Age(PIDChecker.getInstance().getDateFromPersonalID(user.getPersonalID()));

    int userIDDr = 45;

    if (age != null && age.getYears() >= 70) {
      userIDDr = 46; // 45   41047
    }

    PresentationObject picture = null;
    User doctor = null;

    int userImageID = -1;
    try {
      doctor =
          ((UserBusiness) IBOLookup.getServiceInstance(_iwc, UserBusiness.class)).getUser(userIDDr);
    } catch (Exception fe) {
      log(fe);
    }

    if (doctor != null) userImageID = doctor.getSystemImageID();

    if (userImageID == -1) {
      Table fakeImageTable = new Table(1, 1);
      fakeImageTable.setAlignment(1, 1, Table.HORIZONTAL_ALIGN_CENTER);
      fakeImageTable.setBorder(4);
      fakeImageTable.setHeight(140);
      fakeImageTable.setWidth(100);
      String fakeImageColor = "#CCCCCC";
      Text photoText = new Text(iwrb.getLocalizedString("managerview.photo_text", "Photo"));
      photoText.setBold();
      photoText.setFontColor(fakeImageColor);
      photoText.setFontSize(Text.FONT_SIZE_12_STYLE_TAG);
      fakeImageTable.add(photoText, 1, 1);
      fakeImageTable.setBorderColor(fakeImageColor);
      picture = fakeImageTable;
    } else {
      Image image = new Image();
      image.setImageID(userImageID);
      image.setWidth(73);

      picture = image;
    }
    table.add(picture, 1, 1);

    if (age != null && age.getYears() >= 70) {
      doctorInfo =
          "<b>Dr. Inga Pren</b><br>Allmänläkare<br>Telefon:<br>018-987624<br>Telefontid: Mån-ons, kl 08:30-10.00<br>Webbsida: <a href='http://www.flogsta.se' target='_new'>www.flogsta.se</a>";
    } else {
      doctorInfo =
          "<b>Dr. Magne Syhl</b><br>Allmänläkare<br>Telefon:<br>018-987654<br>Telefontid: Mån-ons, kl 08-10.00<br>Webbsida: <a href='http://www.gimovc.se' target='_new'>www.gimovc.se</a>";
    }

    table.add(doctorInfo, 3, 1);
    GenericButton message =
        getButton(new GenericButton("send_message", localize(prmSendMessage, "Send message")));
    if (_messagePage != null) message.setPageToOpen(_messagePage);

    table.add(message, 3, 2);
    table.setHeight(3, 2, "25");

    GenericButton visitbooking =
        getButton(new GenericButton("visit", localize(prmVisitBooking, "Book an appointment")));
    if (_appointmentPage != null) visitbooking.setPageToOpen(_appointmentPage);

    SubmitButton smb = new SubmitButton();
    smb.setStyleClass("ehealth_InterfaceButton");
    smb.setValue("Skicka meddelande >");
    smb.setPageToOpen(132);

    table.add(visitbooking, 3, 3);

    return myForm;
  }
  private void drawForm(IWContext iwc) {
    Form form = new Form();
    Table T = new Table();
    T.setCellpadding(2);
    T.setCellspacing(2);
    T.setBorder(0);
    form.add(T);

    Table table = new Table();
    //		table.setWidth(getWidth());
    table.setCellpadding(2);
    table.setCellspacing(2);
    table.setBorder(0);
    T.add(table, 1, 1);
    T.setWidth(2, 1, "20");

    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_BOTTOM);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_BOTTOM);

    int row = 1;

    String personalID =
        PersonalIDFormatter.format(
            user.getPersonalID(), iwc.getIWMainApplication().getSettings().getApplicationLocale());

    table.add(new Break(2), 1, row);
    table.add(getSmallHeader(localize(KEY_PID, DEFAULT_PID)), 1, row);

    if (user.getPersonalID() != null) {
      table.add(getSmallText(personalID), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }
    row++;
    table.add(getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN)), 1, row);
    LoginTable loginTable =
        LoginDBHandler.getUserLogin(((Integer) user.getPrimaryKey()).intValue());
    if (loginTable != null) {
      table.add(new HiddenInput(PARAMETER_OLD_LOGIN, loginTable.getUserLogin()), 2, row);
      table.add(getSmallText(loginTable.getUserLogin()), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }

    String valueCurrentPassword =
        iwc.getParameter(PARAMETER_CURRENT_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_CURRENT_PASSWORD)
            : "";
    String valueNewPassword =
        iwc.getParameter(PARAMETER_NEW_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD)
            : "";
    String valueNewPasswordRepeated =
        iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED)
            : "";

    // Text tLogin = getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN));
    Text tCurrentPassword =
        getSmallHeader(localize(KEY_CURRENT_PASSWORD, DEFAULT_CURRENT_PASSWORD));
    Text tNewPassword = getSmallHeader(localize(KEY_NEW_PASSWORD, DEFAULT_NEW_PASSWORD));
    Text tNewPasswordRepeated =
        getSmallHeader(localize(KEY_NEW_PASSWORD_REPEATED, DEFAULT_NEW_PASSWORD_REPEATED));

    PasswordInput tiCurrentPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_CURRENT_PASSWORD));
    if (valueCurrentPassword != null) {
      tiCurrentPassword.setValue(valueCurrentPassword);
    }
    PasswordInput tiNewPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD));
    if (valueNewPassword != null) {
      tiNewPassword.setValue(valueNewPassword);
    }
    PasswordInput tiNewPasswordRepeated =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD_REPEATED));
    if (valueNewPasswordRepeated != null) {
      tiNewPasswordRepeated.setValue(valueNewPasswordRepeated);
    }

    SubmitButton sbUpdate =
        (SubmitButton)
            getStyledInterface(
                new SubmitButton(
                    localize(KEY_UPDATE, DEFAULT_UPDATE), PARAMETER_FORM_SUBMIT, "true"));

    row++;
    table.setHeight(row, 12);

    if (requirePasswordVerification) {
      row++;
      table.add(tCurrentPassword, 1, row);
      table.add(tiCurrentPassword, 2, row);
    }

    row++;
    table.add(tNewPassword, 1, row);
    table.add(tiNewPassword, 2, row);

    row++;
    table.add(tNewPasswordRepeated, 1, row);
    table.add(tiNewPasswordRepeated, 2, row);

    row++;
    table.setHeight(row, 12);

    row++;
    table.mergeCells(1, row, 2, row);
    table.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);

    table.add(Text.NON_BREAKING_SPACE, 1, row);
    table.add(sbUpdate, 1, row);

    add(form);
  }
  public UIComponent getOverviewForm() {
    Form myForm = new Form();
    myForm.setName(prmForm);
    Table T = new Table(3, 3);
    T.setCellpadding(0);
    T.setCellspacing(0);
    T.setBorder(0);
    T.setBorderColor("#000000");
    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    // T.setVerticalAlignment(1, 4, Table.VERTICAL_ALIGN_BOTTOM);
    // T.add(getNavigationTree(iwc), 1, 1);
    T.add(getNavigationTree(), 1, 1);
    //	T.add(getInfoLayer(), 2, 1);

    T.add(new Break(3), 3, 1);
    //		T.setHeight(1, 3, "130");
    // T.setHeight(1, 4, "90");
    T.setWidth(2, 1, "40");
    myForm.add(T);

    Page pVisit = this.getParentPage();
    if (pVisit != null) {
      Script S = pVisit.getAssociatedScript();
      // pVisit.setOnLoad("setRowColor(document.getElementById('inf1_1'));");

      S.addFunction("setRowColor(obj)", setRowColorScript());
      S.addFunction("showHideLayer(obj)", showHideLayerScript());
      Script timeScript = myForm.getAssociatedFormScript();
      if (timeScript == null) {
        timeScript = new Script();
        myForm.setAssociatedFormScript(timeScript);
      }
    }

    ArrayList texts1 = new ArrayList();
    ArrayList texts2 = new ArrayList();

    if (age != null && age.getYears() >= 70) {
      texts1.add(localize(keySet1Text1U1, "Texten"));
      texts1.add(localize(keySet1Text2U1, "Texten"));
      texts1.add(localize(keySet1Text3U1, "Texten"));
      texts1.add(localize(keySet1Text4U1, "Texten"));
      texts1.add(localize(keySet1Text5U1, "Texten"));

      texts2.add(localize(keySet2Text1U1, "Texten"));
      texts2.add(localize(keySet2Text2U1, "Texten"));
      texts2.add(localize(keySet2Text3U1, "Texten"));
      texts2.add(localize(keySet2Text4U1, "Texten"));
      texts2.add(localize(keySet2Text5U1, "Texten"));

    } else {
      texts1.add(localize(keySet1Text1U2, "Texten"));
      texts1.add(localize(keySet1Text2U2, "Texten"));
      texts1.add(localize(keySet1Text3U2, "Texten"));
      texts1.add(localize(keySet1Text4U2, "Texten"));
      texts1.add(localize(keySet1Text5U2, "Texten"));

      texts2.add(localize(keySet2Text1U2, "Texten"));
      texts2.add(localize(keySet2Text2U2, "Texten"));
      texts2.add(localize(keySet2Text3U2, "Texten"));
      texts2.add(localize(keySet2Text4U2, "Texten"));
      texts2.add(localize(keySet2Text5U2, "Texten"));
    }

    Layer layerOut = new Layer(Layer.DIV);
    layerOut.setVisibility("visible");
    layerOut.setOverflow("scroll");
    layerOut.setPositionType("absolute");
    layerOut.setWidth("280");
    layerOut.setHeight("170");
    layerOut.setMarkupAttribute("class", "ehealth_div");

    Layer layer = new Layer(Layer.DIV);
    layer.setVisibility("hidden");
    layer.setOverflow("hidden");
    layer.setPositionType("absolute");
    layer.setWidth("250");
    layer.setHeight("145");
    layer.setMarkupAttribute("class", "ehealth_div_no_border");

    int theRow = 1;
    int i = 1;

    Iterator iter1 = texts1.iterator();
    Iterator iter2 = texts2.iterator();

    while (iter1.hasNext()) {
      Layer layers = (Layer) layer.clone();
      layers.setID("info" + i + "_" + theRow);
      String text = (String) iter1.next();
      layers.add(text);
      layerOut.add(layers);

      theRow++;
    }
    i++;
    theRow = 1;
    while (iter2.hasNext()) {
      Layer layers = (Layer) layer.clone();
      layers.setID("info" + i + "_" + theRow);
      String text = (String) iter2.next();
      layers.add(text);
      layerOut.add(layers);

      theRow++;
    }

    T.add(layerOut, 3, 1);
    return myForm;
  }
  private Layer getInfoLayer(int theCase) {
    Layer layerInfo = new Layer(Layer.DIV);
    // layerInfo.setOverflow("hidden");
    // layerInfo.setVisibility("hidden");
    layerInfo.setPositionType("relative");

    layerInfo.setWidth("270");
    layerInfo.setHeight("100");
    layerInfo.setStyleClass("ehealth_row_outer_div");

    Table tableInfo = new Table(1, 10);
    tableInfo.setNoWrap();
    tableInfo.setCellpadding(0);
    tableInfo.setCellspacing(0);
    tableInfo.setBorder(0);
    // tableInfo.setWidth(200);
    int column = 1;
    tableInfo.setWidth(column, 1, "200");
    // tableInfo.setWidth(column++, 1, "70");

    Image transpImg = Table.getTransparentCell(_iwc);
    transpImg.setWidth(15);
    transpImg.setHeight(16);

    Layer layer = new Layer(Layer.DIV);
    layer.setOnMouseOver("setRowColor(this);");
    layer.setPositionType("relative");
    // layer.setHeight(20);
    layer.setStyleClass("ehealth_row_div");

    Image corners = getBundle(_iwc).getImage("thirdLevel.gif");
    corners.setBorder(0);
    corners.setHeight(16);
    corners.setWidth(19);
    layer.setBackgroundImage(corners);

    int theRow = 1;

    ArrayList cases = new ArrayList();
    if (age != null && age.getYears() >= 70) {
      if (theCase == 1) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        cases.add("Remisser och svar:");
        // cases.add("Läkemedel:");
      } else if (theCase == 2) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        cases.add("Remisser och svar:");
      }
    } else {
      if (theCase == 1) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        // cases.add("Läkemedel:");
      } else if (theCase == 2) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        // cases.add("Läkemedel:");
      }
    }

    Iterator iter = cases.iterator();

    while (iter.hasNext()) {

      Layer layers = (Layer) layer.clone();
      layers.setID("inf" + theCase + "_" + theRow);
      String text = (String) iter.next();
      layers.add(text);
      tableInfo.add(layers, column, theRow);
      theRow++;
    }

    layerInfo.add(tableInfo);

    return layerInfo;
  }
  private Table getPlacementTable(IWContext iwc) throws RemoteException {
    Table table = new Table();
    // table.setColor("#DDDDDD");
    table.setBorder(0);
    table.setWidth(Table.HUNDRED_PERCENT);
    table.setCellpadding(1);
    table.setCellspacing(2);
    int col = 1;
    int row = 1;

    // *** HEADING Placements ***
    Text pupilTxt = new Text(localize(KEY_PLACEMENTS_HEADING, "Placements"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "40");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    table.mergeCells(col, row, table.getColumns(), row);
    col = 1;
    row++;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "10");
    col = 1;
    row++;

    //  *** Column headings ***
    table.add(getLocalizedSmallHeader(KEY_NUMBER, "No."), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_TYPE, "School type"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PROVIDER, "Provider"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_YEAR, "School year"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_STUDY_PATH, "Study path"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_GROUP, "School group"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_START_DATE, "Start date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_END_DATE, "End date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATOR, "Registrator"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATION_CREATED_DATE, "Created date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PLACEMENT_PARAGRAPH_SHORT, "Par"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_NOTES, "Notes"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);

    table.setRowColor(row, getHeaderColor());

    table.setRowHeight(row, "18");
    row++;

    // Loop placements
    Collection placements = null;
    try {
      if (this.pupil != null) {
        placements =
            getSchoolBusiness(iwc)
                .getSchoolClassMemberHome()
                .findAllOrderedByRegisterDate(this.pupil);
      }
    } catch (FinderException e) {
    }

    if (placements != null && placements.size() > 0) {
      int zebra = 0;
      int rowNum = 0;
      table.add(new HiddenInput(PARAM_REMOVE_PLACEMENT, "-1"), 1, 1);
      for (Iterator iter = placements.iterator(); iter.hasNext(); ) {
        rowNum++;
        SchoolClassMember plc = (SchoolClassMember) iter.next();
        col = 1;

        // Row number
        table.add(getSmallText(String.valueOf(rowNum)), col++, row);
        // School type
        try {
          table.add(getSmallText(plc.getSchoolType().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Provider
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchool().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // School year
        try {
          table.add(getSmallText(plc.getSchoolYear().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Study path
        try {
          if (plc.getStudyPathId() != -1) {
            SchoolStudyPathHome home =
                (SchoolStudyPathHome) IDOLookup.getHome(SchoolStudyPath.class);
            SchoolStudyPath sp = home.findByPrimaryKey(new Integer(plc.getStudyPathId()));
            table.add(getSmallText(sp.getCode()), col, row);
          }
        } catch (Exception e) {
        }
        col++;
        // School type
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchoolClassName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Start date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRegisterDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // End date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRemovedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Registrator
        try {
          int registratorID = plc.getRegistratorId();
          User registrator = getUserBusiness(iwc).getUser(registratorID);
          if (registrator != null) {
            Name name =
                new Name(
                    registrator.getFirstName(),
                    registrator.getMiddleName(),
                    registrator.getLastName());
            table.add(
                getSmallText(name.getName(iwc.getApplicationSettings().getDefaultLocale(), false)),
                col++,
                row);
          }
        } catch (Exception e) {
          col++;
        }
        // Created date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc)
                  .getDateString(plc.getRegistrationCreatedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Placement paragraph
        try {
          if (plc.getPlacementParagraph() != null) {
            table.add(getSmallText(plc.getPlacementParagraph()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Notes
        try {
          if (plc.getNotes() != null) {
            table.add(getSmallText(plc.getNotes()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Pupil overview button
        try {
          // Get Pupil overview button
          String plcId = ((Integer) plc.getPrimaryKey()).toString();
          String schClassId = String.valueOf(plc.getSchoolClassId());

          Link editButt =
              new Link(this.getEditIcon(localize(KEY_TOOLTIP_PUPIL_OVERVIEW, "Pupil overview")));
          editButt.setWindowToOpen(PlacementHistoryEditPlacement.class);
          editButt.setParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_ONLY_OVERVIEW, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_NO_CHOICES, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_PAGE_ID, getParentPage().getPageID());
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_USER_ID, String.valueOf(plc.getClassMemberId()));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_ID, schClassId);
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_ID, plcId);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_RESOURCE_PERMISSION,
              SchoolAdminOverview.PARAMETER_RESOURCE_PERM_VALUE_CENTRAL_ADMIN);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_FROM_CENTRAL_PLACEMENT_EDITOR, "true");
          if (plc.getRemovedDate() != null) {
            editButt.addParameter(
                SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_REMOVED_DATE,
                plc.getRemovedDate().toString());
          }

          table.add(editButt, col, row);
          table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
          col++;
        }
        // Remove button
        try {
          // Get remove button
          Image delImg = getDeleteIcon(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete placement"));
          int plcID = ((Integer) plc.getPrimaryKey()).intValue();

          SubmitButton delButt = new SubmitButton(delImg);
          delButt.setValueOnClick(PARAM_REMOVE_PLACEMENT, String.valueOf(plcID));
          delButt.setSubmitConfirm(
              localize(
                  KEY_CONFIRM_REMOVE_PLC_MSG,
                  "Do you really want to erase this school placement and its resource placements?"));
          delButt.setToolTip(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete school placement"));
          table.add(delButt, col, row);
          table.setAlignment(col, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
        }

        String zebraColor = zebra % 2 == 0 ? getZebraColor2() : getZebraColor1();
        table.setRowColor(row, zebraColor);
        col = 2;
        row++;

        // Resources
        String rscStr = getResourceBusiness(iwc).getResourcesStringXtraInfo(plc);
        if (!("".equals(rscStr))) {
          table.add(
              getSmallText("<i>" + localize(KEY_RESOURCES, "Resources") + ":</i> "), col, row);
          table.add(getSmallText("<i>" + rscStr + "</i>"), col, row);
          table.setRowColor(row, zebraColor);
          table.mergeCells(col, row, table.getColumns(), row);
          row++;
        }

        zebra++;
      }
    }

    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "20");

    return table;
  }
  public Table getPupilTable(IWContext iwc, User pupil) {
    // *** Search Table *** START - the uppermost table
    Table table = new Table();
    table.setWidth("100%");
    table.setBorder(0);
    table.setCellpadding(2);
    table.setCellspacing(0);
    this.transGIF.setHeight("1");
    this.transGIF.setWidth("1");

    int row = 1;
    int col = 1;
    // add empty space row
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    // Set COLUMN WIDTH for column 1 to 5
    table.setWidth(1, row, "100");
    // table.setWidth(2, row, "70");
    // table.setWidth(3, row, "70");
    // table.setWidth(4, row, "70");
    // table.setWidth(5, row, "104");

    row++;
    col = 1;

    // *** HEADING Pupil ***
    Text pupilTxt = new Text(localize(KEY_PUPIL_HEADING, "Pupil"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "20");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    row++;
    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "5");
    col = 1;
    row++;

    // Personal Id Number
    table.add(getSmallHeader(localize(KEY_PERSONAL_ID_LABEL, "Personal id: ")), col++, row);
    if (pupil != null) {
      table.add(getSmallText(pupil.getPersonalID()), col++, row);
    }
    row++;
    col = 1;
    // Last Name
    table.add(getSmallHeader(localize(KEY_LAST_NAME_LABEL, "Last name: ")), col++, row);

    Table nameTable = new Table();
    col = 1;
    nameTable.setCellpadding(0);
    nameTable.setCellspacing(0);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getLastName()), col++, 1);
    }
    // First Name
    nameTable.add(getSmallHeader(localize(KEY_FIRST_NAME_LABEL, "First name: ")), col++, 1);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getFirstName()), col++, 1);
    }
    nameTable.setWidth(1, 1, "100");
    nameTable.setWidth(2, 1, "100");
    nameTable.setWidth(3, 1, "100");
    table.add(nameTable, 2, row);
    table.mergeCells(2, row, 5, row);
    row++;
    col = 1;

    // Address and Phone
    table.add(getSmallHeader(localize(KEY_ADDRESS_LABEL, "Address: ")), col++, row);
    row++;
    col = 1;
    table.add(getSmallHeader(localize(KEY_PHONE_LABEL, "Phone: ")), col++, row);
    if (pupil != null) {
      try {
        // pupil address
        Address address = getUserBusiness(iwc).getUsersMainAddress(pupil);
        StringBuffer aBuf = new StringBuffer(address.getStreetAddress());
        aBuf.append(", ");
        aBuf.append(address.getPostalCode().getPostalAddress());
        row--;
        table.add(getSmallText(aBuf.toString()), col, row);
        row++;
        // Get pupil phones
        Collection phones = pupil.getPhones();
        int i = 0;
        int phonesSize = phones.size();
        StringBuffer pBuf = new StringBuffer();
        for (Iterator iter = phones.iterator(); iter.hasNext(); i++) {
          Phone phone = (Phone) iter.next();
          pBuf.append(phone.getNumber());
          if (i < phonesSize - 1) {
            pBuf.append(", ");
          }
        }
        pBuf.append("&nbsp;");
        table.add(getSmallText(pBuf.toString()), col, row);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    row++;
    col = 1;

    return table;
  }