package controller;
import Entities.*;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXTextField;
import constant.Language;
import constant.RoleType;
import handler.SceneHandler;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import message.InfoMessage;
import security.InterfaceLanguage;
import security.UserSession;
import utility.ConnectionUtil;
import utility.DateUtil;
import java.io.IOException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Year;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
public class CloseContract implements Initializable {
@FXML
private JFXComboBox currentFuelCombo;
@FXML
private JFXTextField openContractField;
@FXML
private JFXTextField customerNameField;
@FXML
private JFXTextField customerSsnField;
@FXML
private JFXTextField carModelField;
@FXML
private JFXTextField carPlateNumberField;
@FXML
private JFXTextField startMileageField;
@FXML
private JFXTextField allowedMileageField;
@FXML
private JFXTextField startFuelField;
@FXML
private JFXTextField startHourField;
@FXML
private JFXTextField yearField;
@FXML
private JFXTextField priceDayField;
@FXML
private DatePicker startDatePicker;
@FXML
private DatePicker endDatePicker;
@FXML
private JFXTextField taxTypeField;
@FXML
private JFXTextField finalTaxField;
@FXML
private JFXTextField priceField;
@FXML
public JFXTextField finalPriceField;
@FXML
public JFXTextField remainingField;
@FXML
private JFXTextField notesField;
@FXML
private JFXTextField closeMileageField;
@FXML
private Label closeTotalDurationLabel
; @FXML
public JFXButton addPaymentBtn;
@FXML
public JFXButton closeContractBtn;
@FXML
private Label mileageDifferenceLabel
; @FXML
public Label totalPayment
; @FXML
private JFXTextField totalDurationField;
@FXML
private JFXButton unClosedContractBtn;
@FXML
private JFXButton viewPaymentBtn;
@FXML
private JFXButton carExchangeBtn;
@FXML
private JFXButton saveEditBtn;
@FXML
private JFXButton editBtn;
@FXML
private JFXTextField delayPriceField;
@FXML
private JFXButton addDelayCostBtn;
public OpenContract selected;
DisplayAllOpenedContract c;
static double finalTax;
static double price;
static double finalPrice;
static double remaining;
static double v;
static double diffHours;
static long differenceDays;
public static Car car1;
static long durationWithoutDelay;
static double extraCredit;
private static Date startDateForRemainingMethod
; private static Date endDateForRemainingMethod
; private static Date currentDateForRemainingMethod
;
private static java.
util.
Date d1
=null; private static java.
util.
Date d2
=null;
public static double remainForPayment;
@Override
editBtn.setDisable(false);
startDatePicker.setDisable(true);
endDatePicker.setDisable(true);
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
currentFuelCombo.getItems().clear();
currentFuelCombo.getItems().addAll("0","25","50","75","100");
selected=c.selectedOpenedContract;
openContractField.setText(selected.getOpenContractId().toString());
customerNameField.setText(selected.getCustomerContract().getFirstName() + " " + selected.getCustomerContract().getLastName());
customerSsnField.setText(selected.getCustomerContract().getSsn());
carModelField.setText(selected.getCar().getCarColor().getColorName() + " " + selected.getCar().getModel().getCarModel().getModelName() + " " + selected.getCar().getModel().getSubModelType());
carPlateNumberField.setText(selected.getCar().getPlateNumber());
startMileageField.
setText(String.
valueOf(selected.
getCurrentMileage())); allowedMileageField.
setText(String.
valueOf(selected.
getAllowedMileage())); startFuelField.
setText(String.
valueOf(selected.
getCurrentFuel())); startHourField.
setText(String.
valueOf(selected.
getStartHour())); yearField.
setText(String.
valueOf(selected.
getYear())); priceDayField.
setText(String.
valueOf(selected.
getPricePerDay())); startDatePicker.setValue(LocalDate.parse(selected.getStartDate().toString()));
endDatePicker.setValue(LocalDate.parse(selected.getExpectedEndDate().toString()));
taxTypeField.
setText(String.
valueOf(selected.
getTax().
getTaxValue())); notesField.setText(selected.getNotes());
// totalDurationField.setText(String.valueOf(selected.getTotalDuration()));
setTotalPayment();
setRemaining();
closeMileageField.textProperty().addListener((ov, oldText, newText) -> {
mileageDifferenceMethod();
});
if (!remainingField.
getText().
isEmpty() && Double.
parseDouble(remainingField.
getText()) > 0 ){ unClosedContractBtn.setDisable(false);
}
}
@FXML
if (delayPriceField == null) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("Empty Field", "please add A cost for Dialy price ").show();
} else {
new InfoMessage("حقل فارغ", "الرجاء إدخال السعر اليومي").show();
}
} else {
finalPrice
= Double.
parseDouble(finalPriceField.
getText()) + Double.
parseDouble(delayPriceField.
getText()); finalTax
= finalPrice
* Double.
parseDouble(taxTypeField.
getText()); price = finalPrice - finalTax;
remaining
= finalPrice
- Double.
parseDouble(totalPayment.
getText()); priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); remainingField.
setText(String.
valueOf(remaining
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); }
}
public void setFieldsOnEdit(){
Long durationafterEdition
= (java.
sql.
Date.
valueOf(selected.
getExpectedEndDate()).
getTime() - java.
sql.
Date.
valueOf(selected.
getStartDate()).
getTime()) / (60 * 60 * 24 * 1000);
if (durationafterEdition == 0) {
durationafterEdition = 1L;
}
double priDay
= Double.
parseDouble(priceDayField.
getText()); double taxx
= Double.
parseDouble(taxTypeField.
getText());
double pri = (durationafterEdition * priDay) - ((durationafterEdition * priDay) * taxx);
double finPri = pri + ((durationafterEdition * priDay) * taxx);
double remain = finPri - v;
totalDurationField.
setText(String.
valueOf(durationafterEdition
)); priceField.
setText(String.
valueOf(pri
)); finalTaxField.
setText(String.
valueOf(((durationafterEdition
* priDay
) * taxx
))); finalPriceField.
setText(String.
valueOf(finPri
)); remainingField.
setText(String.
valueOf(remain
));}
@FXML
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
saveEditBtn.setVisible(false);
editBtn.setVisible(true);
startDatePicker.setDisable(true);
endDatePicker.setDisable(true);
Tax tax;
tax
= ConnectionUtil.
getEntityManager().
createQuery("select t from Tax t where t.taxValue = :v ", Tax.
class).
setParameter("v",
Double.
parseDouble(taxTypeField.
getText())).
getSingleResult();
setFieldsOnEdit();
selected.
setPrice(Double.
parseDouble(priceField.
getText())); selected.
setTotalPrice(Double.
parseDouble(finalPriceField.
getText())); selected.
setTaxAmount(Double.
parseDouble(finalTaxField.
getText())); selected.
setRemainingAmount(Double.
parseDouble(remainingField.
getText())); selected.
setTotalDuration(Integer.
parseInt(totalDurationField.
getText())); selected.setStartDate(startDatePicker.getValue());
selected.setExpectedEndDate(endDatePicker.getValue());
selected.
setAllowedMileage(Double.
parseDouble(allowedMileageField.
getText())); selected.
setCurrentFuel(Integer.
parseInt(startFuelField.
getText())); selected.setTax(tax);
selected.setNotes(notesField.getText());
selected.
setPricePerDay(Double.
parseDouble(priceDayField.
getText())); ConnectionUtil.getEntityManager().merge(selected);
Actions actions = new Actions();
actions.setActionDate(LocalDate.now().toString() + " " + LocalTime.now().toString());
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
actions.setActionInfo("Contract Is Closed");
} else {
actions.setActionInfo("تم اغلاق عقد");
}
actions.setActionUser(UserSession.getInstance().getUsername());
ConnectionUtil.getEntityManager().persist(actions);
// ConnectionUtil.getEntityManager().refresh(selected);
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
ConnectionUtil.getEntityManager().getTransaction().commit();
startDatePicker.setEditable(false);
endDatePicker.setEditable(false);
allowedMileageField.setEditable(false);
startFuelField.setEditable(false);
taxTypeField.setEditable(false);
notesField.setEditable(false);
priceDayField.setEditable(false);
setFieldsOnEdit();
if (Double.
parseDouble(remainingField.
getText())> 0){ addPaymentBtn.setDisable(false);
}
}
@FXML
editBtn.setVisible(false);
saveEditBtn.setVisible(true);
startDatePicker.setEditable(true);
endDatePicker.setEditable(true);
allowedMileageField.setEditable(true);
startFuelField.setEditable(true);
taxTypeField.setEditable(true);
notesField.setEditable(true);
priceDayField.setEditable(true);
startDatePicker.setDisable(false);
endDatePicker.setDisable(false);
}
public void mileageDifferenceMethod() {
mileageDifferenceLabel.setText("");
double mileageDiff
=Double.
parseDouble(closeMileageField.
getText()) - selected.
getCurrentMileage(); mileageDifferenceLabel.
setText(String.
valueOf(mileageDiff
)); }
@FXML
remainForPayment
= Double.
parseDouble(remainingField.
getText()); FXMLLoader fxmlLoader;
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
fxmlLoader=new FXMLLoader(getClass().getResource("/views/EN/AddPayment.fxml"));
} else {
fxmlLoader=new FXMLLoader(getClass().getResource("/views/AR/AddPayment.fxml"));
}
Parent root1=(Parent) fxmlLoader.load();
Stage stage=new Stage();
stage.setScene(new Scene(root1));
AddPaymentController addProductControllerController=fxmlLoader.getController();
fxmlLoader.setController(addProductControllerController);
stage.showAndWait();
setTotalPayment();
if (delayPriceField.isVisible()){
remainingField.
setText(String.
valueOf(Double.
parseDouble(finalPriceField.
getText()) - Double.
parseDouble(totalPayment.
getText()))); if (Double.
parseDouble(remainingField.
getText()) <= 0 ){ // closeContractBtn.setDisable(false);
}
}
else {
setRemaining();
}
}
@FXML
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new SceneHandler("/views/EN/ViewPayments.fxml").Go();
} else {
new SceneHandler("/views/AR/ViewPayments.fxml").Go();
}
}
public void setTotalPayment() {
v
=(Double) ConnectionUtil.
getEntityManager().
createQuery("select sum(paymentValue) from PaymentHistory where contractPayment.openContractId = :v ").
setParameter("v", selected.
getOpenContractId()).
getSingleResult(); totalPayment.
setText(String.
valueOf(v
)); }
public void setRemaining()
{
if (!remainingField.
getText().
isEmpty() && (Double.
parseDouble(remainingField.
getText()) == 0 || Double.
parseDouble(remainingField.
getText()) < 0 ) ) { addPaymentBtn.setDisable(true);
closeContractBtn.setDisable(false);
}
else {
currentDateForRemainingMethod
= java.
sql.
Date.
valueOf(DateUtil.
getDate()); endDateForRemainingMethod
= java.
sql.
Date.
valueOf(selected.
getExpectedEndDate()); startDateForRemainingMethod
= java.
sql.
Date.
valueOf(selected.
getStartDate());
durationWithoutDelay = (endDateForRemainingMethod.getTime() - startDateForRemainingMethod.getTime()) / (60 * 60 * 24 * 1000);
differenceDays = (currentDateForRemainingMethod.getTime() - endDateForRemainingMethod.getTime()) / (60 * 60 * 24 * 1000);
try {
d1=format.parse(selected.getExpectedEndHour());
d2=format.parse(DateUtil.getCurrentHour());
//in milliseconds
long diff=d2.getTime() - d1.getTime();
diffHours=(diff / (60 * 60 * 1000) % 24);
// double diffMin = ((diff / (60 * 1000) % 60));
// System.out.println(diffHours);
}
if (differenceDays == 0) {
differenceDays = 1;
}
if ((currentDateForRemainingMethod.getTime()/ (60 * 60 * 24 * 1000)) > (endDateForRemainingMethod.getTime()/ (60 * 60 * 24 * 1000))) {
ifCurrentDateBiggerThanEndDate();
}
else if ((currentDateForRemainingMethod.getTime()/ (60 * 60 * 24 * 1000)) == (endDateForRemainingMethod.getTime()/ (60 * 60 * 24 * 1000))) {
ifCurrentDateEqualEndDate();
}
else {
ifCurrentDateLessThanEndDate();
}
}
if (!remainingField.
getText().
isEmpty() && (Double.
parseDouble(remainingField.
getText()) == 0 || Double.
parseDouble(remainingField.
getText()) < 0 ) ) { addPaymentBtn.setDisable(true);
closeContractBtn.setDisable(false);
}
}
@FXML
Customer customerr;
customerr= ConnectionUtil.getEntityManager().createQuery("select c from Customer c where c.customerId= :v", Customer.class).setParameter("v", selected.getCustomerContract().getCustomerId()).getSingleResult();
customerr.setBlocked(true);
ConnectionUtil.getEntityManager().merge(customerr);
Actions actions = new Actions();
actions.setActionDate(LocalDate.now().toString() + " " + LocalTime.now().toString());
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
actions.setActionInfo("Customer Has Been Added To BlackList");
} else {
actions.setActionInfo("تمت إضافة العميل إلى القائمة السوداء");
}
actions.setActionUser(UserSession.getInstance().getUsername());
ConnectionUtil.getEntityManager().persist(actions);
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
ConnectionUtil.getEntityManager().getTransaction().commit();
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("Done", "Customer added to blacklist ").show();
} else {
new InfoMessage("تمت العملية بنجاح", "تمت إضافة العميل إلى القائمة السوداء").show();
}
}
@FXML
// rearranged by yousef
if (currentFuelCombo.getSelectionModel().getSelectedItem() == null || closeMileageField.getText().isEmpty()) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "please insert current mileage and current fuel").show();
} else {
new InfoMessage("تحذير", "الرجاء إدخال المسافة المقطوعة الحالية و كمية الوقود الحالية").show();
}
} else {
if (Double.
parseDouble(remainingField.
getText()) > 0) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("Rejected Operation", "please check remaining and get payment from customer").show();
} else {
new InfoMessage("تم رفض العملية", "يرجى التحقق من البلغ المتبقي وتحصيل المبلغ المتبقي من العميل").show();
}
}
else if (Double.
parseDouble(remainingField.
getText()) <= 0) {
Long dur
= (java.
sql.
Date.
valueOf(DateUtil.
getDate()).
getTime() - java.
sql.
Date.
valueOf(selected.
getStartDate()).
getTime()) / (60 * 60 * 24 * 1000);
if (dur == 0) {
dur = 1L;
}
double priDay
= Double.
parseDouble(priceDayField.
getText()); double taxx
= Double.
parseDouble(taxTypeField.
getText());
double pri = (dur * priDay) - ((dur * priDay) * taxx);
double finPri = pri + ((dur * priDay) * taxx);
double remain = finPri - v;
try {
d11=format.parse(selected.getExpectedEndHour());
d22=format.parse(DateUtil.getCurrentHour());
//in milliseconds
long diff=d2.getTime() - d1.getTime();
diffHours=(diff / (60 * 60 * 1000) % 24);
// double diffMin = ((diff / (60 * 1000) % 60));
// System.out.println(diffHours);
}
if ((diffHours >= 2)&&(diffHours < 6)) {
double ext
= Double.
parseDouble(priceDayField.
getText())/2; if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour.... extra cost has been added tot total "+" : "+ext).show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... تمت اضافة تكلفة التاخير الى المجموع الكلي و التي قيمتها : "+ext).show();
}
totalDurationField.
setText(String.
valueOf(dur
)); priceField.
setText(String.
valueOf(pri
)); finalTaxField.
setText(String.
valueOf(((dur
* priDay
) * taxx
))); finalPriceField.
setText(String.
valueOf(finPri
+ ext
)); remainingField.
setText(String.
valueOf(remain
)); }
else if (diffHours >= 6) {
double extraOneDay
= Double.
parseDouble(priceDayField.
getText()); totalDurationField.
setText(String.
valueOf(dur
+ 1 )); priceField.
setText(String.
valueOf((pri
+ (extraOneDay
)) - (extraOneDay
* taxx
) )); finalTaxField.
setText(String.
valueOf((((dur
+1) * priDay
) * taxx
) )); finalPriceField.
setText(String.
valueOf(finPri
+ extraOneDay
)); remainingField.
setText(String.
valueOf(remain
+ extraOneDay
));
}
else {
totalDurationField.
setText(String.
valueOf(dur
)); priceField.
setText(String.
valueOf(pri
)); finalTaxField.
setText(String.
valueOf(((dur
* priDay
) * taxx
))); finalPriceField.
setText(String.
valueOf(finPri
)); remainingField.
setText(String.
valueOf(remain
)); }
ClosedContract closedContract = new ClosedContract();
Car car;
CarStatus carStatus;
List<Customer> customer;
selected.setContractState("Closed");
selected.
setPrice(Double.
parseDouble(priceField.
getText())); selected.
setTaxAmount(Double.
parseDouble(finalTaxField.
getText())); selected.
setRemainingAmount(Double.
parseDouble(remainingField.
getText())); selected.
setTotalPrice(Double.
parseDouble(finalPriceField.
getText())); selected.
setTotalDuration(Integer.
parseInt(totalDurationField.
getText()));
customer = ConnectionUtil.getEntityManager().createQuery("select c from Customer c where c.customerId=:v", Customer.class).setParameter("v", selected.getCustomerContract().getCustomerId()).getResultList();
if (Double.
parseDouble(remainingField.
getText()) == 0){ customer.get(0).setCurrentCredit(0.0);
}else if(Double.
parseDouble(remainingField.
getText()) < 0){ customer.
get(0).
setCurrentCredit(-1 * Double.
parseDouble(remainingField.
getText())); }
closedContract.setCarId(selected.getCar().getCarId());
closedContract.setContractYear(Year.now());
closedContract.
setCurrentFuel(Integer.
parseInt(currentFuelCombo.
getSelectionModel().
getSelectedItem().
toString())); closedContract.
setCurrentMileage(Double.
parseDouble(closeMileageField.
getText())); closedContract.setCustomerId(selected.getCustomerContract().getCustomerId());
closedContract.
setEndDate(java.
sql.
Date.
valueOf(LocalDate.
now())); closedContract.setRecievedEmployeeId(UserSession.getInstance().getUserId());
closedContract.
setTotalDuration(Integer.
parseInt(totalDurationField.
getText())); closedContract.setContractNumber(selected.getOpenContractId());
closedContract.setClosedHour(DateUtil.getCurrentHour());
closedContract.setOpenContract(selected);
closedContract.setStatus("Closed");
if (!ConnectionUtil.getEntityManager().getTransaction().isActive()) {
ConnectionUtil.getEntityManager().getTransaction().begin();
}
carStatus = ConnectionUtil.getEntityManager().createQuery("select c from CarStatus c where c.carStatusName= :sStatus", CarStatus.class).setParameter("sStatus", "Available").getSingleResult();
car = ConnectionUtil.getEntityManager().createQuery("select c from Car c where c.carId=:v", Car.class).setParameter("v", selected.getCar().getCarId()).getSingleResult();
car.setCarStatus(carStatus);
car.
setCarMileage(Double.
parseDouble(closeMileageField.
getText()));
car.setCurrentLoction(UserSession.getInstance().getBranch());
selected.setClosedContract(closedContract);
closedContract.setOpenContract(selected);
ConnectionUtil.getEntityManager().persist(closedContract);
ConnectionUtil.getEntityManager().merge(car);
ConnectionUtil.getEntityManager().merge(customer.get(0));
ConnectionUtil.getEntityManager().merge(selected);
Actions actions = new Actions();
actions.setActionDate(LocalDate.now().toString() + " " + LocalTime.now().toString());
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
actions.setActionInfo("Contract Closed Successfully");
} else {
actions.setActionInfo("تم إغلاق العقد بنجاح");
}
actions.setActionUser(UserSession.getInstance().getUsername());
ConnectionUtil.getEntityManager().persist(actions);
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
ConnectionUtil.getEntityManager().getTransaction().commit();
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("Success", "Contract Closed Successfully").show();
} else {
new InfoMessage("تمت العملية بنجاح", "تم إغلاق العقد بنجاح").show();
}
Stage stage = (Stage) closeContractBtn.getScene().getWindow();
stage.close();
if (Double.
parseDouble(remainingField.
getText()) < 0) { if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage
("Note",
"customer has credit from this contract " + "CREDIT VALUE :" + (-1 * Double.
parseDouble(remainingField.
getText()))).
show();
} else {
new InfoMessage
("ملاحظة",
"العميل لديه رصيد من هذا العقد " + "القيمة : " + (-1 * Double.
parseDouble(remainingField.
getText()))).
show(); }
}
}
}
}
@FXML
if ((closeMileageField.getText().isEmpty() || currentFuelCombo.getSelectionModel().getSelectedItem().toString().length()==0) ) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "please enter current mileage and fuel").show();
} else {
new InfoMessage("تحذير", "يرجى إدخال المسافة المقطوعة الحالية و كمية الوقود").show();
}
}
else {
FXMLLoader fxmlLoader;
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
fxmlLoader = new FXMLLoader(getClass().getResource("/views/EN/CarExchange.fxml"));
}else{
fxmlLoader = new FXMLLoader(getClass().getResource("/views/AR/CarExchange.fxml"));
}
Parent root1 = (Parent) fxmlLoader.load();
Stage stage = new Stage();
stage.setScene(new Scene(root1));
CarExchangeController exchangeController = fxmlLoader.getController();
fxmlLoader.setController(exchangeController);
stage.showAndWait();
if ((car1
!= null) && ((java.
sql.
Date.
valueOf(LocalDate.
now()).
getTime()) < java.
sql.
Date.
valueOf(endDatePicker.
getValue()).
getTime()) && (Double.
parseDouble(remainingField.
getText()) <= 0)) {
forCarExchangeIfNewCarExist_andCurrentDateLessTHanEndDate();
setCloseContract_UpdateOpenContract_UpdateCar_UpdateCustomer();
viewRent_WithCurrentCustomer_InfoAndCredit();
Stage stv = (Stage) closeContractBtn.getScene().getWindow();
stv.close();
} else {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "Balance Due take remaining and open new Contract").show();
} else {
new InfoMessage("تحذير", "يوجد مبلغ متبقي قم بتحصيله من العميل و اغلق العقد ثم قم بفتح عقد جديد").show();
}
}
}
}
@FXML
public void unCloseContractWithoutCarExchange
(ActionEvent event
) { if (currentFuelCombo.getSelectionModel().getSelectedItem() == null || closeMileageField.getText().isEmpty()){
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning","please insert current fuel and current mileage").show();
} else {
new InfoMessage("تحذير", "يرجى إدخال المسافة المقطوعة الحالية و كمية الوقود").show();
}
}
else
{
if (Double.
parseDouble(remainingField.
getText()) > 0) {
Car car;
Long dur
= (java.
sql.
Date.
valueOf(DateUtil.
getDate()).
getTime() - java.
sql.
Date.
valueOf(selected.
getStartDate()).
getTime()) / (60 * 60 * 24 * 1000);
if (dur == 0) {
dur = 1L;
}
double priDay
= Double.
parseDouble(priceDayField.
getText()); double taxx
= Double.
parseDouble(taxTypeField.
getText());
double pri = (dur * priDay) - ((dur * priDay) * taxx);
double finPri = pri + ((dur * priDay) * taxx);
double remain = selected.getRemainingAmount() + ( finPri - (v-selected.getDownPayment()));
try {
d11=format.parse(selected.getExpectedEndHour());
d22=format.parse(DateUtil.getCurrentHour());
//in milliseconds
long diff=d2.getTime() - d1.getTime();
diffHours=(diff / (60 * 60 * 1000) % 24);
// double diffMin = ((diff / (60 * 1000) % 60));
// System.out.println(diffHours);
}
if ((diffHours >= 2)&&(diffHours < 6)) {
double ext
= Double.
parseDouble(priceDayField.
getText())/2; if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour.... extra cost has been added tot total "+" : "+ext).show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... تمت اضافة تكلفة التاخير الى المجموع الكلي و التي قيمتها : "+ext).show();
}
totalDurationField.
setText(String.
valueOf(dur
)); priceField.
setText(String.
valueOf(pri
)); finalTaxField.
setText(String.
valueOf(((dur
* priDay
) * taxx
))); finalPriceField.
setText(String.
valueOf(finPri
+ + ext
)); remainingField.
setText(String.
valueOf(remain
)); }
else if (diffHours >= 6) {
double extraOneDay
= Double.
parseDouble(priceDayField.
getText()); totalDurationField.
setText(String.
valueOf(dur
+ 1 )); priceField.
setText(String.
valueOf((pri
+ (extraOneDay
)) - (extraOneDay
* taxx
) )); finalTaxField.
setText(String.
valueOf((((dur
+1) * priDay
) * taxx
) )); finalPriceField.
setText(String.
valueOf(finPri
+ extraOneDay
)); remainingField.
setText(String.
valueOf(remain
+ extraOneDay
));
}
else {
totalDurationField.
setText(String.
valueOf(dur
)); priceField.
setText(String.
valueOf(pri
)); finalTaxField.
setText(String.
valueOf(((dur
* priDay
) * taxx
))); finalPriceField.
setText(String.
valueOf(finPri
)); remainingField.
setText(String.
valueOf(remain
)); }
CarStatus carStatus = ConnectionUtil.getEntityManager().createQuery("select c from CarStatus c where c.carStatusName = :v",CarStatus.class).setParameter("v","Available").getSingleResult();
car = ConnectionUtil.getEntityManager().createQuery("select c from Car c where c.carId = :v",Car.class).setParameter("v",selected.getCar().getCarId()).getSingleResult();
car.setCurrentLoction(UserSession.getInstance().getBranch());
car.
setCarMileage(Double.
parseDouble(closeMileageField.
getText())); car.setCarStatus(carStatus);
selected.
setPrice(Double.
parseDouble(priceField.
getText())); selected.
setTotalPrice(Double.
parseDouble(finalPriceField.
getText())); selected.
setTaxAmount(Double.
parseDouble(finalTaxField.
getText())); selected.
setRemainingAmount(Double.
parseDouble(remainingField.
getText())); selected.setTotalDuration(dur.intValue());
selected.setStartDate(startDatePicker.getValue());
selected.setExpectedEndDate(LocalDate.parse(DateUtil.getDate()));
selected.
setAllowedMileage(Double.
parseDouble(allowedMileageField.
getText())); selected.
setCurrentFuel(Integer.
parseInt(startFuelField.
getText())); selected.setNotes(notesField.getText());
selected.
setPricePerDay(Double.
parseDouble(priceDayField.
getText()));
UnClosedContract unClosedContract = new UnClosedContract();
selected.setContractState("Unclosed");
unClosedContract.setOpenContract(selected);
unClosedContract.
setActualEndDate(new Date());
unClosedContract.
setUnclosedCurrentMileage(Double.
parseDouble(closeMileageField.
getText())); unClosedContract.
setUnclosedCurrentFuel(Integer.
parseInt(currentFuelCombo.
getSelectionModel().
getSelectedItem().
toString())); unClosedContract.setUnclosedYear(LocalDateTime.now().getYear());
unClosedContract.setOpenContract(selected);
unClosedContract.setStatus("Unclosed");
selected.setUnclosedOpenContract(unClosedContract);
ConnectionUtil.getEntityManager().merge(selected);
ConnectionUtil.getEntityManager().merge(car);
ConnectionUtil.getEntityManager().persist(unClosedContract);
}
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("done","Contract has been added to Unclosed Contract").show();
} else {
new InfoMessage("تمت العملية بنجاح","تم تحويل العقد الى العقود المغلقة على الذمم").show();
}
Stage stv = (Stage) closeContractBtn.getScene().getWindow();
stv.close();
}
}
public void ifCurrentDateBiggerThanEndDate() {
try {
d1=format.parse(selected.getStartHour());
d2=format.parse(DateUtil.getCurrentHour());
//in milliseconds
long diff=d2.getTime() - d1.getTime();
diffHours=(diff / (60 * 60 * 1000) % 24);
// double diffMin = ((diff / (60 * 1000) % 60));
// System.out.println(diffHours);
}
carExchangeBtn.setDisable(true);
if ((diffHours >= 2)&&(diffHours < 6)) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour....you can set new cost to final price").show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... يمكنك اضافة تكلفة التاخير الى المجموع الكلي ").show();
}
delayPriceField.setVisible(true);
addDelayCostBtn.setVisible(true);
price
= (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText()))) - (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText()));// price = (durationWithoutDelay + differenceDays) * Double.parseDouble(priceDayField.getText());
finalTax
=(selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalPrice = price + finalTax;
if (delayPriceField.getText().isEmpty()){
remaining
= selected.
getRemainingAmount() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) - (Double.
parseDouble(totalPayment.
getText())- selected.
getDownPayment()); }else {
remaining
= Double.
parseDouble(delayPriceField.
getText()) + selected.
getRemainingAmount() + (differenceDays
* Double.
parseDouble(priceDayField.
getText())) - (Double.
parseDouble(totalPayment.
getText()) - selected.
getDownPayment()); }
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
+ differenceDays
));
}
else if (diffHours >= 6) {
price
= (selected.
getPrice() + ((differenceDays
+1) *Double.
parseDouble(priceDayField.
getText()))) - (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalTax
=(selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalPrice = price + finalTax;
if (delayPriceField.getText().isEmpty()){
remaining
= selected.
getRemainingAmount() + ((differenceDays
+1) *Double.
parseDouble(priceDayField.
getText())) - (Double.
parseDouble(totalPayment.
getText())- selected.
getDownPayment()); }else {
remaining
= Double.
parseDouble(delayPriceField.
getText()) + selected.
getRemainingAmount() + ((differenceDays
+1) * Double.
parseDouble(priceDayField.
getText())) - (Double.
parseDouble(totalPayment.
getText()) - selected.
getDownPayment()); }
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
+ differenceDays
+ 1)); }
else {
price
= (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText()))) - (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end date ....final price and remaining updated ").show();
} else {
new InfoMessage("تحذير", "هناك تأخير في تاريخ الانتهاء .... تم تحديث السعر النهائي والسعر المتبقي ").show();
}
finalTax
= (selected.
getPrice() + (differenceDays
*Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalPrice = price + finalTax;
remaining
= selected.
getRemainingAmount() + ((differenceDays
+1) * Double.
parseDouble(priceDayField.
getText())) - (Double.
parseDouble(totalPayment.
getText()) - selected.
getDownPayment());
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
+ differenceDays
)); }
}
public void ifCurrentDateEqualEndDate(){
carExchangeBtn.setDisable(true);
if ((diffHours >= 2)&&(diffHours < 6)) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour....you can set new cost to final price").show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... يمكنك اضافة تكلفة التاخير الى المجموع الكلي ").show();
}
delayPriceField.setVisible(true);
addDelayCostBtn.setVisible(true);
price = selected.getPrice() ;
finalTax
= price
* Double.
parseDouble(taxTypeField.
getText()); finalPrice = price + finalTax;
if (delayPriceField.getText().isEmpty()){
remaining =selected.getRemainingAmount();
}else{
remaining
=selected.
getRemainingAmount()+Double.
parseDouble(delayPriceField.
getText()) - (Double.
parseDouble(totalPayment.
getText())-selected.
getDownPayment()) ; }
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
)); }
else if (diffHours >= 6) {
price
= (selected.
getPrice() + (Double.
parseDouble(priceDayField.
getText()))) - (selected.
getPrice() + (Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalTax
= (selected.
getPrice() + (Double.
parseDouble(priceDayField.
getText())) *Double.
parseDouble(taxTypeField.
getText())); finalPrice = price + finalTax;
remaining
= selected.
getRemainingAmount() +(Double.
parseDouble(priceDayField.
getText())) -(Double.
parseDouble(totalPayment.
getText())-selected.
getDownPayment()) ;
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
+1)); }
}
public void ifCurrentDateLessThanEndDate(){
carExchangeBtn.setDisable(false);
if ((diffHours >= 2)&&(diffHours < 6)) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour....you can set new cost to final price").show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... يمكنك اضافة تكلفة التاخير الى المجموع الكلي ").show();
}
delayPriceField.setVisible(true);
addDelayCostBtn.setVisible(true);
price
= ((durationWithoutDelay
) * Double.
parseDouble(priceDayField.
getText())) - (((durationWithoutDelay
) * Double.
parseDouble(priceDayField.
getText())) * Double.
parseDouble(taxTypeField.
getText())); finalTax
= (((durationWithoutDelay
) * Double.
parseDouble(priceDayField.
getText())) * Double.
parseDouble(taxTypeField.
getText())); finalPrice = (price + finalTax);
if (delayPriceField.getText().isEmpty()){
remaining
= finalPrice
- Double.
parseDouble(totalPayment.
getText()) ; }
else if (!delayPriceField.getText().isEmpty() ){
remaining
= finalPrice
+Double.
parseDouble(delayPriceField.
getText())- Double.
parseDouble(totalPayment.
getText()) ; }
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
)); }
else if (diffHours >= 6) {
price
= ((durationWithoutDelay
+ 1) * Double.
parseDouble(priceDayField.
getText())) - (((durationWithoutDelay
+1) * Double.
parseDouble(priceDayField.
getText())) * Double.
parseDouble(taxTypeField.
getText())); finalTax
= (((durationWithoutDelay
+1) * Double.
parseDouble(priceDayField.
getText())) * Double.
parseDouble(taxTypeField.
getText())); finalPrice = (price + finalTax);
remaining
= selected.
getRemainingAmount() - (finalPrice
- (Double.
parseDouble(totalPayment.
getText()) - selected.
getDownPayment()));
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); remainingField.
setText(String.
valueOf(remaining
)); totalDurationField.
setText(String.
valueOf(durationWithoutDelay
+ 1));
}
}
public void forCarExchangeIfNewCarExist_andCurrentDateLessTHanEndDate(){
currentDateForRemainingMethod
= new Date(); endDateForRemainingMethod
= java.
sql.
Date.
valueOf(selected.
getExpectedEndDate()); startDateForRemainingMethod
= java.
sql.
Date.
valueOf(selected.
getStartDate());
durationWithoutDelay = (endDateForRemainingMethod.getTime() - startDateForRemainingMethod.getTime()) / (60 * 60 * 24 * 1000);
// its not the same of the upper function its specialize for this method
differenceDays = (currentDateForRemainingMethod.getTime() - startDateForRemainingMethod.getTime()) / (60 * 60 * 24 * 1000);
try {
d1=format.parse(selected.getStartHour());
d2=format.parse(DateUtil.getCurrentHour());
//in milliseconds
long diff=d2.getTime() - d1.getTime();
diffHours=(diff / (60 * 60 * 1000) % 24);
// double diffMin = ((diff / (60 * 1000) % 60));
// System.out.println(diffHours);
}
if ((diffHours >= 2)&&(diffHours < 6)) {
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
new InfoMessage("warning", "there is delay in end hour....you can set new cost to final price").show();
} else {
new InfoMessage("تحذير", "هناك تأخير في ساعة الاستلام .... يمكنك اضافة تكلفة التاخير الى المجموع الكلي ").show();
}
delayPriceField.setVisible(true);
addDelayCostBtn.setVisible(true);
price
= ( differenceDays
* Double.
parseDouble(priceDayField.
getText())) - (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText())); finalTax
= (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText()));; finalPrice = price + finalTax ;
remaining
=selected.
getRemainingAmount() -( finalPrice
- (Double.
parseDouble(totalPayment.
getText())- selected.
getDownPayment()));
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); remainingField.
setText(String.
valueOf(remaining
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); totalDurationField.
setText(String.
valueOf( differenceDays
));
}else if (diffHours >= 6) {
price
= ( (differenceDays
+1) * Double.
parseDouble(priceDayField.
getText())) - (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText())); finalTax
= (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText()));; finalPrice = price + finalTax ;
remaining
=selected.
getRemainingAmount() -( finalPrice
- (Double.
parseDouble(totalPayment.
getText())- selected.
getDownPayment()));
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); remainingField.
setText(String.
valueOf(remaining
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); totalDurationField.
setText(String.
valueOf( differenceDays
+1));
}
else {
price
= ( differenceDays
* Double.
parseDouble(priceDayField.
getText())) - (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText())); finalTax
= (( differenceDays
* Double.
parseDouble(priceDayField.
getText()))*Double.
parseDouble(taxTypeField.
getText()));; finalPrice = price + finalTax ;
remaining
=selected.
getRemainingAmount() -( finalPrice
- (Double.
parseDouble(totalPayment.
getText())- selected.
getDownPayment()));
priceField.
setText(String.
valueOf(price
)); finalTaxField.
setText(String.
valueOf(finalTax
)); remainingField.
setText(String.
valueOf(remaining
)); finalPriceField.
setText(String.
valueOf(finalPrice
)); totalDurationField.
setText(String.
valueOf( differenceDays
)); }
if(Double.
parseDouble(remainingField.
getText()) < 0 ){ extraCredit
= -1 * Double.
parseDouble(remainingField.
getText()); }
else if (Double.
parseDouble(remainingField.
getText()) == 0) { extraCredit
= Double.
parseDouble(totalPayment.
getText()) - finalPrice
; }
}
public void setCloseContract_UpdateOpenContract_UpdateCar_UpdateCustomer(){
ClosedContract closedContract = new ClosedContract();
Car car;
CarStatus carStatus;
CarStatus carStatus1;
List<Customer> customer;
selected.setContractState("Closed");
selected.
setPrice(Double.
parseDouble(priceField.
getText())); selected.
setTaxAmount(Double.
parseDouble(finalTaxField.
getText())); selected.setRemainingAmount(remaining);
selected.
setTotalPrice(Double.
parseDouble(finalPriceField.
getText())); selected.
setTotalDuration(Integer.
parseInt(totalDurationField.
getText())); selected.setExpectedEndDate(LocalDate.parse(DateUtil.getDate()));
selected.setExpectedEndHour(DateUtil.getCurrentHour());
customer = ConnectionUtil.getEntityManager().createQuery("select c from Customer c where c.customerId=:v", Customer.class).setParameter("v", selected.getCustomerContract().getCustomerId()).getResultList();
customer.get(0).setCurrentCredit(extraCredit);
closedContract.setCarId(selected.getCar().getCarId());
closedContract.setContractYear(Year.now());
closedContract.
setCurrentFuel(Integer.
parseInt(currentFuelCombo.
getSelectionModel().
getSelectedItem().
toString())); closedContract.
setCurrentMileage(Double.
parseDouble(closeMileageField.
getText())); closedContract.setCustomerId(selected.getCustomerContract().getCustomerId());
closedContract.
setEndDate(java.
sql.
Date.
valueOf(LocalDate.
now())); closedContract.setRecievedEmployeeId(UserSession.getInstance().getUserId());
closedContract.
setTotalDuration(Integer.
parseInt(totalDurationField.
getText())); closedContract.setContractNumber(selected.getOpenContractId());
closedContract.setClosedHour(DateUtil.getCurrentHour());
closedContract.setOpenContract(selected);
closedContract.setStatus("Closed");
carStatus = ConnectionUtil.getEntityManager().createQuery("select c from CarStatus c where c.carStatusName='Available'", CarStatus.class).getSingleResult();
carStatus1 = ConnectionUtil.getEntityManager().createQuery("select c from CarStatus c where c.carStatusName='Rented'", CarStatus.class).getSingleResult();
car = ConnectionUtil.getEntityManager().createQuery("select c from Car c where c.carId=:v", Car.class).setParameter("v", selected.getCar().getCarId()).getSingleResult();
car.setCarStatus(carStatus);
car.setCurrentLoction(UserSession.getInstance().getBranch());
car1.setCarStatus(carStatus1);
car1.setCurrentLoction(UserSession.getInstance().getBranch());
selected.setClosedContract(closedContract);
closedContract.setOpenContract(selected);
ConnectionUtil.getEntityManager().persist(closedContract);
ConnectionUtil.getEntityManager().merge(car);
ConnectionUtil.getEntityManager().merge(car1);
ConnectionUtil.getEntityManager().merge(customer.get(0));
ConnectionUtil.getEntityManager().merge(selected);
if(!ConnectionUtil.getEntityManager().getTransaction().isActive()){
ConnectionUtil.getEntityManager().getTransaction().begin();
}
ConnectionUtil.getEntityManager().getTransaction().commit();
}
private void viewRent_WithCurrentCustomer_InfoAndCredit
() throws IOException { FXMLLoader fxmlLoaderr;
if (InterfaceLanguage.getInstance().getLanguage() == Language.ENGLISH) {
fxmlLoaderr = new FXMLLoader(getClass().getResource("/views/EN/Rent.fxml"));
}
else
{
fxmlLoaderr = new FXMLLoader(getClass().getResource("/views/AR/Rent.fxml"));
}
Parent root2 = (Parent) fxmlLoaderr.load();
Stage stagee = new Stage();
stagee.setScene(new Scene(root2));
RentController addProductRentController = fxmlLoaderr.getController();
addProductRentController.customerRadio.setDisable(true);
addProductRentController.customerSearch.setText(selected.getCustomerContract().getFirstName()+"" +selected.getCustomerContract().getMiddleName()+" "+selected.getCustomerContract().getLastName());
addProductRentController.customerSearch.setDisable(true);
addProductRentController.customerScroll.setDisable(true);
addProductRentController.carSearch.setDisable(true);
addProductRentController.carRadio.setDisable(true);
addProductRentController.carScroll.setDisable(true);
addProductRentController.addSecondDriverButton.setVisible(true);
addProductRentController.selectedCar = car1;
addProductRentController.selectedCustomer = selected.getCustomerContract();
addProductRentController.carSearch.setText(selected.getCar().getCarColor().getColorName()+" "+selected.getCar().getModel().getCarModel().getModelName()+" "+selected.getCar().getModel().getSubModelType());
addProductRentController.modelLabel.setText(addProductRentController.selectedCar.getModel().getCarModel().getModelName());
addProductRentController.subModelLabel.setText(addProductRentController.selectedCar.getModel().getSubModelType());
addProductRentController.plateLabel.setText(addProductRentController.selectedCar.getPlateNumber());
addProductRentController.driverNameLabel.setText(addProductRentController.selectedCustomer.getFirstName() + " "+ addProductRentController.selectedCustomer.getMiddleName() + " "+ addProductRentController.selectedCustomer.getLastName());
addProductRentController.currentCreditLabel.setText("" + addProductRentController.selectedCustomer.getCurrentCredit());
addProductRentController.expirationLabel.setText("" + addProductRentController.selectedCustomer.getLicenseExpirationDate());
addProductRentController.customerPhoneNumberLabel.setText("" + addProductRentController.selectedCustomer.getPhoneNumber());
addProductRentController.halfPane.setDisable(false);
fxmlLoaderr.setController(addProductRentController);
stagee.show();
}
}