diff --git a/src/main/java/info/bukova/isspst/data/TripBillItem.java b/src/main/java/info/bukova/isspst/data/TripBillItem.java index 577f01a6..062f6f31 100644 --- a/src/main/java/info/bukova/isspst/data/TripBillItem.java +++ b/src/main/java/info/bukova/isspst/data/TripBillItem.java @@ -2,15 +2,14 @@ package info.bukova.isspst.data; import info.bukova.isspst.Constants; -import java.math.BigDecimal; -import java.util.Date; - import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.Table; +import java.math.BigDecimal; +import java.util.Date; @Entity @Table(name = "TRIP_BILL_ITEMS") @@ -65,6 +64,35 @@ public class TripBillItem extends BaseData { @Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4) private BigDecimal adjustedTotal; + public TripBillItem() { + + } + + public TripBillItem(TripBillItem src) { + date = src.getDate(); + to = src.getTo(); + back = src.getBack(); + toDeparture = src.getToDeparture(); + toArrival = src.getToArrival(); + backDeparture = src.getBackDeparture(); + backArrival = src.getBackArrival(); + toVehicle = src.getToVehicle(); + backVehicle = src.getBackVehicle(); + beginWork = src.getBeginWork(); + endWork = src.getEndWork(); + freeMealsCount = src.getFreeMealsCount(); + distance = src.getDistance(); + fuelConsumption = src.getFuelConsumption(); + distanceAmount = src.getDistanceAmount(); + fuelAmount = src.getFuelAmount(); + carefare = src.getCarefare(); + housing = src.getHousing(); + meals = src.getMeals(); + otherExpenses = src.getOtherExpenses(); + total = src.getTotal(); + adjustedTotal = src.getAdjustedTotal(); + } + public Date getDate() { return date; } diff --git a/src/main/java/info/bukova/isspst/data/TripRequirement.java b/src/main/java/info/bukova/isspst/data/TripRequirement.java index 6339cbac..d10ab802 100644 --- a/src/main/java/info/bukova/isspst/data/TripRequirement.java +++ b/src/main/java/info/bukova/isspst/data/TripRequirement.java @@ -42,6 +42,8 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach @LazyCollection(LazyCollectionOption.TRUE) @IndexedEmbedded private List attachedFiles; + @Column(name = "BILL_FOR_PASSENGERS") + private Boolean billForPassengers; public TripRequirement() { this.setOwnedBy(new User()); @@ -140,4 +142,11 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach attachedFiles.remove(metainfo); } + public Boolean getBillForPassengers() { + return billForPassengers; + } + + public void setBillForPassengers(Boolean billForPassengers) { + this.billForPassengers = billForPassengers; + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java index 6071221b..1a2b4952 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -110,13 +110,15 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl implemen @Override @Transactional - @LazyLoader("print") + @LazyLoader({"print", "form"}) public void loadOwner(TripBill bill) { TripBill tb = dao.getById(bill.getId()); tb.getOwnedBy().getFirstName(); + tb.getRequirement().getOwnedBy().getFirstName(); bill.setOwnedBy(tb.getOwnedBy()); + bill.getRequirement().setOwnedBy(tb.getRequirement().getOwnedBy()); } @Override @@ -196,4 +198,31 @@ public class TripBillServiceImpl extends AbstractOwnedService implemen bill.getRequirement().setPassengers(tr.getPassengers()); } + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") + public void update(TripBill entity) { + super.update(entity); + + TripRequirement req = entity.getRequirement(); + Query q = dao.getQuery("from TripBill where requirement = :req and id != :id"); + q.setParameter("req", req); + q.setParameter("id", entity.getId()); + + List bills = q.list(); + for (TripBill tb : bills) { + tb.getBillItems().clear(); + + for (TripBillItem item : entity.getBillItems()) { + tb.getBillItems().add(new TripBillItem(item)); + } + + tb.setFreeCarfare(entity.isFreeCarfare()); + tb.setFreeHousing(entity.isFreeHousing()); + tb.setFreeMeals(entity.isFreeMeals()); + calculate(tb); + super.update(tb); + } + + } } diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java index fcfe8c75..91f4420b 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java @@ -38,4 +38,14 @@ public class TripBillForm extends FormWithUpload { return vehicles; } + public boolean isBillDisabled() { + if (getDataBean().getRequirement().getBillForPassengers() != null + && getDataBean().getRequirement().getBillForPassengers() + && !getDataBean().getOwnedBy().equals(getDataBean().getRequirement().getOwnedBy())) { + return true; + } + + return false; + } + } diff --git a/src/main/webapp/app/search/searchForm.zul b/src/main/webapp/app/search/searchForm.zul index bbeacd0c..c13bf717 100644 --- a/src/main/webapp/app/search/searchForm.zul +++ b/src/main/webapp/app/search/searchForm.zul @@ -16,7 +16,9 @@
- +
+ +
diff --git a/src/main/webapp/img/search-072.png b/src/main/webapp/img/search-072.png new file mode 100644 index 00000000..cd4c8b5c Binary files /dev/null and b/src/main/webapp/img/search-072.png differ diff --git a/src/main/webapp/main/trips/requirements/requirementsForm.zul b/src/main/webapp/main/trips/requirements/requirementsForm.zul index 0aaee1b2..62e03fc0 100644 --- a/src/main/webapp/main/trips/requirements/requirementsForm.zul +++ b/src/main/webapp/main/trips/requirements/requirementsForm.zul @@ -147,6 +147,9 @@ sclass="nicebutton" disabled="@load(vm.selUser eq null)"/> + diff --git a/src/main/webapp/main/trips/requirements/tripBill.zul b/src/main/webapp/main/trips/requirements/tripBill.zul index 7fdaa8fd..1c35e63f 100644 --- a/src/main/webapp/main/trips/requirements/tripBill.zul +++ b/src/main/webapp/main/trips/requirements/tripBill.zul @@ -21,7 +21,7 @@ zclass="form-caption" label="${labels.TravelOrdersFormTitle}" /> - + diff --git a/src/main/webapp/main/trips/tripBillInterior.zul b/src/main/webapp/main/trips/tripBillInterior.zul index 07bf2c2a..50d1342a 100644 --- a/src/main/webapp/main/trips/tripBillInterior.zul +++ b/src/main/webapp/main/trips/tripBillInterior.zul @@ -56,21 +56,21 @@ + disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)" /> + disabled="@load(vm.billDisabled or disabled)" /> @@ -237,12 +237,12 @@ value="@load(each.to)" maxlength="@load(vm.lengthText)" sclass="grid-textbox-max-left" - readonly="${disabled}"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/>
+ disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)"> @@ -289,7 +289,7 @@ selectedItem="@bind(each.backVehicle)" width="67px" readonly="true" - disabled="${disabled}"> + disabled="@load(vm.billDisabled or disabled)"> @@ -300,12 +300,12 @@ width="68px" value="@bind(each.beginWork)" format="short" - disabled="${disabled}"/> + disabled="@load(vm.billDisabled or disabled)"/> + disabled="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> + readonly="@load(vm.billDisabled or disabled)"/> @@ -366,7 +366,7 @@ value="@bind(each.otherExpenses) @converter(vm.standardBigDecimalConverter)" maxlength="@load(vm.lengthText)" onChange="@command('calculate')" - readonly="${disabled}"/> + readonly="@load(vm.billDisabled or disabled)"/>