public class VisitorPersonalView {
  private static VisitorPersonalView instance;

  private VisitorPersonalView() {}

  public static VisitorPersonalView getInstance() {
    if (instance == null) instance = new VisitorPersonalView();
    return instance;
  }

  private JDialog dialog;
  private JPanel westPanel;
  private JPanel infoPanel;
  private JPanel abovePanel;
  private JPanel centerPanel;
  private JPanel bottomPanel;

  private JLabel lbFirstName;
  private JTextField tfFirstName;
  private JLabel lbMiddleName;
  private JTextField tfMiddleName;
  private JLabel lbSureName;
  private JTextField tfSureName;
  private JLabel lbBirthDay;
  private JTextField tfBirthDay;
  private JLabel lbAdress;
  private JTextField tfAdress;
  private JLabel lbNumberPhone;
  private JTextField tfNumberPhone;
  private JLabel lbDateReg;
  private JTextField tfDateReg;
  private JLabel lbCard;
  private JComboBox<String> cbCard;
  private JLabel lbBalance;
  private JTextField tfBalance;
  private JLabel lbDiscount;
  private JTextField tfDiscount;
  private ButtonGroup sexButtonGroup;
  private JRadioButton rbtnMale;
  private JRadioButton rbtnFemale;
  private JTextArea notation;
  private JScrollPane scroll;
  private JLabel photo;
  private ImageIcon image;
  private String fileImage = new String();

  private JTable personalTableService;
  private DefaultTableModel model = null;
  private VisitorPersonalListener listener = null;
  private CheckDataBaseManager dbManager = CheckDataBaseManager.getInstance();

  private Integer visitorId = 0;

  public void showPersonalVisitorView(Visitor visitor) {
    if (AppUtills.LEVEL_ACCESS.equals("adminnistrator")) {
      prepareDialog(visitor);
      setAccessLevel(true);
    } else if (AppUtills.LEVEL_ACCESS.equals("user")) {
      prepareDialog(visitor);
      setAccessLevel(false);
    } else {
      JOptionPane.showConfirmDialog(null, "бля, братан,шняга какая то...");
    }
  }

