fork download
  1. package controller;
  2.  
  3. import Entities.*;
  4. import com.jfoenix.controls.*;
  5. import constant.Language;
  6. import handler.CreatePdf;
  7. import handler.SceneHandler;
  8. import javafx.beans.property.SimpleStringProperty;
  9. import javafx.collections.FXCollections;
  10. import javafx.collections.ObservableList;
  11. import javafx.collections.transformation.FilteredList;
  12. import javafx.collections.transformation.SortedList;
  13. import javafx.event.ActionEvent;
  14. import javafx.fxml.FXML;
  15. import javafx.fxml.Initializable;
  16. import javafx.scene.control.*;
  17. import javafx.scene.input.MouseEvent;
  18. import javafx.scene.layout.Pane;
  19. import javafx.stage.Stage;
  20. import message.InfoMessage;
  21. import org.codehaus.plexus.util.StringUtils;
  22. import security.InterfaceLanguage;
  23. import security.UserSession;
  24. import utility.ConnectionUtil;
  25. import utility.DateUtil;
  26.  
  27. import javax.persistence.TypedQuery;
  28. import java.net.URL;
  29. import java.sql.Date;
  30. import java.sql.Timestamp;
  31. import java.text.SimpleDateFormat;
  32. import java.time.*;
  33. import java.util.*;
  34. import java.util.function.Predicate;
  35. import java.util.regex.Matcher;
  36. import java.util.regex.Pattern;
  37.  
  38.  
  39. public class RentController implements Initializable {
  40.  
  41. /*
  42.   -1 Car Table view Definition
  43.   -2 Customer Table view Definition
  44.   -3 Customer Search field and Car Search field Difintion
  45.   -4 Lower half Pane which contains evrything without upper half (Definition)
  46.   -5 Second Driver Pane (Definition )
  47.   -6 Mixed variables Defintion
  48.   -7 Variables for Date validation Definition
  49.   -8 variables for arethmatic Definition
  50.   -9 Radio button(of Car) controller line 165
  51.   -10 Radio button(of Customer) controller line 181
  52.   -11 Car Search Controller line 198
  53.   -12 Customer Search Controller line 222
  54.   -13 retrieve Customer Data inside Customer Table view (this function inside initialize method) line 273
  55.   -14 retrieve Car Data inside Customer Table view (this function inside initialize method) line 305
  56.   -15 customer sellection on mouse double click (this function inside initialize method) line 333
  57.   -16 Car sellection on mouse double click (this function inside initialize method) line 363
  58.   -17 fill All combo boxes (this function inside initialize method) from line 388 to line 430
  59.   -18 calcualte all calculation of rent (this function inside initialize method) line 435
  60.   -19 Dates validation Controller (this function inside initialize method) line 449
  61.   */
  62.  
  63. private static final Pattern VALID_STRING_REGEX =
  64. Pattern.compile("^[a-z-A-Z\\p{InArabic}\\s]*$", Pattern.CASE_INSENSITIVE);
  65. private static final Pattern VALID_PHONE_NUMBER_REGEX =
  66. Pattern.compile("^\\d+$");
  67.  
  68. //***** Section number __1__ 'Car Table view' *****
  69. @FXML
  70. ScrollPane carScroll;
  71. @FXML
  72. private TableView<Car> carTable;
  73. @FXML
  74. private TableColumn<Car, String> carPlateNumber, carYear, carOwnerName, carMileage, kiloMeters, carSize, carDoorsNumber, carChassisNumber, carLicenseExpirationDate, carExtraInfo, carModel, carState, carInsurance, carType, carColor, carEngineStatus, carEngineNumber;
  75.  
  76.  
  77. //***** Section number __2__ 'Customer Table view' *****
  78. @FXML
  79. ScrollPane customerScroll;
  80. @FXML
  81. private TableView<Customer> customerTable;
  82. @FXML
  83. private TableColumn<Customer, String> firstName;
  84. @FXML
  85. private TableColumn<Customer, String> middleName;
  86. @FXML
  87. private TableColumn<Customer, String> lastName;
  88. @FXML
  89. private TableColumn<Customer, String> ssn;
  90. @FXML
  91. private TableColumn<Customer, String> currentCredit;
  92. @FXML
  93. private TableColumn<Customer, String> licenseNumber;
  94. @FXML
  95. private TableColumn<Customer, String> licenseExpiration;
  96. @FXML
  97. private TableColumn<Customer, String> birthDate;
  98. @FXML
  99. private TableColumn<Customer, String> bloodType;
  100. @FXML
  101. private TableColumn<Customer, String> email;
  102. @FXML
  103. private TableColumn<Customer, String> address;
  104. @FXML
  105. private TableColumn<Customer, String> passportNumber;
  106. @FXML
  107. private TableColumn<Customer, String> phoneNumber;
  108. @FXML
  109. private TableColumn<Customer, String> alternativePhone;
  110. @FXML
  111. private TableColumn<Customer, String> country;
  112.  
  113. // @FXML public Label customerCurrentCreditLabel;
  114.  
  115.  
  116. //***** Section number __3__ 'Customer Search field and Car Search field ' *****
  117. @FXML
  118. public JFXTextField carSearch;
  119. @FXML
  120. public JFXTextField customerSearch;
  121. @FXML
  122. JFXRadioButton customerRadio;
  123. @FXML
  124. JFXRadioButton carRadio;
  125. @FXML
  126. JFXButton addSecondDriverButton;
  127.  
  128.  
  129. //***** Section number __4__ Lower half Pane which contains evrything without upper half *****
  130. @FXML
  131. public Pane halfPane;
  132. @FXML
  133. private Pane searchPane;
  134. @FXML
  135. public Label driverNameLabel;
  136. @FXML
  137. public Label currentCreditLabel;
  138. @FXML
  139. public Label expirationLabel;
  140. @FXML
  141. public Label subModelLabel;
  142. @FXML
  143. public Label plateLabel;
  144. @FXML
  145. public Label modelLabel;
  146. @FXML
  147. public Label customerPhoneNumberLabel;
  148.  
  149. @FXML
  150. private JFXButton rentBtn;
  151.  
  152. @FXML
  153. private JFXComboBox<String> openingCombo;
  154. @FXML
  155. private JFXTextField downPaymentField;
  156. @FXML
  157. private DatePicker startDate;
  158. @FXML
  159. private JFXComboBox<String> closingCombo;
  160. @FXML
  161. private JFXTextField depositField;
  162. @FXML
  163. private JFXTextField currentMileageField;
  164. @FXML
  165. private Label totalExtraDaysLabel;
  166. @FXML
  167. private DatePicker endDate;
  168.  
  169. @FXML
  170. private Label totalDurationLabel;
  171. @FXML
  172. private JFXComboBox<String> paymentCombo;
  173. @FXML
  174. private JFXTextField pricePerDayField;
  175. @FXML
  176. private Label finalPriceLabel;
  177. @FXML
  178. private Label taxLabel;
  179. @FXML
  180. private Label priceLabel;
  181. @FXML
  182. private JFXComboBox<Double> taxCombo;
  183. @FXML
  184. private JFXTextField allowedMileageField;
  185. @FXML
  186. private JFXComboBox<String> currentFuelField;
  187. @FXML
  188. private Label remainingAmountLabel;
  189. @FXML
  190. private JFXTextArea notesField;
  191.  
  192.  
  193. //***** Section number __5__ 'Second Driver Pane ' *****
  194. @FXML
  195. private Pane secondDiverPane;
  196. @FXML
  197. private JFXTextField SecondDriverName;
  198. @FXML
  199. private JFXTextField secondDriverLicenceNumber;
  200. @FXML
  201. private JFXTextField secondDriverSsnPass;
  202. @FXML
  203. private JFXComboBox<String> secondDriverNationality;
  204. @FXML
  205. private JFXComboBox<String> secondDriverLicenceCountry;
  206. @FXML
  207. private DatePicker secondDriverLicenceExpiration;
  208. @FXML
  209. private Label secondDriverNameLabel;
  210. @FXML
  211. private JFXTextField secondDriverMiddleName;
  212. @FXML
  213. private JFXTextField secondDriverLastName;
  214. @FXML
  215. private Label secondDriverExpirationLabel;
  216.  
  217. @FXML
  218. private JFXTextField secondDriverPhone;
  219. @FXML
  220. private Label secondDriverPhoneLabel;
  221. @FXML
  222. JFXButton backButton;
  223. @FXML
  224. JFXToggleButton unlimitedBtn;
  225.  
  226.  
  227. //***** Section number __6__ 'Mixed variables' *****
  228. public static Car selectedCar;
  229. public static Customer selectedCustomer;
  230. public int i;
  231. public ObservableList<Car> list = FXCollections.observableArrayList();
  232. public ObservableList<Customer> customerObservableList = FXCollections.observableArrayList();
  233.  
  234.  
  235. //***** Section number __7__ 'Variables for Date validation ' *****
  236. private static long today;
  237. private static long start;
  238. private static long tomorrow;
  239. private static long end;
  240. private static Timestamp startTime;
  241. private static SimpleDateFormat sdf;
  242. private static Date time;
  243. private static LocalTime n;
  244.  
  245.  
  246. //***** Section number __8__ 'variables for arethmatic ' *****
  247. public long difference;
  248. private static double remaining;
  249. private static double total;
  250. public static double b;
  251. public static double remainingCustomerCredit;
  252.  
  253.  
  254. //***** Section number __9__ Radio button(of Car) controller *****
  255. @FXML
  256. private void carRadioButton(ActionEvent event) {
  257. carScroll.setVisible(true);
  258. carScroll.setDisable(false);
  259. carTable.setVisible(true);
  260. carTable.setDisable(false);
  261. carSearch.setDisable(false);
  262. carSearch.setEditable(true);
  263. customerScroll.setVisible(false);
  264. customerTable.setVisible(false);
  265. customerSearch.setVisible(true);
  266. customerSearch.setDisable(true);
  267. i = 1;
  268. }
  269.  
  270. //***** Section number __10__ Radio button(of Customer) controller *****
  271. @FXML
  272. private void customerRadioButton(ActionEvent event) {
  273.  
  274. customerScroll.setVisible(true);
  275. customerTable.setVisible(true);
  276. customerSearch.setEditable(true);
  277. customerSearch.setDisable(false);
  278. carScroll.setVisible(false);
  279. carTable.setVisible(false);
  280. carSearch.setEditable(false);
  281. carSearch.setDisable(true);
  282. i = 2;
  283. }
  284.  
  285.  
  286. //***** Section number __11__ Car Search Controller *****
  287. private void CarSearch() {
  288.  
  289. FilteredList<Car> filteredList = new FilteredList<>(list, e -> true);
  290. carSearch.setOnKeyReleased(ex -> {
  291. carSearch.textProperty().addListener((observableValue, oldValue, newValue) -> {
  292. filteredList.setPredicate((Predicate<? super Car>) car -> {
  293. if (newValue == null || newValue.isEmpty()) {
  294. return true;
  295. }
  296. String lowerCaseFilter = newValue.toLowerCase();
  297. return String.valueOf(car.getPlateNumber()).toLowerCase().contains(lowerCaseFilter);
  298. });
  299. });
  300. SortedList<Car> sortedList = new SortedList<>(filteredList);
  301. sortedList.comparatorProperty().bind(carTable.comparatorProperty());
  302. carTable.setItems(sortedList);
  303. });
  304. }
  305.  
  306. //***** Section number __12__ Customer Search Controller *****
  307. private void CustomerSearch() {
  308. FilteredList<Customer> customerFilteredList = new FilteredList<>(customerObservableList, e -> true);
  309. customerSearch.setOnKeyReleased(ex -> {
  310. customerSearch.textProperty().addListener((observableValue, oldValue, newValue) -> {
  311. customerFilteredList.setPredicate((Predicate<? super Customer>) customer -> {
  312. if (newValue == null || newValue.isEmpty()) {
  313. return true;
  314. }
  315. String lowerCaseFilter = newValue.toLowerCase();
  316. if (String.valueOf(customer.getFirstName()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  317. return true;
  318. } else if (String.valueOf(customer.getMiddleName()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  319. return true;
  320. } else if (String.valueOf(customer.getLastName()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  321. return true;
  322. } else if (String.valueOf(customer.getSsn()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  323. return true;
  324. } else if (String.valueOf(customer.getLicenseNumber()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  325. return true;
  326. } else if (String.valueOf(customer.getEmail()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  327. return true;
  328. } else if (String.valueOf(customer.getPassportNumber()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  329. return true;
  330. } else if (String.valueOf(customer.getPhoneNumber()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  331. return true;
  332. } else if (String.valueOf(customer.getAlternativeNumber()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  333. return true;
  334. } else if (String.valueOf(customer.getCountry()).toLowerCase().indexOf(lowerCaseFilter) != -1) {
  335. return true;
  336. }
  337. return false;
  338. });
  339. });
  340. SortedList<Customer> customerSortedList = new SortedList<>(customerFilteredList);
  341. customerSortedList.comparatorProperty().bind(customerTable.comparatorProperty());
  342. customerTable.setItems(customerSortedList);
  343. });
  344. }
  345.  
  346. @Override
  347. public void initialize(URL location, ResourceBundle resources) {
  348. if (!ConnectionUtil.getEntityManager().getTransaction().isActive()) {
  349. ConnectionUtil.getEntityManager().getTransaction().begin();
  350. }
  351.  
  352.  
  353. //for car table
  354. list.clear();
  355. customerObservableList.clear();
  356.  
  357.  
  358. //***** Section number __13__ retrieve Customer Data inside Customer Table view (this function inside initialize method) *****
  359.  
  360. try {
  361.  
  362. //TODO where c.carStatus='2L'
  363. List<Car> cars = ConnectionUtil.getEntityManager().createQuery("select c from Car c where c.carStatus.carStatusName = 'Available' ", Car.class).getResultList();
  364.  
  365. list.addAll(cars);
  366. carPlateNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getPlateNumber()));
  367. carYear.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getYear()));
  368. carOwnerName.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getOwnerName()));
  369. carMileage.setCellValueFactory(data -> new SimpleStringProperty(String.valueOf(data.getValue().getCarMileage())));
  370. kiloMeters.setCellValueFactory(data -> new SimpleStringProperty(String.valueOf(data.getValue().getCarKilometers())));
  371. carSize.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarSize()));
  372. carEngineNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarEngineNumber()));
  373. carChassisNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarChassisNumber()));
  374. carLicenseExpirationDate.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getLicenseExpirationDate().toString()));
  375. carExtraInfo.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getExtraInformation()));
  376. carModel.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getModel().getSubModelType()));
  377. carState.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarStatus().getCarStatusName()));
  378. carInsurance.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarInsurance().getCarInsuranceType()));
  379. carType.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarPowerType().getPowerType()));
  380. carColor.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getCarColor().getColorName()));
  381. carTable.setItems(list);
  382. } catch (Exception e) {
  383. throw new RuntimeException(e);
  384. }
  385.  
  386.  
  387. //***** Section number __14__ retrieve Car Data inside Customer Table view (this function inside initialize method) *****
  388. try {
  389. List<Customer> customers = ConnectionUtil.getEntityManager().createQuery(" select c FROM Customer c where c.isBlocked=false ", Customer.class).getResultList();
  390. customerObservableList.addAll(customers);
  391. firstName.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getFirstName()));
  392. middleName.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getMiddleName()));
  393. lastName.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getLastName()));
  394. ssn.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getSsn()));
  395. currentCredit.setCellValueFactory(data -> new SimpleStringProperty("" + data.getValue().getCurrentCredit()));
  396. licenseNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getLicenseNumber()));
  397. licenseExpiration.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getLicenseExpirationDate().toString()));
  398. birthDate.setCellValueFactory(data -> new SimpleStringProperty("" + data.getValue().getBirthDate()));
  399. bloodType.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getBloodType()));
  400. email.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getEmail()));
  401. address.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getAddress()));
  402. passportNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getPassportNumber()));
  403. phoneNumber.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getPhoneNumber()));
  404. alternativePhone.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getAlternativeNumber()));
  405. country.setCellValueFactory(data -> {
  406. Country country = data.getValue().getCountry();
  407.  
  408. if (country != null) {
  409. return new SimpleStringProperty(country.getCountryName());
  410. }
  411.  
  412. return null;
  413. });
  414. customerTable.setItems(customerObservableList);
  415.  
  416. } catch (Exception e) {
  417. throw new RuntimeException(e);
  418. }
  419.  
  420. CarSearch();
  421. CustomerSearch();
  422.  
  423. //***** Section number __15__ customer sellection on mouse double click (this function inside initialize method) *****
  424. // for customer selection
  425. customerTable.setRowFactory(tv -> {
  426. TableRow<Customer> row = new TableRow<>();
  427. row.setOnMouseClicked(event -> {
  428. selectedCustomer = null;
  429. selectedCustomer = customerTable.getSelectionModel().getSelectedItem();
  430. if (event.getClickCount() == 2 && (!row.isEmpty())) {
  431.  
  432. driverNameLabel.setText(selectedCustomer.getFirstName() + " " + selectedCustomer.getMiddleName() + " " + selectedCustomer.getLastName());
  433. currentCreditLabel.setText("" + selectedCustomer.getCurrentCredit());
  434. expirationLabel.setText("" + selectedCustomer.getLicenseExpirationDate());
  435. customerPhoneNumberLabel.setText("" + selectedCustomer.getPhoneNumber());
  436. // TODO fix it
  437. //customerCurrentCreditLabel.setText(""+selectedCustomer.getCurrentCredit());
  438. carRadio.setDisable(false);
  439. customerSearch.setText(selectedCustomer.getFirstName() + " " + selectedCustomer.getMiddleName() + " " + selectedCustomer.getLastName());
  440. }
  441. });
  442.  
  443. return row;
  444. });
  445.  
  446. //***** Section number __16__ Car sellection on mouse double click (this function inside initialize method) *****
  447. // for car selection
  448. carTable.setRowFactory(tv -> {
  449. TableRow<Car> row = new TableRow<>();
  450. row.setOnMouseClicked(event -> {
  451. selectedCar = null;
  452. selectedCar = carTable.getSelectionModel().getSelectedItem();
  453. if (event.getClickCount() == 2 && (!row.isEmpty())) {
  454. try {
  455. modelLabel.setText(selectedCar.getModel().getCarModel().getModelName());
  456. subModelLabel.setText(selectedCar.getModel().getSubModelType());
  457. plateLabel.setText(selectedCar.getPlateNumber());
  458. } catch (Exception e) {
  459. throw new RuntimeException(e);
  460. }
  461. carSearch.setText(selectedCar.getPlateNumber() + " " + selectedCar.getModel().getCarModel().getModelName());
  462. halfPane.setDisable(false);
  463. rentBtn.setDisable(false);
  464. addSecondDriverButton.setVisible(true);
  465. currentMileageField.setText("" + selectedCar.getCarMileage());
  466. }
  467. });
  468. return row;
  469. });
  470.  
  471. //***** Section number __17__ fill All combo boxes (this function inside initialize method) *****
  472. ObservableList<String> Fueloptions =
  473. FXCollections.observableArrayList(
  474. "0",
  475. "25",
  476. "50",
  477. "75",
  478. "100"
  479. );
  480. currentFuelField.getItems().clear();
  481. currentFuelField.setItems(Fueloptions);
  482.  
  483.  
  484. ObservableList<String> paymentOptions =
  485. FXCollections.observableArrayList(
  486. "cash",
  487. "visa",
  488. "cheque"
  489. );
  490. paymentCombo.getItems().clear();
  491. paymentCombo.setItems(paymentOptions);
  492.  
  493.  
  494. taxCombo.getItems().clear();
  495. List<Tax> ta = ConnectionUtil.getEntityManager().createQuery("select t from Tax t ", Tax.class).getResultList();
  496. for (Tax t : ta) {
  497. taxCombo.getItems().add(t.getTaxValue());
  498. }
  499.  
  500. openingCombo.getItems().clear();
  501. closingCombo.getItems().clear();
  502. List<Branch> branches = ConnectionUtil.getEntityManager().createQuery(" select b from Branch b ", Branch.class).getResultList();
  503. for (Branch b : branches) {
  504. openingCombo.getItems().add(b.getBranchCity());
  505. closingCombo.getItems().add(b.getBranchCity());
  506. }
  507.  
  508. //TODO abu salah >>> try to make search field inside the comboBoxes
  509. secondDriverNationality.getItems().clear();
  510. secondDriverLicenceCountry.getItems().clear();
  511. List<Country> countryList = ConnectionUtil.getEntityManager().createQuery(" select c from Country c ", Country.class).getResultList();
  512. for (Country country1 : countryList) {
  513. secondDriverNationality.getItems().add(country1.getCountryName());
  514. secondDriverLicenceCountry.getItems().add(country1.getCountryName());
  515. }
  516.  
  517.  
  518. //***** Section number __18__ calculate all calculation of rent (this function inside initialize method) *****
  519. depositField.textProperty().addListener((obs, oldText, newText) -> {
  520. b = ((Integer.parseInt(totalDurationLabel.getText()) * (Double.parseDouble(pricePerDayField.getText()))) + (Integer.parseInt(totalExtraDaysLabel.getText()) * (Double.parseDouble(pricePerDayField.getText()))));
  521. double tx = Double.parseDouble(taxCombo.getSelectionModel().getSelectedItem().toString()) * b;
  522. total = b ;
  523. finalPriceLabel.setText(total + " JD");
  524. String taxFormat = String.format("%.3f", tx);
  525. taxLabel.setText(taxFormat + " JD");
  526.  
  527. String downPayment = downPaymentField.getText();
  528.  
  529. double downPaymentValue = !StringUtils.isEmpty(downPayment) ? Double.parseDouble(downPayment) : 0;
  530.  
  531. if (selectedCustomer.getCurrentCredit() != 0) {
  532. remaining = total - downPaymentValue - selectedCustomer.getCurrentCredit();
  533. } else {
  534. remaining = total - downPaymentValue;
  535. }
  536. priceLabel.setText((b-tx) + " JD");
  537. remainingAmountLabel.setText(remaining + " JD");
  538. });
  539.  
  540.  
  541. //***** Section number __19__ Dates validation Controller (this function inside initialize method) *****
  542. startDate.valueProperty().addListener((ov, oldValue, newValue) -> {
  543. startWithNullEnd();
  544. });
  545.  
  546. endDate.valueProperty().addListener((ov, oldValue, newValue) -> {
  547. startWithNotNullEnd();
  548. });
  549.  
  550. pricePerDayField.textProperty().addListener((ov, oldText, newText) -> {
  551. depositField.setText("0");
  552. priceLabel.setText("0");
  553. taxLabel.setText("0");
  554. finalPriceLabel.setText("0");
  555. remainingAmountLabel.setText("0");
  556. });
  557.  
  558.  
  559. downPaymentField.textProperty().addListener((ov, oldText, newText) -> {
  560. depositField.setText("0");
  561. priceLabel.setText("0");
  562. taxLabel.setText("0");
  563. finalPriceLabel.setText("0");
  564. remainingAmountLabel.setText("0");
  565. });
  566.  
  567. }
  568.  
  569.  
  570. //***** Section number __20__ Add second driver Controller *****
  571. public void addSecondDriver(ActionEvent event) {
  572. if (SecondDriverName.getText().isEmpty() || (!checkString(SecondDriverName.getText()))) {
  573. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  574. new InfoMessage("Empty Field", "Please insert second driver first name").show();
  575. } else {
  576. new InfoMessage("حقل فارغ", "الرجاء إدخال الإسم الأول للسائق الثاني").show();
  577. }
  578. } else if (secondDriverMiddleName.getText().isEmpty() || (!checkString(secondDriverMiddleName.getText()))) {
  579. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  580. new InfoMessage("Empty Field", "Please insert second driver middle name").show();
  581. } else {
  582. new InfoMessage("حقل فارغ", "الرجاء إدخال الإسم الأوسط للسائق الثاني").show();
  583. }
  584. } else if (secondDriverLastName.getText().isEmpty() || (!checkString(secondDriverLastName.getText()))) {
  585. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  586. new InfoMessage("Empty Field", "Please insert second driver last name").show();
  587. } else {
  588. new InfoMessage("حقل فارغ", "الرجاء إدخال الإسم الأخير للسائق الثاني").show();
  589. }
  590. } else if (secondDriverPhone.getText().isEmpty()) {
  591. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  592. new InfoMessage("Empty Field", "Please insert second driver phone number").show();
  593. } else {
  594. new InfoMessage("حقل فارغ", "الرجاء إدخال رقم الهاتف للسائق الثاني").show();
  595. }
  596.  
  597.  
  598. } else if (secondDriverLicenceNumber.getText().isEmpty()) {
  599. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  600. new InfoMessage("Empty Field", "Please insert second driver licence number").show();
  601. } else {
  602. new InfoMessage("حقل فارغ", "الرجاء إدخال رقم الرخصة للسائق الثاني").show();
  603. }
  604.  
  605. } else if (secondDriverSsnPass.getText().isEmpty()) {
  606. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  607. new InfoMessage("Empty Field", "Please insert second driver SSN or Passport number").show();
  608. } else {
  609. new InfoMessage("حقل فارغ", "الرجاء إدخال الرقم الوطني أو رقم جواز السفر للسائق الثاني").show();
  610. }
  611.  
  612. } else if (secondDriverNationality.getSelectionModel().getSelectedItem() == null) {
  613. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  614. new InfoMessage("Empty Field", "Please select second driver nationality").show();
  615. } else {
  616. new InfoMessage("حقل فارغ", "الرجاء إدخال الجنسية للسائق الثاني").show();
  617. }
  618. } else if (secondDriverLicenceCountry.getSelectionModel().getSelectedItem() == null) {
  619. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  620. new InfoMessage("Empty Field", "Please select second driver licence country").show();
  621. } else {
  622. new InfoMessage("حقل فارغ", "الرجاء إدخال مكان إصدار الرخصة للسائق الثاني").show();
  623. }
  624.  
  625. } else if (secondDriverLicenceExpiration.getValue() == null) {
  626. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  627. new InfoMessage("Empty Field", "Please select second driver licence expiration date").show();
  628. } else {
  629. new InfoMessage("حقل فارغ", "الرجاء إدخال تاريخ إنتهاء الرخصة للسائق الثاني").show();
  630. }
  631. } else {
  632. secondDiverPane.setVisible(false);
  633. searchPane.setVisible(true);
  634. customerScroll.setDisable(false);
  635. customerSearch.setDisable(false);
  636. customerRadio.setDisable(false);
  637. customerScroll.setVisible(false);
  638.  
  639. // secondDriverMiddleNameLabel.setText("" + secondDriverMiddleName.getText());
  640. // secondDriverLastNameLabel.setText("" + secondDriverLastName.getText());
  641. secondDriverNameLabel.setText(SecondDriverName.getText() + " " + secondDriverMiddleName.getText() + " " + secondDriverLastName.getText());
  642. secondDriverExpirationLabel.setText(secondDriverLicenceExpiration.getValue() + "");
  643. secondDriverPhoneLabel.setText(secondDriverPhone.getText());
  644. }
  645.  
  646. if (selectedCustomer.getCurrentCredit() > Double.parseDouble(finalPriceLabel.getText())) {
  647. remainingCustomerCredit = selectedCustomer.getCurrentCredit() - Double.parseDouble(finalPriceLabel.getText());
  648. } else {
  649. remainingCustomerCredit = 0;
  650. }
  651.  
  652. }
  653.  
  654.  
  655. //***** Section number __21__ Start Date validation *****
  656. public void startWithNullEnd() {
  657.  
  658. today = Date.valueOf(LocalDate.now()).getTime();
  659. start = Date.valueOf(startDate.getValue()).getTime();
  660.  
  661. tomorrow = today + 86400000;
  662. if (((endDate.getValue() != null && start < today) || (endDate.getValue() != null && start > tomorrow) || (endDate.getValue() != null && start > end))) {
  663. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  664. new InfoMessage("Invalid Date", "please select Start Date between today and tomorrow and not after end date").show();
  665. } else {
  666. new InfoMessage("تاريخ غير صالح", "يرجى تحديد تاريخ البدء بين اليوم وغدا وليس بعد تاريخ الانتهاء").show();
  667. }
  668.  
  669. } else if ((endDate.getValue() == null && start < today) || (endDate.getValue() == null && start > tomorrow)) {
  670. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  671. new InfoMessage("Invalid Date", "please select Start Date between today and tomorrow").show();
  672. } else {
  673. new InfoMessage("تاريخ غير صالح", "يرجى تحديد تاريخ البدء بين اليوم وغدا").show();
  674. }
  675.  
  676. } else if ((endDate.getValue() == null && start == today) || (endDate.getValue() == null && start == tomorrow)) {
  677. difference = 0L;
  678. totalDurationLabel.setText("" + difference);
  679. startDate.setDisable(true);
  680. endDate.setDisable(false);
  681. } else {
  682.  
  683. difference = (start - end) / (-60 * 60 * 24 * 1000);
  684. totalDurationLabel.setText("" + difference);
  685. startDate.setDisable(true);
  686. endDate.setDisable(false);
  687.  
  688. return;
  689. }
  690. }
  691.  
  692.  
  693. public void switchMileage(ActionEvent event) {
  694. if (unlimitedBtn.isSelected()) {
  695. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  696. allowedMileageField.setVisible(false);
  697. unlimitedBtn.setText("Allowed mileage");
  698. } else {
  699. allowedMileageField.setVisible(false);
  700. unlimitedBtn.setText("تحديد مسافة");
  701. }
  702. }
  703. else {
  704.  
  705. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  706.  
  707. unlimitedBtn.setText("Unlimited mileage");
  708. allowedMileageField.setVisible(true);
  709.  
  710. } else {
  711. allowedMileageField.setVisible(true);
  712. unlimitedBtn.setText("مسافة غير محدودة");
  713. }
  714. }
  715. }
  716.  
  717.  
  718.  
  719. //***** Section number __22__ End Dates validation Controller *****
  720. public void startWithNotNullEnd() {
  721. today = Date.valueOf(LocalDate.now()).getTime();
  722. String a = startDate.getValue().toString();
  723. String e = endDate.getValue().toString();
  724. start = Date.valueOf(startDate.getValue()).getTime();
  725. tomorrow = today + 86400000;
  726. end = Date.valueOf(endDate.getValue()).getTime();
  727.  
  728. if (end < start) {
  729. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  730. new InfoMessage("Invalid Date", "Please select END DATE not before start date").show();
  731.  
  732. } else {
  733. new InfoMessage("تاريخ غير صالح", "يرجى تحديد تاريخ الانتهاء بعد تاريخ البدء").show();
  734.  
  735. }
  736.  
  737. } else {
  738. difference = (start - end) / (-60 * 60 * 24 * 1000);
  739. totalDurationLabel.setText("" + difference);
  740. if (difference < 0) {
  741. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  742. new InfoMessage("Invalid Date", "please correct end date selection it is cannot be before start date").show();
  743. } else {
  744. new InfoMessage("تاريخ غير صالح", "يرجى تصحيح اختيار تاريخ الانتهاء ، فلا يمكن أن يكون قبل تاريخ البدء").show();
  745. }
  746.  
  747. startDate.setDisable(false);
  748. endDate.setDisable(true);
  749. } else {
  750. startDate.setDisable(false);
  751. endDate.setDisable(true);
  752. }
  753. }
  754. return;
  755. }
  756.  
  757.  
  758. //***** Section number __23__ checking lowest half fields if is empty and show alert box *****
  759. public void checkDeposit(MouseEvent event) {
  760. //TODO handel it on 'tab' key
  761.  
  762. if (startDate.getValue() == null) {
  763. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  764. new InfoMessage("Start Date", "Please select Start Date").show();
  765. } else {
  766. new InfoMessage("تاريخ البدء", "يرجى اختيار تاريخ البدء").show();
  767. }
  768.  
  769.  
  770. } else if (endDate.getValue() == null) {
  771. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  772. new InfoMessage("End Date", "Please Select End Date").show();
  773. } else {
  774. new InfoMessage("تاريخ الإنتهاء", "يرجى اختيار تاريخ الإنتهاء").show();
  775. }
  776.  
  777.  
  778. } else if (paymentCombo.getSelectionModel().getSelectedItem() == null) {
  779. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  780. new InfoMessage("Payment Method", "Please insert Payment Method").show();
  781. } else {
  782. new InfoMessage("طريقة الدفع", "الرجاء ادخال طريقة دفع").show();
  783. }
  784.  
  785. } else if (taxCombo.getSelectionModel().getSelectedItem() == null) {
  786. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  787. new InfoMessage("Tax Type", "Please insert Tax").show();
  788. } else {
  789. new InfoMessage("نوع الضريبة", "الرجاء إدخال نوع الضريبة").show();
  790. }
  791.  
  792.  
  793. } else if (pricePerDayField.getText().isEmpty()) {
  794. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  795. new InfoMessage("Price Per Day", "Please insert Price Per Day").show();
  796. } else {
  797. new InfoMessage("السعر ليوم واحد", "الرجاء ادخال السعر ليوم").show();
  798. }
  799.  
  800.  
  801. } else if (downPaymentField.getText().isEmpty()) {
  802. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  803. new InfoMessage("Down Payment", "Please insert Down Payment value").show();
  804. } else {
  805. new InfoMessage("الدفعة الأولى", "الرجاء إدخال قيمة الدفعة الأولى").show();
  806. }
  807.  
  808.  
  809. }
  810. }
  811.  
  812.  
  813. //***** Section number __24__ rent controller *****
  814. public void rent(ActionEvent event) {
  815.  
  816. if (selectedCar == null) {
  817. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  818. new InfoMessage("Car Selection", "Please select Car from Table view").show();
  819. } else {
  820. new InfoMessage("اختيار السيارة", "يرجى اختيار سيارة من جدول عرص السيارات").show();
  821. }
  822.  
  823. } else if (selectedCustomer == null) {
  824. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  825. new InfoMessage("Customer Selection", "Please select Customer from Table view").show();
  826. } else {
  827. new InfoMessage("اختيار العميل", "يرجى اختيار عميل من جدول عرص العملاء").show();
  828. }
  829.  
  830. } else if (depositField.getText().isEmpty()) {
  831. // TODO cheack about if the value == 0
  832. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  833. new InfoMessage("Deposit ", "Please insert Deposit Value").show();
  834. } else {
  835. new InfoMessage("التأمين ", "الرجاء إدخال قيمة التأمين").show();
  836. }
  837.  
  838. } else if (allowedMileageField.getText().isEmpty() && !unlimitedBtn.isSelected()) {
  839. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  840. new InfoMessage("Allowed Mileage", "Please insert Allowed Mileage").show();
  841. } else {
  842. new InfoMessage("المسافة المسحوح بها", "الرجاء إدخال عدد الكيلومترات المسموح بها").show();
  843. }
  844.  
  845. } else if (currentMileageField.getText().isEmpty()) {
  846. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  847. new InfoMessage("Current mileage", "Please insert Current Mileage").show();
  848. } else {
  849. new InfoMessage("القراءة الحالية لعداد المسافات", "الرجاء إدخال قراءة المسافة المقطوعة الحالية").show();
  850. }
  851.  
  852. } else if (currentFuelField.getSelectionModel().getSelectedItem() == null) {
  853. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  854. new InfoMessage("Curent Fuel", "Please insert Current Fuel").show();
  855. } else {
  856. new InfoMessage("كمية الوقود الحالية", "الرجاء إدخال كمية الوقود الحالية").show();
  857. }
  858.  
  859. } else if (closingCombo.getSelectionModel().getSelectedItem() == null) {
  860. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  861. new InfoMessage("Closing Branch", "Please select Closing Branch").show();
  862. } else {
  863. new InfoMessage("إلاق في فرع", "الرجاء إختيار الفرع الذي سيتم إغلاق العقد فيه").show();
  864. }
  865.  
  866.  
  867. } else if (openingCombo.getSelectionModel().getSelectedItem() == null) {
  868. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  869. new InfoMessage("Opening Branch", "Please select Opening Branch ").show();
  870. } else {
  871. new InfoMessage("فرع فتح العقد", "الرجاء إختيار الفرع المراد فتح العقد به").show();
  872. }
  873.  
  874. } else {
  875.  
  876. rentBtn.setDisable(true);
  877. OpenContract openContract = new OpenContract();
  878. ClientDriver clientDriver = new ClientDriver();
  879.  
  880.  
  881. openContract.setYear(Integer.parseInt(String.valueOf(startDate.getValue().getYear())));
  882. if (!unlimitedBtn.isSelected()) {
  883. openContract.setAllowedMileage(Double.parseDouble(allowedMileageField.getText()));
  884. }
  885. openContract.setContractState("Opened");
  886. openContract.setCurrentFuel(Integer.parseInt(currentFuelField.getSelectionModel().getSelectedItem().toString()));
  887. openContract.setCurrentMileage(Double.parseDouble(currentMileageField.getText()));
  888. openContract.setDepositValue(Double.parseDouble(depositField.getText()));
  889. openContract.setDownPayment(Double.parseDouble(downPaymentField.getText()));
  890. openContract.setExpectedEndDate(endDate.getValue());
  891. openContract.setPricePerDay(Double.parseDouble(pricePerDayField.getText()));
  892. openContract.setRemainingAmount(Double.parseDouble(remainingAmountLabel.getText().replace("JD", "")));
  893. openContract.setStartDate(startDate.getValue());
  894. openContract.setTotalDuration(Integer.parseInt(totalDurationLabel.getText()));
  895. openContract.setTotalExtraDays(Integer.parseInt(totalExtraDaysLabel.getText()));
  896. openContract.setTotalPrice(Double.parseDouble(finalPriceLabel.getText().replace("JD", "")));
  897.  
  898. openContract.setNotes(notesField.getText());
  899. openContract.setType("Individual");
  900. openContract.setTaxAmount(Double.parseDouble(taxLabel.getText().substring(0, taxLabel.getText().length() - 2)));
  901. openContract.setPrice(Double.parseDouble(priceLabel.getText().substring(0, priceLabel.getText().length() - 2)));
  902. openContract.setUserId(UserSession.getInstance().getUserId());
  903. openContract.setCar(selectedCar);
  904. openContract.setStartHour(DateUtil.getCurrentHour());
  905. openContract.setExpectedEndHour(DateUtil.getCurrentHour());
  906.  
  907. Car car = ConnectionUtil.getEntityManager().find(Car.class, selectedCar.getCarId());
  908. CarStatus carStatus = ConnectionUtil.getEntityManager().find(CarStatus.class, 2L);
  909. car.setCarStatus(carStatus);
  910. car.setCarMileage(Double.parseDouble(currentMileageField.getText()));
  911. car.setCurrentLoction(openingCombo.getSelectionModel().getSelectedItem());
  912.  
  913. TypedQuery<Branch> branchQuery = ConnectionUtil.getEntityManager().createQuery("select x from Branch x where x.branchCity = :v ", Branch.class);
  914.  
  915. Branch closedBranch = branchQuery.setParameter("v", closingCombo.getSelectionModel().getSelectedItem()).getSingleResult();
  916.  
  917. openContract.setClosedBranch(closedBranch);
  918.  
  919. Branch openedBranch = branchQuery.setParameter("v", openingCombo.getSelectionModel().getSelectedItem()).getSingleResult();
  920.  
  921. openContract.setOpenedBranch(openedBranch);
  922.  
  923. PaymentHistory paymentHistory = new PaymentHistory();
  924.  
  925.  
  926. paymentHistory.setPaymentTypeName(String.valueOf(paymentCombo.getSelectionModel().getSelectedItem()));
  927.  
  928. paymentHistory.setPaymentValue(Double.parseDouble(downPaymentField.getText()));
  929. paymentHistory.setContractPayment(openContract);
  930.  
  931. List<Tax> t = ConnectionUtil.getEntityManager().createQuery("select x from Tax x where x.taxValue = :v ", Tax.class).setParameter("v", taxCombo.getSelectionModel().getSelectedItem()).getResultList();
  932.  
  933. openContract.setTax(t.get(0));
  934.  
  935. List<Customer> customerList = new ArrayList<>();
  936. customerList.add(selectedCustomer);
  937.  
  938. openContract.setCustomerContract(selectedCustomer);
  939. selectedCustomer.setCurrentCredit(remainingCustomerCredit);
  940.  
  941. if (!(secondDriverNameLabel.getText().isEmpty())) {
  942. clientDriver.setFirstName(SecondDriverName.getText());
  943. clientDriver.setMiddleName(secondDriverMiddleName.getText());
  944. clientDriver.setLastName(secondDriverLastName.getText());
  945. clientDriver.setLicenseNumber(secondDriverLicenceNumber.getText());
  946. clientDriver.setPhoneNumber(secondDriverPhone.getText());
  947. clientDriver.setSsn(secondDriverSsnPass.getText());
  948.  
  949. TypedQuery<Country> countryQuery = ConnectionUtil.getEntityManager().createQuery(" select x from Country x where x.countryName = :v ", Country.class);
  950. Country secondDriverCountry = countryQuery.setParameter("v", secondDriverNationality.getSelectionModel().getSelectedItem()).getSingleResult();
  951. clientDriver.setCountry(secondDriverCountry);
  952.  
  953. Country secondLicenceCountry = countryQuery.setParameter("v", secondDriverLicenceCountry.getSelectionModel().getSelectedItem()).getSingleResult();
  954. clientDriver.setLicenseCountry(secondLicenceCountry);
  955.  
  956. clientDriver.setLicenseExpiration(Date.valueOf(secondDriverLicenceExpiration.getValue()));
  957.  
  958.  
  959. clientDriver.setOpenContract(openContract);
  960. clientDriver.setDriverOfCustomer(customerList);
  961. ConnectionUtil.getEntityManager().persist(clientDriver);
  962.  
  963. }
  964.  
  965.  
  966. List<PaymentHistory> paymentHistories = new ArrayList<>();
  967. paymentHistories.add(paymentHistory);
  968. openContract.setContractPaymentHistory(paymentHistories);
  969.  
  970. ConnectionUtil.getEntityManager().persist(openContract);
  971. ConnectionUtil.getEntityManager().persist(selectedCustomer);
  972. Actions actions = new Actions();
  973. actions.setActionDate(LocalDate.now().toString() + " " + LocalTime.now().toString());
  974. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  975. actions.setActionInfo("New OPEN CONTRACT added");
  976. } else {
  977. actions.setActionInfo(" تم فتح عقد جديد بنجاح");
  978. }
  979.  
  980. actions.setActionUser(UserSession.getInstance().getUsername());
  981. ConnectionUtil.getEntityManager().persist(actions);
  982. if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
  983. ConnectionUtil.getEntityManager().getTransaction().begin();
  984. }
  985. ConnectionUtil.getEntityManager().getTransaction().commit();
  986. ConnectionUtil.getEntityManager().refresh(openContract);
  987.  
  988.  
  989. customerRadio.setDisable(true);
  990. carRadio.setDisable(true);
  991. customerSearch.setDisable(true);
  992. carSearch.setDisable(true);
  993. startDate.setEditable(true);
  994. endDate.setEditable(true);
  995. paymentCombo.setEditable(true);
  996. taxCombo.setEditable(true);
  997. pricePerDayField.setDisable(true);
  998. downPaymentField.setDisable(true);
  999. depositField.setDisable(true);
  1000. allowedMileageField.setDisable(true);
  1001. currentMileageField.setDisable(true);
  1002. currentFuelField.setDisable(true);
  1003. closingCombo.setDisable(true);
  1004. openingCombo.setDisable(true);
  1005. if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
  1006. new InfoMessage("Done", "Congrats new OPEN CONTRACT added").show();
  1007. } else {
  1008. new InfoMessage("تمت العملية بنجاح", "مبروك تم فتح عقد جديد بنجاح").show();
  1009. }
  1010.  
  1011.  
  1012.  
  1013. OpenContract numb = ConnectionUtil.getEntityManager().createQuery("select o from OpenContract o where o.startDate = :a and o.expectedEndDate = :b and o.car = :c ",OpenContract.class).setParameter("a",startDate.getValue()).setParameter("b",endDate.getValue()).setParameter("c",selectedCar).getSingleResult();
  1014. long contNumb = numb.getOpenContractId();
  1015. CreatePdf createPdf = new CreatePdf(
  1016. // TODO create static contract number & issue place
  1017. contNumb,
  1018. selectedCustomer.getFirstName() + " " + selectedCustomer.getMiddleName() + " " + selectedCustomer.getLastName(),
  1019. selectedCustomer.getCountry().getCountryName() + "",
  1020. selectedCustomer.getBirthDate() + "",
  1021. selectedCustomer.getLicenseNumber() + "",
  1022. selectedCustomer.getLicenseCountry().getCountryName()+"",
  1023. selectedCustomer.getLicenseExpirationDate() + "",
  1024. (clientDriver.getFirstName()==null ? "-" : clientDriver.getFirstName()) + " " + (clientDriver.getMiddleName()==null ? "-" : clientDriver.getMiddleName()) + " " + (clientDriver.getLastName()==null ? "-" :clientDriver.getLastName()),
  1025. (clientDriver.getLicenseNumber()==null ? "-" : clientDriver.getLicenseNumber()) + "",
  1026. (clientDriver.getLicenseExpiration()==null ? "-" : clientDriver.getLicenseExpiration()) + "",
  1027. selectedCustomer.getPhoneNumber() + "",
  1028. selectedCustomer.getAddress() + "",
  1029. //selectedCar.getCarInsurance().getCarInsuranceType() + "",
  1030. selectedCar.getPlateNumber() + "",
  1031. selectedCar.getModel().getCarModel().getModelName() + "",
  1032. selectedCar.getModel().getSubModelType() + "",
  1033. selectedCar.getCarColor().getColorName() + "",
  1034. startDate.getValue().toString() + "",
  1035. endDate.getValue() + "",
  1036. DateUtil.getCurrentHour() + "",
  1037. currentMileageField.getText() + "",
  1038. endDate.getValue().toString() + "",
  1039. totalDurationLabel.getText() + "",
  1040. pricePerDayField.getText() + "",
  1041. depositField.getText() + "",
  1042. priceLabel.getText() + "",
  1043. taxLabel.getText() + "",
  1044. finalPriceLabel.getText() + "",
  1045. String.valueOf(remainingCustomerCredit + Double.parseDouble(downPaymentField.getText()))+ " JD",
  1046. remainingAmountLabel.getText() + "",
  1047. numb.getExpectedEndHour() + ""
  1048. );
  1049. try {
  1050. createPdf.printReport();
  1051. } catch (Exception ex) {
  1052. throw new RuntimeException(ex);
  1053. }
  1054.  
  1055. ConnectionUtil.getEntityManager().refresh(openContract);
  1056.  
  1057. // to close the scene
  1058. Stage stagePrev = (Stage) rentBtn.getScene().getWindow();
  1059. stagePrev.close();
  1060. }
  1061. }
  1062.  
  1063.  
  1064. public void showAddSecondDriver(ActionEvent event) {
  1065. searchPane.setVisible(false);
  1066. secondDiverPane.setVisible(true);
  1067. }
  1068.  
  1069.  
  1070. public void backToSearch(ActionEvent event) {
  1071. secondDiverPane.setVisible(false);
  1072. searchPane.setVisible(true);
  1073. customerScroll.setDisable(false);
  1074. customerSearch.setDisable(false);
  1075. customerRadio.setDisable(false);
  1076. customerScroll.setVisible(false);
  1077. }
  1078.  
  1079. private static boolean checkNumber(String emailStr) {
  1080. Matcher matcher = VALID_PHONE_NUMBER_REGEX.matcher(emailStr);
  1081. return matcher.find();
  1082. }
  1083.  
  1084. private static boolean checkString(String emailStr) {
  1085. Matcher matcher = VALID_STRING_REGEX.matcher(emailStr);
  1086. return matcher.find();
  1087. }
  1088. }
  1089.  
  1090. //TODO
  1091. // Date localDate = Date.valueOf(LocalDate.now());
  1092. // long x = ((localDate.getTime()) - (Date.valueOf(endDate.getValue()).getTime()) /(-60 * 60 * 24 * 1000));
  1093. // totalExtraDaysLabel.setText("");
  1094. //
  1095. //// if ((Date.valueOf(LocalDate.now()).getTime()) <= (Date.valueOf(endDate.getValue()).getTime()) ){
  1096. //// System.out.println("no");
  1097. //// }
  1098.  
  1099.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:39: error: class RentController is public, should be declared in a file named RentController.java
