public void view(ActionEvent actionEvent) {

    Alert alert = new Alert(Alert.AlertType.INFORMATION, orderArrayToString(), ButtonType.OK);
    alert.setHeaderText("View Order");
    alert.setResizable(true);
    alert.getDialogPane().setPrefWidth(alert.getDialogPane().getWidth() * 2);
    // alert.setContentText(orderString.toString());
    alert.show();
  }
  private void invoiceAlert(String message) {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Invoice");
    alert.setHeaderText(null);
    alert.setContentText(message);
    alert.getDialogPane().setStyle(" -fx-max-width:500px; -fx-pref-width: 500px;");

    alert.show();
  }
  public void viewOrder() {
    String currentOrder = "";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      currentOrder += counter + ". " + i.toString() + "\n";
    }
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Current Order");
    alert.setHeaderText("Your current order is as follows:");
    alert.setContentText(currentOrder);
    alert.getDialogPane().setStyle(" -fx-max-width:500px; -fx-pref-width: 500px;");

    alert.showAndWait();
  }
  void deletePlaylist() {
    if (interfaceDisabled) return;
    Playlist p = getSelectedPlaylist();
    if (p == null) return;
    Alert alert = new Alert(AlertType.CONFIRMATION);
    ButtonType btYes = new ButtonType(res.getString("yes"), ButtonBar.ButtonData.YES);
    ButtonType btCancel =
        new ButtonType(res.getString("cancel"), ButtonBar.ButtonData.CANCEL_CLOSE);
    alert.getButtonTypes().setAll(btYes, btCancel);
    alert.setTitle(res.getString("delete_playlist"));
    alert.setHeaderText(res.getString("delete_playlist"));
    alert.setContentText(String.format(res.getString("delete_confirm"), p.getTitle()));
    alert.getDialogPane().getStylesheets().add("/styles/dialogs.css");
    ((Stage) alert.getDialogPane().getScene().getWindow()).getIcons().addAll(logoImages);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == btYes) {
      Cache.deletePlaylist(p);
      Platform.runLater(
          () -> {
            updatePlaylists();
          });
    }
  }
  public void finishOrder(ActionEvent actionEvent) {
    StringBuilder orderString = new StringBuilder();
    // create new alert
    Alert alert = new Alert(Alert.AlertType.INFORMATION, "", ButtonType.OK);
    // get date
    Date date = new Date();
    DateFormat format1 = new SimpleDateFormat("MM/dd/yy hh:mm:ss a z");
    DateFormat format2 = new SimpleDateFormat("yyMMddhhmmss");
    orderString.append(
        String.format(
            "%s\n\nNumber of line items:%d\n\nItem#/ID/Title/Price/Qty/Disc%%/Subtotal:\n\n%s\n\nOrder Subtotal:$%.2f\n\n"
                + "Tax Rate:\t6%%\n\nTax Amount:$%.2f\n\nOrder Total:$%.2f\n\nThanks for shopping!",
            format1.format(date),
            myOrders.size(),
            orderArrayToString(),
            Order.getRunningTotal(),
            Order.getRunningTotal() * .06,
            Order.getRunningTotal() + Order.getRunningTotal() * .06));

    // print order array
    // print subtotal
    // print 6% tax
    // add tax and generate new total
    // show alert
    // call new order

    alert.setHeaderText("Order Receipt");
    alert.setResizable(true);
    alert.getDialogPane().setPrefWidth(alert.getDialogPane().getWidth() * 2);
    alert.setContentText(orderString.toString());
    alert.show();

    // output transactions.txt
    OpenOption[] options = {
      StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.APPEND
    };
    Path file = Paths.get("transaction.txt");

    try {
      BufferedWriter writer = Files.newBufferedWriter(file, Charset.defaultCharset(), options);

      int i = 0;
      for (Order order : myOrders) {
        // String[] strArray = order.toString().split(" ");
        // System.out.println(strArray[0] + strArray[1]);
        writer.write(
            String.format(
                "%s, %s, %s, %s, %s, %s, %s, %s\n",
                format2.format(date),
                order.getOrderedBook().getBookID(),
                order.getOrderedBook().getBookTitle(),
                order.getOrderedBook().getPrice(),
                order.getQuantity(),
                order.getDiscount(),
                order.getFinalPrice(),
                format1.format(date)));
      }

      writer.close();
    } catch (IOException e) {
      System.out.println("OOPS");
      e.printStackTrace();
    }

    newOrder(new ActionEvent());
  }