  private void prepareDialog(Visitor visitor) {
    listener = new VisitorPersonalListener();

    lbFirstName = new JLabel("имя:");
    lbFirstName.setBounds(10, 209, 70, 10);
    tfFirstName = new JTextField();
    tfFirstName.setBounds(80, 205, 110, 20);

    lbMiddleName = new JLabel("отчество:");
    lbMiddleName.setBounds(10, 230, 70, 10);
    tfMiddleName = new JTextField();
    tfMiddleName.setBounds(80, 225, 110, 20);

    lbSureName = new JLabel("фамилия:");
    lbSureName.setBounds(10, 248, 70, 15);
    tfSureName = new JTextField();
    tfSureName.setBounds(80, 245, 110, 20);

    lbBirthDay = new JLabel("д.рож.:");
    lbBirthDay.setBounds(10, 273, 70, 15);
    tfBirthDay = new JTextField();
    tfBirthDay.setBounds(80, 270, 110, 20);
    tfBirthDay.addKeyListener(listener);

    lbAdress = new JLabel("адресс:");
    lbAdress.setBounds(10, 298, 70, 15);
    tfAdress = new JTextField();
    tfAdress.setBounds(80, 295, 110, 20);

    lbNumberPhone = new JLabel("№ тел.:");
    lbNumberPhone.setBounds(10, 325, 70, 15);
    tfNumberPhone = new JTextField();
    tfNumberPhone.setBounds(80, 325, 110, 20);

    lbDateReg = new JLabel("д.регист.:");
    lbDateReg.setBounds(9, 350, 75, 15);
    tfDateReg = new JTextField();
    tfDateReg.setBounds(81, 350, 110, 20);
    tfDateReg.addKeyListener(listener);

    lbCard = new JLabel("карта:");
    lbCard.setBounds(10, 375, 70, 15);

    String[] arCard = new String[dbManager.getAllCards().size()];
    for (int i = 0; i < arCard.length; i++) {
      arCard[i] = dbManager.getAllCards().get(i).getCard();
    }
    cbCard = new JComboBox<String>(arCard);
    cbCard.setBounds(80, 375, 110, 20);

    lbBalance = new JLabel("баланс:");
    lbBalance.setBounds(10, 400, 70, 15);
    tfBalance = new JTextField();
    tfBalance.setBounds(80, 400, 110, 20);

    lbDiscount = new JLabel("скидки:");
    lbDiscount.setBounds(10, 425, 70, 15);
    tfDiscount = new JTextField();
    tfDiscount.setBounds(80, 425, 110, 20);
    sexButtonGroup = new ButtonGroup();
    rbtnMale = new JRadioButton("муж.");
    rbtnMale.setBounds(10, 450, 70, 20);
    rbtnFemale = new JRadioButton("жен.");
    rbtnFemale.setBounds(90, 450, 70, 20);
    sexButtonGroup.add(rbtnMale);
    sexButtonGroup.add(rbtnFemale);

    notation = new JTextArea();
    notation.setLineWrap(true);
    scroll =
        new JScrollPane(
            notation,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBounds(10, 480, 180, 50);

    westPanel = new JPanel();
    westPanel.setFocusable(false);
    westPanel.setPreferredSize(new Dimension(200, 400));
    westPanel.setLayout(null);

    photo = new JLabel();
    photo.setName("photo");
    photo.addMouseListener(listener);

    if (visitor == null) {
      image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());

    } else {
      this.setVisitorId(visitor.getId());
      tfFirstName.setText(visitor.getFirst_name().toString());
      tfMiddleName.setText(visitor.getPatronymic().toString());
      tfSureName.setText(visitor.getSurname().toString());
      tfBirthDay.setText(visitor.getBirthday().toString());
      tfAdress.setText(visitor.getAdress().toString());
      if (visitor.getSex().equals("мужчина")) rbtnMale.setSelected(true);
      if (visitor.getSex().equals("женщина")) rbtnFemale.setSelected(true);
      tfNumberPhone.setText(visitor.getNumber_phone() + "");
      tfDateReg.setText(visitor.getData_reg().toString());
      cbCard.setSelectedIndex(visitor.getIndexCard() - 1);

      tfBalance.setText(visitor.getBalance() + "");
      tfDiscount.setText("уточнять");
      notation.setText(visitor.getNotation().toString());
      if ((visitor.getPhoto().toString()).equals(null)
          || (visitor.getPhoto().toString()).equals("---")
          || (visitor.getPhoto().toString()).equals("")) {
        image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      } else {
        fileImage = visitor.getPhoto().toString();
        image = new ImageIcon(fileImage);
      }

      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());
    }

    JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
    separator.setBounds(0, 200, 200, 1);

    westPanel.add(photo);
    westPanel.add(separator);
    westPanel.add(lbFirstName);
    westPanel.add(tfFirstName);
    westPanel.add(lbMiddleName);
    westPanel.add(tfMiddleName);
    westPanel.add(lbSureName);
    westPanel.add(tfSureName);
    westPanel.add(lbBirthDay);
    westPanel.add(tfBirthDay);
    westPanel.add(lbAdress);
    westPanel.add(tfAdress);
    westPanel.add(lbNumberPhone);
    westPanel.add(tfNumberPhone);
    westPanel.add(lbDateReg);
    westPanel.add(tfDateReg);
    westPanel.add(lbCard);
    westPanel.add(cbCard);
    westPanel.add(lbBalance);
    westPanel.add(tfBalance);
    westPanel.add(lbDiscount);
    westPanel.add(tfDiscount);
    westPanel.add(rbtnMale);
    westPanel.add(rbtnFemale);
    westPanel.add(scroll);