public class RentController implements Initializable {
       ^
Main.java:5: error: package constant does not exist
import constant.Language;
               ^
Main.java:6: error: package handler does not exist
import handler.CreatePdf;
              ^
Main.java:7: error: package handler does not exist
import handler.SceneHandler;
              ^
Main.java:8: error: package javafx.beans.property does not exist
import javafx.beans.property.SimpleStringProperty;
                            ^
Main.java:9: error: package javafx.collections does not exist
import javafx.collections.FXCollections;
                         ^
Main.java:10: error: package javafx.collections does not exist
import javafx.collections.ObservableList;
                         ^
Main.java:11: error: package javafx.collections.transformation does not exist
import javafx.collections.transformation.FilteredList;
                                        ^
Main.java:12: error: package javafx.collections.transformation does not exist
import javafx.collections.transformation.SortedList;
                                        ^
Main.java:13: error: package javafx.event does not exist
import javafx.event.ActionEvent;
                   ^
Main.java:14: error: package javafx.fxml does not exist
import javafx.fxml.FXML;
                  ^
Main.java:15: error: package javafx.fxml does not exist
import javafx.fxml.Initializable;
                  ^
Main.java:17: error: package javafx.scene.input does not exist
import javafx.scene.input.MouseEvent;
                         ^
Main.java:18: error: package javafx.scene.layout does not exist
import javafx.scene.layout.Pane;
                          ^
Main.java:19: error: package javafx.stage does not exist
import javafx.stage.Stage;
                   ^
Main.java:20: error: package message does not exist
import message.InfoMessage;
              ^
Main.java:21: error: package org.codehaus.plexus.util does not exist
import org.codehaus.plexus.util.StringUtils;
                               ^
Main.java:22: error: package security does not exist
import security.InterfaceLanguage;
               ^
Main.java:23: error: package security does not exist
import security.UserSession;
               ^
Main.java:24: error: package utility does not exist
import utility.ConnectionUtil;
              ^
Main.java:25: error: package utility does not exist
import utility.DateUtil;
              ^
Main.java:27: error: package javax.persistence does not exist
import javax.persistence.TypedQuery;
                        ^
Main.java:39: error: cannot find symbol
public class RentController implements Initializable {
                                       ^
  symbol: class Initializable
Main.java:70: error: cannot find symbol
    ScrollPane carScroll;
    ^
  symbol:   class ScrollPane
  location: class RentController
Main.java:72: error: cannot find symbol
    private TableView<Car> carTable;
            ^
  symbol:   class TableView
  location: class RentController
Main.java:72: error: cannot find symbol
    private TableView<Car> carTable;
                      ^
  symbol:   class Car
  location: class RentController
Main.java:74: error: cannot find symbol
    private TableColumn<Car, String> carPlateNumber, carYear, carOwnerName, carMileage, kiloMeters, carSize, carDoorsNumber, carChassisNumber, carLicenseExpirationDate, carExtraInfo, carModel, carState, carInsurance, carType, carColor, carEngineStatus, carEngineNumber;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:74: error: cannot find symbol
    private TableColumn<Car, String> carPlateNumber, carYear, carOwnerName, carMileage, kiloMeters, carSize, carDoorsNumber, carChassisNumber, carLicenseExpirationDate, carExtraInfo, carModel, carState, carInsurance, carType, carColor, carEngineStatus, carEngineNumber;
                        ^
  symbol:   class Car
  location: class RentController
Main.java:79: error: cannot find symbol
    ScrollPane customerScroll;
    ^
  symbol:   class ScrollPane
  location: class RentController
Main.java:81: error: cannot find symbol
    private TableView<Customer> customerTable;
            ^
  symbol:   class TableView
  location: class RentController
Main.java:81: error: cannot find symbol
    private TableView<Customer> customerTable;
                      ^
  symbol:   class Customer
  location: class RentController
Main.java:83: error: cannot find symbol
    private TableColumn<Customer, String> firstName;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:83: error: cannot find symbol
    private TableColumn<Customer, String> firstName;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:85: error: cannot find symbol
    private TableColumn<Customer, String> middleName;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:85: error: cannot find symbol
    private TableColumn<Customer, String> middleName;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:87: error: cannot find symbol
    private TableColumn<Customer, String> lastName;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:87: error: cannot find symbol
    private TableColumn<Customer, String> lastName;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:89: error: cannot find symbol
    private TableColumn<Customer, String> ssn;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:89: error: cannot find symbol
    private TableColumn<Customer, String> ssn;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:91: error: cannot find symbol
    private TableColumn<Customer, String> currentCredit;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:91: error: cannot find symbol
    private TableColumn<Customer, String> currentCredit;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:93: error: cannot find symbol
    private TableColumn<Customer, String> licenseNumber;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:93: error: cannot find symbol
    private TableColumn<Customer, String> licenseNumber;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:95: error: cannot find symbol
    private TableColumn<Customer, String> licenseExpiration;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:95: error: cannot find symbol
    private TableColumn<Customer, String> licenseExpiration;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:97: error: cannot find symbol
    private TableColumn<Customer, String> birthDate;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:97: error: cannot find symbol
    private TableColumn<Customer, String> birthDate;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:99: error: cannot find symbol
    private TableColumn<Customer, String> bloodType;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:99: error: cannot find symbol
    private TableColumn<Customer, String> bloodType;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:101: error: cannot find symbol
    private TableColumn<Customer, String> email;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:101: error: cannot find symbol
    private TableColumn<Customer, String> email;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:103: error: cannot find symbol
    private TableColumn<Customer, String> address;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:103: error: cannot find symbol
    private TableColumn<Customer, String> address;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:105: error: cannot find symbol
    private TableColumn<Customer, String> passportNumber;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:105: error: cannot find symbol
    private TableColumn<Customer, String> passportNumber;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:107: error: cannot find symbol
    private TableColumn<Customer, String> phoneNumber;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:107: error: cannot find symbol
    private TableColumn<Customer, String> phoneNumber;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:109: error: cannot find symbol
    private TableColumn<Customer, String> alternativePhone;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:109: error: cannot find symbol
    private TableColumn<Customer, String> alternativePhone;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:111: error: cannot find symbol
    private TableColumn<Customer, String> country;
            ^
  symbol:   class TableColumn
  location: class RentController
Main.java:111: error: cannot find symbol
    private TableColumn<Customer, String> country;
                        ^
  symbol:   class Customer
  location: class RentController
Main.java:118: error: cannot find symbol
    public JFXTextField carSearch;
           ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:120: error: cannot find symbol
    public JFXTextField customerSearch;
           ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:122: error: cannot find symbol
    JFXRadioButton customerRadio;
    ^
  symbol:   class JFXRadioButton
  location: class RentController
Main.java:124: error: cannot find symbol
    JFXRadioButton carRadio;
    ^
  symbol:   class JFXRadioButton
  location: class RentController
Main.java:126: error: cannot find symbol
    JFXButton addSecondDriverButton;
    ^
  symbol:   class JFXButton
  location: class RentController
Main.java:131: error: cannot find symbol
    public Pane halfPane;
           ^
  symbol:   class Pane
  location: class RentController
Main.java:133: error: cannot find symbol
    private Pane searchPane;
            ^
  symbol:   class Pane
  location: class RentController
Main.java:135: error: cannot find symbol
    public Label driverNameLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:137: error: cannot find symbol
    public Label currentCreditLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:139: error: cannot find symbol
    public Label expirationLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:141: error: cannot find symbol
    public Label subModelLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:143: error: cannot find symbol
    public Label plateLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:145: error: cannot find symbol
    public Label modelLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:147: error: cannot find symbol
    public Label customerPhoneNumberLabel;
           ^
  symbol:   class Label
  location: class RentController
Main.java:150: error: cannot find symbol
    private JFXButton rentBtn;
            ^
  symbol:   class JFXButton
  location: class RentController
Main.java:153: error: cannot find symbol
    private JFXComboBox<String> openingCombo;
            ^
  symbol:   class JFXComboBox
  location: class RentController
Main.java:155: error: cannot find symbol
    private JFXTextField downPaymentField;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:157: error: cannot find symbol
    private DatePicker startDate;
            ^
  symbol:   class DatePicker
  location: class RentController
Main.java:159: error: cannot find symbol
    private JFXComboBox<String> closingCombo;
            ^
  symbol:   class JFXComboBox
  location: class RentController
Main.java:161: error: cannot find symbol
    private JFXTextField depositField;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:163: error: cannot find symbol
    private JFXTextField currentMileageField;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:165: error: cannot find symbol
    private Label totalExtraDaysLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:167: error: cannot find symbol
    private DatePicker endDate;
            ^
  symbol:   class DatePicker
  location: class RentController
Main.java:170: error: cannot find symbol
    private Label totalDurationLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:172: error: cannot find symbol
    private JFXComboBox<String> paymentCombo;
            ^
  symbol:   class JFXComboBox
  location: class RentController
Main.java:174: error: cannot find symbol
    private JFXTextField pricePerDayField;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:176: error: cannot find symbol
    private Label finalPriceLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:178: error: cannot find symbol
    private Label taxLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:180: error: cannot find symbol
    private Label priceLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:182: error: cannot find symbol
    private JFXComboBox<Double> taxCombo;
            ^
  symbol:   class JFXComboBox
  location: class RentController
Main.java:184: error: cannot find symbol
    private JFXTextField allowedMileageField;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:186: error: cannot find symbol
    private JFXComboBox<String> currentFuelField;
            ^
  symbol:   class JFXComboBox
  location: class RentController
Main.java:188: error: cannot find symbol
    private Label remainingAmountLabel;
            ^
  symbol:   class Label
  location: class RentController
Main.java:190: error: cannot find symbol
    private JFXTextArea notesField;
            ^
  symbol:   class JFXTextArea
  location: class RentController
Main.java:195: error: cannot find symbol
    private Pane secondDiverPane;
            ^
  symbol:   class Pane
  location: class RentController
Main.java:197: error: cannot find symbol
    private JFXTextField SecondDriverName;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:199: error: cannot find symbol
    private JFXTextField secondDriverLicenceNumber;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:201: error: cannot find symbol
    private JFXTextField secondDriverSsnPass;
            ^
  symbol:   class JFXTextField
  location: class RentController
Main.java:203: error: cannot find symbol
    private JFXComboBox<String> secondDriverNationality;
            ^
  symbol:   class JFXComboBox
  location: class RentController
100 errors
stdout
Standard output is empty