diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index b802a111..1d17da2c 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -10,9 +10,9 @@ import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; -import info.bukova.isspst.services.fulltext.FullTextService; import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.buildings.BuildingService; +import info.bukova.isspst.services.fulltext.FullTextService; import info.bukova.isspst.services.invoicing.InvoicingService; import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.orders.ApprovedService; @@ -33,7 +33,7 @@ import java.util.Map; public class Constants { - public final static long DB_VERSION = 2; + public final static long DB_VERSION = 3; public final static String DEF_ADMIN = "admin"; public final static String DEF_ADMIN_PASSWD = "admin"; diff --git a/src/main/java/info/bukova/isspst/data/Invoicing.java b/src/main/java/info/bukova/isspst/data/Invoicing.java index 4256e389..f6d81b8c 100644 --- a/src/main/java/info/bukova/isspst/data/Invoicing.java +++ b/src/main/java/info/bukova/isspst/data/Invoicing.java @@ -17,7 +17,8 @@ import org.hibernate.annotations.LazyCollectionOption; @Entity @Table(name = "INVOICING") -public class Invoicing extends BaseData { +public class Invoicing extends BaseData implements Cloneable +{ @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumn(name = "REQUIREMENT_ID") @@ -31,6 +32,9 @@ public class Invoicing extends BaseData { @Column(name = "TOTAL_INVOICED", precision = 15, scale = 4) private BigDecimal totalInvoiced; + @Column(name = "COMPLETED") + private boolean completed; + public Requirement getRequirement() { return requirement; } @@ -55,4 +59,20 @@ public class Invoicing extends BaseData { this.totalInvoiced = totalInvoiced; } + public boolean isCompleted() + { + return completed; + } + + public void setCompleted(boolean completed) + { + this.completed = completed; + } + + @Override + public Object clone() throws CloneNotSupportedException + { + Invoicing cloned = (Invoicing) super.clone(); + return cloned; + } } diff --git a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java index 4203419a..60d74265 100644 --- a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java @@ -71,29 +71,29 @@ public class DbInfoServiceImpl extends AbstractService implements DbInfo { List tables = new ArrayList(); - tables.add(new Str2Str("address", "DESCRIPTION")); - tables.add(new Str2Str("building", "DESCRIPTION")); - tables.add(new Str2Str("material", "DESCRIPTION")); - tables.add(new Str2Str("munit", "DESCRIPTION")); - tables.add(new Str2Str("orders", "DESCRIPTION")); - tables.add(new Str2Str("order_item", "DESCRIPTION")); - tables.add(new Str2Str("permission", "DESCRIPTION")); - tables.add(new Str2Str("requirement", "DESCRIPTION")); - tables.add(new Str2Str("requirementtype", "DESCRIPTION")); - tables.add(new Str2Str("requirement_items", "DESCRIPTION")); - tables.add(new Str2Str("role", "DESCRIPTION")); - tables.add(new Str2Str("service", "DESCRIPTION")); - tables.add(new Str2Str("triprequirement", "DESCRIPTION")); - - tables.add(new Str2Str("material", "MUNIT_DESCRIPTION")); - tables.add(new Str2Str("orders", "INVOICE_DESCRIPTION")); - tables.add(new Str2Str("orders", "DELIVERY_DESCRIPTION")); - tables.add(new Str2Str("orders", "SUPPLIER_DESCRIPTION")); - tables.add(new Str2Str("order_item", "MUNIT_DESCRIPTION")); - tables.add(new Str2Str("requirement_items", "MUNIT_DESCRIPTION")); - tables.add(new Str2Str("triprequirement", "VEHICLE_DESCRIPTION")); - tables.add(new Str2Str("trip_bill_items", "BACK_VEHICLE_DESCRIPTION")); - tables.add(new Str2Str("trip_bill_items", "VEHICLE_DESCRIPTION")); + tables.add(new Str2Str("ADDRESS", "DESCRIPTION")); + tables.add(new Str2Str("BUILDING", "DESCRIPTION")); + tables.add(new Str2Str("MATERIAL", "DESCRIPTION")); + tables.add(new Str2Str("MUNIT", "DESCRIPTION")); + tables.add(new Str2Str("ORDERS", "DESCRIPTION")); + tables.add(new Str2Str("ORDER_ITEM", "DESCRIPTION")); + tables.add(new Str2Str("PERMISSION", "DESCRIPTION")); + tables.add(new Str2Str("REQUIREMENT", "DESCRIPTION")); + tables.add(new Str2Str("REQUIREMENTTYPE", "DESCRIPTION")); + tables.add(new Str2Str("REQUIREMENT_ITEMS", "DESCRIPTION")); + tables.add(new Str2Str("ROLE", "DESCRIPTION")); + tables.add(new Str2Str("SERVICE", "DESCRIPTION")); + tables.add(new Str2Str("TRIPREQUIREMENT", "DESCRIPTION")); + + tables.add(new Str2Str("MATERIAL", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("ORDERS", "INVOICE_DESCRIPTION")); + tables.add(new Str2Str("ORDERS", "DELIVERY_DESCRIPTION")); + tables.add(new Str2Str("ORDERS", "SUPPLIER_DESCRIPTION")); + tables.add(new Str2Str("ORDER_ITEM", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("REQUIREMENT_ITEMS", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("TRIPREQUIREMENT", "VEHICLE_DESCRIPTION")); + tables.add(new Str2Str("TRIP_BILL_ITEMS", "BACK_VEHICLE_DESCRIPTION")); + tables.add(new Str2Str("TRIP_BILL_ITEMS", "VEHICLE_DESCRIPTION")); for (Str2Str item : tables) { @@ -107,9 +107,9 @@ public class DbInfoServiceImpl extends AbstractService implements DbInfo { List tables = new ArrayList(); - tables.add("material"); - tables.add("order_item"); - tables.add("requirement_items"); + tables.add("MATERIAL"); + tables.add("ORDER_ITEM"); + tables.add("REQUIREMENT_ITEMS"); for (String item : tables) { @@ -119,6 +119,13 @@ public class DbInfoServiceImpl extends AbstractService implements DbInfo } } + if (dbVersion < 3) + { + sql = "UPDATE INVOICING SET COMPLETED = false WHERE (COMPLETED Is NULL) "; + sq = this.dao.getSession().createSQLQuery(sql); + sq.executeUpdate(); + } + this.updateDatabaseVersion(); } } diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java index d56dba55..84583cc9 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingService.java @@ -1,11 +1,12 @@ package info.bukova.isspst.services.invoicing; -import java.math.BigDecimal; - import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.services.Service; +import java.math.BigDecimal; +import java.util.List; + public interface InvoicingService extends Service { public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup); @@ -16,4 +17,7 @@ public interface InvoicingService extends Service { public void calculate(Invoicing invoicing); + public List getPendingList(); + + public List getArchiveList(); } diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index d7263af3..98124d3d 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -73,4 +73,23 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem invoice.getRequirement().setOwnedBy(inv.getRequirement().getOwnedBy()); } + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List getPendingList() + { + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) order by rq.numser"); + return q.list(); + } + + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List getArchiveList() + { + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where inv.completed = true order by rq.numser"); + return q.list(); + } } diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index 9d5d4be8..0b746112 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -258,7 +258,10 @@ public class ListViewModel extends DocumentViewModel } dataBean = editBean; if (!newRec && editBean != null) { - dataList.set(selIndex, editBean); + if (selIndex < dataList.size()) + { + dataList.set(selIndex, editBean); + } } BindUtils.postGlobalCommand(null, null, "reloadRelated", null); diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingArchiveList.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingArchiveList.java new file mode 100644 index 00000000..3b8eab20 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingArchiveList.java @@ -0,0 +1,33 @@ +package info.bukova.isspst.ui.main.invoicing; + +import info.bukova.isspst.data.Invoicing; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.annotation.Init; + +public class InvoicingArchiveList extends InvoicingList +{ + @Init(superclass = true) + public void initInvoicingArchiveList() + { + + } + + @Override + protected List getListFromService() + { + try + { + return invoicingService.getArchiveList(); + } + catch (AccessDeniedException e) + { + // BindUtils.postGlobalCommand(null, null, "disableCentre", null); + // e.printStackTrace(); + return new ArrayList(); + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java index 6d21a94f..763c0932 100644 --- a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingForm.java @@ -5,6 +5,9 @@ import info.bukova.isspst.data.InvoicingItem; import info.bukova.isspst.services.invoicing.InvoicingService; import info.bukova.isspst.ui.FormViewModel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; @@ -13,16 +16,46 @@ import org.zkoss.zk.ui.select.annotation.WireVariable; public class InvoicingForm extends FormViewModel { + public final static String TAG = InvoicingForm.class.getSimpleName(); + private final static Logger log = LoggerFactory.getLogger(InvoicingForm.class.getSimpleName()); + private InvoicingItem selectedItem; private int selectedIndex; @WireVariable private InvoicingService invoicingService; + protected Invoicing invoicingBeforeEdit; + @Init(superclass = true) - public void init() { + public void initInvoicingForm() + { selectedIndex = -1; + + try + { + this.invoicingBeforeEdit = (Invoicing) this.getDataBean().clone(); + } + catch (CloneNotSupportedException e) + { + log.error("Nelze provést hlubokou kopii fakturace!"); + e.printStackTrace(); + } } + @Override + protected void doSave() + { + // Zjisti, zda se změnil příznak Vyřízeno + boolean competedChanged = (this.invoicingBeforeEdit.isCompleted() != this.getDataBean().isCompleted()); + + super.doSave(); + + if (competedChanged) + { + BindUtils.postGlobalCommand(null, null, "refreshTabs", null); + } + } + private void selectItem(InvoicingItem item) { if (item != null) { selectedItem = item; @@ -77,4 +110,13 @@ public class InvoicingForm extends FormViewModel { this.selectedIndex = selectedIndex; } + public Invoicing getInvoicingBeforeEdit() + { + return invoicingBeforeEdit; + } + + public void setInvoicingBeforeEdit(Invoicing invoicingBeforeEdit) + { + this.invoicingBeforeEdit = invoicingBeforeEdit; + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java index 2de94126..3cef1248 100644 --- a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingList.java @@ -1,7 +1,5 @@ package info.bukova.isspst.ui.main.invoicing; -import java.util.List; - import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.User; import info.bukova.isspst.data.Workgroup; @@ -11,13 +9,17 @@ import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.ListViewModel; +import java.util.List; + +import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; public class InvoicingList extends ListViewModel { @WireVariable - private InvoicingService invoicingService; + protected InvoicingService invoicingService; @WireVariable private WorkgroupService workgroupService; @WireVariable @@ -53,4 +55,15 @@ public class InvoicingList extends ListViewModel { return userService.getUsersForCombo(); } + @GlobalCommand + @NotifyChange({ "dataList", "dataBean", "ableToDelete" }) + public void refreshTabs() + { + // Změnou hodnoty Vyřízeno se záznam přesunul do jiné záložky + // Aby se editovaný záznam nerefreshoval, protože tam už nebude, nastaví + // se na null + this.setEditBean(null); + // Provede přenačtení všech záložek + this.reload(); + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingPendingList.java b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingPendingList.java new file mode 100644 index 00000000..463e039b --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/main/invoicing/InvoicingPendingList.java @@ -0,0 +1,32 @@ +package info.bukova.isspst.ui.main.invoicing; + +import info.bukova.isspst.data.Invoicing; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.annotation.Init; + +public class InvoicingPendingList extends InvoicingList +{ + @Init(superclass = true) + public void initInvoicingPendingList() + { + } + + @Override + protected List getListFromService() + { + try + { + return invoicingService.getPendingList(); + } + catch (AccessDeniedException e) + { + // BindUtils.postGlobalCommand(null, null, "disableCentre", null); + // e.printStackTrace(); + return new ArrayList(); + } + } +} diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index ec72b795..33a75b22 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -386,3 +386,6 @@ ModuleNotActive=Modul není aktivovaný AgendaSearch=Vyhledávání Search=Hledat +Pending = Nevyřízené +Archive = Archiv +Completed = Vyřízeno diff --git a/src/main/webapp/main/invoicing/index.zul b/src/main/webapp/main/invoicing/index.zul index 6a397a7b..1b90f56d 100644 --- a/src/main/webapp/main/invoicing/index.zul +++ b/src/main/webapp/main/invoicing/index.zul @@ -2,7 +2,7 @@ - String gridZul = "invoicingGrid.zul"; + String gridZul = "setup.zul"; diff --git a/src/main/webapp/main/invoicing/invHeadListArchive.zul b/src/main/webapp/main/invoicing/invHeadListArchive.zul new file mode 100644 index 00000000..c520c9f1 --- /dev/null +++ b/src/main/webapp/main/invoicing/invHeadListArchive.zul @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/main/invoicing/invHeadListPending.zul b/src/main/webapp/main/invoicing/invHeadListPending.zul new file mode 100644 index 00000000..4000df43 --- /dev/null +++ b/src/main/webapp/main/invoicing/invHeadListPending.zul @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/main/invoicing/invoicingForm.zul b/src/main/webapp/main/invoicing/invoicingForm.zul index a516a260..b003174d 100644 --- a/src/main/webapp/main/invoicing/invoicingForm.zul +++ b/src/main/webapp/main/invoicing/invoicingForm.zul @@ -17,11 +17,21 @@ -