    abovePanel = new JPanel();

    abovePanel.setPreferredSize(new Dimension(50, 50));

    model = new DefaultTableModel(AppUtills.PERSONAL_TABLE_COLUMN_NAME, 1);
    if (visitor != null) {
      List<BookService> listBookService = dbManager.getBookServiceByVisitorId(visitor.getId());
      for (int row = 0; row < listBookService.size(); row++) {
        int column = 0;
        BookService tmp = listBookService.get(row);
        model.addRow(new Vector<String>());
        model.setValueAt(tmp.getId(), row, column++);
        model.setValueAt(tmp.getService(), row, column++);
        model.setValueAt(tmp.getDate(), row, column++);
        model.setValueAt(tmp.getStaff(), row, column++);
        model.setValueAt(tmp.getNotation(), row, column);
      }
    }

    personalTableService =
        new JTable(model) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };
    personalTableService.setName("personalTableBookService");
    personalTableService.getColumnModel().getColumn(0).setMaxWidth(50);
    personalTableService.getColumnModel().getColumn(2).setMaxWidth(80);
    personalTableService.addMouseListener(listener);
    JScrollPane scroll =
        new JScrollPane(
            personalTableService,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 1));
    centerPanel.add(scroll);
    centerPanel.setBackground(Color.RED);
    centerPanel.setPreferredSize(new Dimension(50, 50));

    JButton btnSave = new JButton("сохранить");
    btnSave.setToolTipText("сохранить нового посетителя");
    btnSave.addActionListener(listener);
    JButton btnCancel = new JButton("отмена");
    btnCancel.setToolTipText("закрыть без сохраниения");
    btnCancel.addActionListener(listener);

    bottomPanel = new JPanel();
    bottomPanel.add(btnSave);
    bottomPanel.add(btnCancel);
    bottomPanel.setPreferredSize(new Dimension(50, 50));

    infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    infoPanel.add(abovePanel, BorderLayout.NORTH);
    infoPanel.add(centerPanel, BorderLayout.CENTER);
    infoPanel.add(bottomPanel, BorderLayout.SOUTH);

    dialog = new JDialog();
    dialog.setAlwaysOnTop(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(850, 550);
    dialog.setResizable(false);
    dialog.setLayout(new BorderLayout());
    dialog.getContentPane().add(westPanel, BorderLayout.WEST);
    dialog.getContentPane().add(infoPanel, BorderLayout.CENTER);
    dialog.setVisible(true);
  }

  public ImageIcon scaleImage(ImageIcon icon) {
    if ((icon.getIconWidth() > 195 && icon.getIconHeight() > 190)) {
      ImageIcon imageScale =
          new ImageIcon(
              icon.getImage()
                  .getScaledInstance(
                      icon.getIconWidth() / 2, icon.getIconHeight() / 2, Image.SCALE_DEFAULT));
      return this.scaleImage(imageScale);
    } else {
      return icon;
    }
  }

  public Visitor getVisitor() {
    Visitor visitor = new Visitor();
    visitor.setFirst_name(this.getTfFirstName().getText().toString().trim());
    visitor.setPatronymic(this.getTfMiddleName().getText().toString().trim());
    visitor.setSurname(this.getTfSureName().getText().toString().trim());
    if (rbtnMale.isSelected()) visitor.setSex("мужчина");
    if (rbtnFemale.isSelected()) visitor.setSex("женщина");
    visitor.setAdress(this.getTfAdress().getText().toString().trim());
    visitor.setBirthday(this.getTfBirthDay().getText().toString().trim());
    visitor.setNumber_phone(this.getTfNumberPhone().getText().toString().trim());
    visitor.setIndexCard(cbCard.getSelectedIndex() + 1);
    visitor.setCard(cbCard.getSelectedItem().toString().trim());
    visitor.setKey(0);
    visitor.setNotation(this.getNotation().getText().toString().trim());
    visitor.setDate_reg(this.getTfDateReg().getText().toString().trim());
    visitor.setBalance(this.getTfBalance().getText().toString().trim());
    visitor.setPhoto(this.fileImage);

    return visitor;
  }

  public void changePersonalPhoto(File newPhoto) {

    if (newPhoto != null) {
      fileImage = new String(newPhoto.getAbsoluteFile().toString());
      ImageIcon newImage = new ImageIcon(fileImage);
      this.getPhoto().setIcon(this.scaleImage(newImage));
      this.getPhoto().setBounds(10, 10, 180, 180);
      this.getPhoto().setBorder(BorderFactory.createEtchedBorder());
    }
  }

  public void addValueToRow(BookService bookService, int row) {
    model.setValueAt(bookService.getId(), row, 0);
    model.setValueAt(bookService.getService(), row, 1);
    model.setValueAt(bookService.getDate(), row, 2);
    model.setValueAt(bookService.getStaff(), row, 3);
    model.setValueAt(bookService.getNotation(), row, 4);
  }

  private void setAccessLevel(boolean flag) {
    tfFirstName.setEditable(flag);
    tfMiddleName.setEditable(flag);
    tfSureName.setEditable(flag);
    tfBirthDay.setEditable(flag);
    tfAdress.setEditable(flag);
    tfNumberPhone.setEditable(flag);
    tfDateReg.setEditable(flag);
    rbtnFemale.setEnabled(flag);
    rbtnMale.setEnabled(flag);
    cbCard.setEnabled(flag);
    tfBalance.setEditable(flag);
    tfDiscount.setEditable(flag);
    notation.setEditable(flag);
  }

  public JDialog getDialog() {
    return dialog;
  }

  public void setDialog(JDialog dialog) {
    this.dialog = dialog;
  }

  public JPanel getWestPanel() {
    return westPanel;
  }

  public void setWestPanel(JPanel westPanel) {
    this.westPanel = westPanel;
  }

  public JPanel getInfoPanel() {
    return infoPanel;
  }

  public void setInfoPanel(JPanel infoPanel) {
    this.infoPanel = infoPanel;
  }

  public JPanel getAbovePanel() {
    return abovePanel;
  }

  public void setAbovePanel(JPanel abovePanel) {
    this.abovePanel = abovePanel;
  }

  public JPanel getCenterPanel() {
    return centerPanel;
  }

  public void setCenterPanel(JPanel centerPanel) {
    this.centerPanel = centerPanel;
  }

  public JPanel getBottomPanel() {
    return bottomPanel;
  }

  public void setBottomPanel(JPanel bottomPanel) {
    this.bottomPanel = bottomPanel;
  }

  public JLabel getLbFirstName() {
    return lbFirstName;
  }

  public void setLbFirstName(JLabel lbFirstName) {
    this.lbFirstName = lbFirstName;
  }

  public JLabel getLbMiddleName() {
    return lbMiddleName;
  }

  public void setLbMiddleName(JLabel lbMiddleName) {
    this.lbMiddleName = lbMiddleName;
  }

  public JLabel getLbSureName() {
    return lbSureName;
  }

  public void setLbSureName(JLabel lbSureName) {
    this.lbSureName = lbSureName;
  }

  public JLabel getLbBirthDay() {
    return lbBirthDay;
  }

  public void setLbBirthDay(JLabel lbBirthDay) {
    this.lbBirthDay = lbBirthDay;
  }

  public JLabel getLbAdress() {
    return lbAdress;
  }

  public void setLbAdress(JLabel lbAdress) {
    this.lbAdress = lbAdress;
  }

  public JLabel getLbNumberPhone() {
    return lbNumberPhone;
  }

  public void setLbNumberPhone(JLabel lbNumberPhone) {
    this.lbNumberPhone = lbNumberPhone;
  }

  public JLabel getLbDateReg() {
    return lbDateReg;
  }

  public void setLbDateReg(JLabel lbDateReg) {
    this.lbDateReg = lbDateReg;
  }

  public JLabel getLbCard() {
    return lbCard;
  }

  public void setLbCard(JLabel lbCard) {
    this.lbCard = lbCard;
  }

  public JLabel getLbBalance() {
    return lbBalance;
  }

  public void setLbBalance(JLabel lbBalance) {
    this.lbBalance = lbBalance;
  }

  public JLabel getLbDiscount() {
    return lbDiscount;
  }

  public void setLbDiscount(JLabel lbDiscount) {
    this.lbDiscount = lbDiscount;
  }

  public JTextArea getNotation() {
    return notation;
  }

  public void setNotation(JTextArea notation) {
    this.notation = notation;
  }

  public JScrollPane getScroll() {
    return scroll;
  }

  public void setScroll(JScrollPane scroll) {
    this.scroll = scroll;
  }

  public JTextField getTfFirstName() {
    return tfFirstName;
  }

  public void setTfFirstName(JTextField tfFirstName) {
    this.tfFirstName = tfFirstName;
  }

  public JTextField getTfMiddleName() {
    return tfMiddleName;
  }

  public void setTfMiddleName(JTextField tfMiddleName) {
    this.tfMiddleName = tfMiddleName;
  }

  public JTextField getTfSureName() {
    return tfSureName;
  }

  public void setTfSureName(JTextField tfSureName) {
    this.tfSureName = tfSureName;
  }

  public JTextField getTfBirthDay() {
    return tfBirthDay;
  }

  public void setTfBirthDay(JTextField tfBirthDay) {
    this.tfBirthDay = tfBirthDay;
  }

  public JTextField getTfAdress() {
    return tfAdress;
  }

  public void setTfAdress(JTextField tfAdress) {
    this.tfAdress = tfAdress;
  }

  public JTextField getTfNumberPhone() {
    return tfNumberPhone;
  }

  public void setTfNumberPhone(JTextField tfNumberPhone) {
    this.tfNumberPhone = tfNumberPhone;
  }

  public JTextField getTfDateReg() {
    return tfDateReg;
  }

  public void setTfDateReg(JTextField tfDateReg) {
    this.tfDateReg = tfDateReg;
  }

  public JComboBox<String> getTfCard() {
    return cbCard;
  }

  public void setTfCard(JComboBox<String> tfCard) {
    this.cbCard = tfCard;
  }

  public JTextField getTfBalance() {
    return tfBalance;
  }

  public void setTfBalance(JTextField tfBalance) {
    this.tfBalance = tfBalance;
  }

  public JTextField getTfDiscount() {
    return tfDiscount;
  }

  public void setTfDiscount(JTextField tfDiscount) {
    this.tfDiscount = tfDiscount;
  }

  public JLabel getPhoto() {
    return photo;
  }

  public void setPhoto(JLabel photo) {
    this.photo = photo;
  }

  public Integer getVisitorId() {
    return visitorId;
  }

  public void setVisitorId(Integer visitorId) {
    this.visitorId = visitorId;
  }

  public JTable getPersonalTableService() {
    return personalTableService;
  }

  public void setPersonalTableService(JTable personalTableService) {
    this.personalTableService = personalTableService;
  }
}
  private void prepareDialog(Visitor visitor) {
    listener = new VisitorPersonalListener();

    lbFirstName = new JLabel("имя:");
    lbFirstName.setBounds(10, 209, 70, 10);
    tfFirstName = new JTextField();
    tfFirstName.setBounds(80, 205, 110, 20);

    lbMiddleName = new JLabel("отчество:");
    lbMiddleName.setBounds(10, 230, 70, 10);
    tfMiddleName = new JTextField();
    tfMiddleName.setBounds(80, 225, 110, 20);

    lbSureName = new JLabel("фамилия:");
    lbSureName.setBounds(10, 248, 70, 15);
    tfSureName = new JTextField();
    tfSureName.setBounds(80, 245, 110, 20);

    lbBirthDay = new JLabel("д.рож.:");
    lbBirthDay.setBounds(10, 273, 70, 15);
    tfBirthDay = new JTextField();
    tfBirthDay.setBounds(80, 270, 110, 20);
    tfBirthDay.addKeyListener(listener);

    lbAdress = new JLabel("адресс:");
    lbAdress.setBounds(10, 298, 70, 15);
    tfAdress = new JTextField();
    tfAdress.setBounds(80, 295, 110, 20);

    lbNumberPhone = new JLabel("№ тел.:");
    lbNumberPhone.setBounds(10, 325, 70, 15);
    tfNumberPhone = new JTextField();
    tfNumberPhone.setBounds(80, 325, 110, 20);

    lbDateReg = new JLabel("д.регист.:");
    lbDateReg.setBounds(9, 350, 75, 15);
    tfDateReg = new JTextField();
    tfDateReg.setBounds(81, 350, 110, 20);
    tfDateReg.addKeyListener(listener);

    lbCard = new JLabel("карта:");
    lbCard.setBounds(10, 375, 70, 15);

    String[] arCard = new String[dbManager.getAllCards().size()];
    for (int i = 0; i < arCard.length; i++) {
      arCard[i] = dbManager.getAllCards().get(i).getCard();
    }
    cbCard = new JComboBox<String>(arCard);
    cbCard.setBounds(80, 375, 110, 20);

    lbBalance = new JLabel("баланс:");
    lbBalance.setBounds(10, 400, 70, 15);
    tfBalance = new JTextField();
    tfBalance.setBounds(80, 400, 110, 20);

    lbDiscount = new JLabel("скидки:");
    lbDiscount.setBounds(10, 425, 70, 15);
    tfDiscount = new JTextField();
    tfDiscount.setBounds(80, 425, 110, 20);
    sexButtonGroup = new ButtonGroup();
    rbtnMale = new JRadioButton("муж.");
    rbtnMale.setBounds(10, 450, 70, 20);
    rbtnFemale = new JRadioButton("жен.");
    rbtnFemale.setBounds(90, 450, 70, 20);
    sexButtonGroup.add(rbtnMale);
    sexButtonGroup.add(rbtnFemale);

    notation = new JTextArea();
    notation.setLineWrap(true);
    scroll =
        new JScrollPane(
            notation,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBounds(10, 480, 180, 50);

    westPanel = new JPanel();
    westPanel.setFocusable(false);
    westPanel.setPreferredSize(new Dimension(200, 400));
    westPanel.setLayout(null);

    photo = new JLabel();
    photo.setName("photo");
    photo.addMouseListener(listener);

    if (visitor == null) {
      image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());

    } else {
      this.setVisitorId(visitor.getId());
      tfFirstName.setText(visitor.getFirst_name().toString());
      tfMiddleName.setText(visitor.getPatronymic().toString());
      tfSureName.setText(visitor.getSurname().toString());
      tfBirthDay.setText(visitor.getBirthday().toString());
      tfAdress.setText(visitor.getAdress().toString());
      if (visitor.getSex().equals("мужчина")) rbtnMale.setSelected(true);
      if (visitor.getSex().equals("женщина")) rbtnFemale.setSelected(true);
      tfNumberPhone.setText(visitor.getNumber_phone() + "");
      tfDateReg.setText(visitor.getData_reg().toString());
      cbCard.setSelectedIndex(visitor.getIndexCard() - 1);

      tfBalance.setText(visitor.getBalance() + "");
      tfDiscount.setText("уточнять");
      notation.setText(visitor.getNotation().toString());
      if ((visitor.getPhoto().toString()).equals(null)
          || (visitor.getPhoto().toString()).equals("---")
          || (visitor.getPhoto().toString()).equals("")) {
        image = new ImageIcon(StartAplication.class.getClass().getResource("/visitor.png"));
      } else {
        fileImage = visitor.getPhoto().toString();
        image = new ImageIcon(fileImage);
      }

      photo.setIcon(this.scaleImage(image));
      photo.setBounds(10, 10, 180, 180);
      photo.setBorder(BorderFactory.createEtchedBorder());
    }

    JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
    separator.setBounds(0, 200, 200, 1);

    westPanel.add(photo);
    westPanel.add(separator);
    westPanel.add(lbFirstName);
    westPanel.add(tfFirstName);
    westPanel.add(lbMiddleName);
    westPanel.add(tfMiddleName);
    westPanel.add(lbSureName);
    westPanel.add(tfSureName);
    westPanel.add(lbBirthDay);
    westPanel.add(tfBirthDay);
    westPanel.add(lbAdress);
    westPanel.add(tfAdress);
    westPanel.add(lbNumberPhone);
    westPanel.add(tfNumberPhone);
    westPanel.add(lbDateReg);
    westPanel.add(tfDateReg);
    westPanel.add(lbCard);
    westPanel.add(cbCard);
    westPanel.add(lbBalance);
    westPanel.add(tfBalance);
    westPanel.add(lbDiscount);
    westPanel.add(tfDiscount);
    westPanel.add(rbtnMale);
    westPanel.add(rbtnFemale);
    westPanel.add(scroll);

    abovePanel = new JPanel();

    abovePanel.setPreferredSize(new Dimension(50, 50));

    model = new DefaultTableModel(AppUtills.PERSONAL_TABLE_COLUMN_NAME, 1);
    if (visitor != null) {
      List<BookService> listBookService = dbManager.getBookServiceByVisitorId(visitor.getId());
      for (int row = 0; row < listBookService.size(); row++) {
        int column = 0;
        BookService tmp = listBookService.get(row);
        model.addRow(new Vector<String>());
        model.setValueAt(tmp.getId(), row, column++);
        model.setValueAt(tmp.getService(), row, column++);
        model.setValueAt(tmp.getDate(), row, column++);
        model.setValueAt(tmp.getStaff(), row, column++);
        model.setValueAt(tmp.getNotation(), row, column);
      }
    }

    personalTableService =
        new JTable(model) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };
    personalTableService.setName("personalTableBookService");
    personalTableService.getColumnModel().getColumn(0).setMaxWidth(50);
    personalTableService.getColumnModel().getColumn(2).setMaxWidth(80);
    personalTableService.addMouseListener(listener);
    JScrollPane scroll =
        new JScrollPane(
            personalTableService,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 1));
    centerPanel.add(scroll);
    centerPanel.setBackground(Color.RED);
    centerPanel.setPreferredSize(new Dimension(50, 50));

    JButton btnSave = new JButton("сохранить");
    btnSave.setToolTipText("сохранить нового посетителя");
    btnSave.addActionListener(listener);
    JButton btnCancel = new JButton("отмена");
    btnCancel.setToolTipText("закрыть без сохраниения");
    btnCancel.addActionListener(listener);

    bottomPanel = new JPanel();
    bottomPanel.add(btnSave);
    bottomPanel.add(btnCancel);
    bottomPanel.setPreferredSize(new Dimension(50, 50));

    infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    infoPanel.add(abovePanel, BorderLayout.NORTH);
    infoPanel.add(centerPanel, BorderLayout.CENTER);
    infoPanel.add(bottomPanel, BorderLayout.SOUTH);

    dialog = new JDialog();
    dialog.setAlwaysOnTop(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(850, 550);
    dialog.setResizable(false);
    dialog.setLayout(new BorderLayout());
    dialog.getContentPane().add(westPanel, BorderLayout.WEST);
    dialog.getContentPane().add(infoPanel, BorderLayout.CENTER);
    dialog.setVisible(true);
  }