enabled: always
datasource:
type: com.zaxxer.hikari.HikariDataSource
- url: jdbc:db2://localhost:50000/slycrm
+ # url: jdbc:db2://localhost:50000/slycrm
+ # username: db2admin
+ # password: password
+ url: jdbc:db2://db2.in.useribm.hu:50000/slycrm
username: db2admin
- password: password
-# url: jdbc:db2://db2.in.useribm.hu:50000/slycrm
-# username: db2admin
-# password: Passw@rd01
+ password: Passw@rd01
camunda.bpm:
generic-properties.properties:
telemetry-reporter-activate: false
ui:
user-name: user
password: password
- # disable-profile-save: true
+ export-temp-path: /temp
+ disable-profile-save: true
workflow:
import-invoice:
input-path: /temp/invoice-import
<artifactId>sly-crm-workflow</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
+ <!-- https://mvnrepository.com/artifact/org.dhatim/fastexcel -->
+ <dependency>
+ <groupId>org.dhatim</groupId>
+ <artifactId>fastexcel</artifactId>
+ <version>0.15.0</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
import hu.user.lis.service.data.EntityDataService;
import hu.user.lis.service.data.PartnerService;
import hu.user.lis.ui.data.common.CachedSpringDataModel;
+import hu.user.lis.ui.data.common.IDataHeaderProvider;
+import hu.user.lis.ui.data.common.IRowDataProvider;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@Component
@Log4j2
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class PartnersDataModel extends CachedSpringDataModel<Partner> {
+public class PartnersDataModel extends CachedSpringDataModel<Partner> implements IDataHeaderProvider, IRowDataProvider<Partner> {
@Autowired
PartnerRepository partnerRepository;
public void delete(Partner selectedEntity) {
partnerRepository.delete(selectedEntity);
}
+
+ public void export() {
+ super.export("partners", this, this);
+ }
+
+ @Override
+ public String[] mapHeaders() {
+ return new String[]{
+ "Név", "Adószám", "Cím", "Aktív"
+ };
+ }
+
+ @Override
+ public String[] mapRowData(Partner data) {
+ return new String[]{
+ data.getName(), data.getVatNr(), data.getAddress(), String.valueOf(data.isActive())
+ };
+ }
}
package hu.user.lis.ui.data.common;
+import hu.user.lis.ui.properties.ApplicationUIProperties;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
+import org.dhatim.fastexcel.Workbook;
+import org.dhatim.fastexcel.Worksheet;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zkoss.bind.BindUtils;
import org.zkoss.zul.FieldComparator;
+import org.zkoss.zul.Filedownload;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.event.ListDataEvent;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
-@Component
@Log4j2
+@Component
public abstract class CachedDataModel<T> extends ListModelList<T> {
public static final String NATURAL = "natural";
+
public static final String ASCENDING = "ascending";
+
public static final String DESCENDING = "descending";
- private int CACHE_SIZE = 100;
+
+ private final int CACHE_SIZE = 100;
+
+ private final HashMap<Integer, T> cache = new HashMap<>();
+
private int cacheStart;
+
private int cacheEnd;
+
private int resultSetSize = -1;
- private HashMap<Integer, T> cache = new HashMap<>();
+
@Setter
private FieldComparator sortComparator;
+ @Autowired
+ private ApplicationUIProperties applicationUIProperties;
+
public CachedDataModel() {
setMultiple(false);
@Override
public void sort(Comparator<T> cmpr, boolean ascending) {
sortComparator = (FieldComparator) cmpr;
-// log.info("Sort {} {}", sortComparator.getOrderBy(), ascending);
reset();
}
+
+ public Path export(String name, IDataHeaderProvider headerProvider, IRowDataProvider<T> rowDataProvider) {
+ String timestamp = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").format(LocalDateTime.now());
+ Path result = Paths.get(applicationUIProperties.getExportTempPath(), String.format("%s-%s.xlsx", name, timestamp));
+ int resultSetCount = getResultSetCount();
+ if (resultSetCount == 0) {
+ return null;
+ }
+ int pageCount = resultSetCount / CACHE_SIZE;
+ if (resultSetCount % CACHE_SIZE > 0) {
+ pageCount++;
+ }
+ int row = 0;
+ try (OutputStream os = Files.newOutputStream(result)) {
+ Workbook wb = new Workbook(os, "SLY-CRM", "1.0");
+ Worksheet ws = wb.newWorksheet("Sheet 1");
+ String[] headers = headerProvider.mapHeaders();
+ for (int h = 0; h < headers.length; h++) {
+ ws.value(row, h, headers[h]);
+ }
+ for (int i = 0; i < pageCount; i++) {
+ List<T> datas = getResultSet(i, CACHE_SIZE, sortComparator);
+ log.info("Got {} records", datas.size());
+ for (T data : datas) {
+ String[] rowData = rowDataProvider.mapRowData(data);
+ row++;
+ for (int o = 0; o < rowData.length; o++) {
+ ws.value(row, o, rowData[o]);
+ }
+ }
+ }
+ wb.finish();
+
+ Filedownload.save(result.toFile(), "application/vnd.ms-excel");
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ }
+ return result;
+ }
}
--- /dev/null
+package hu.user.lis.ui.data.common;
+
+public interface IDataHeaderProvider {
+
+ String[] mapHeaders();
+
+}
--- /dev/null
+package hu.user.lis.ui.data.common;
+
+public interface IRowDataProvider<T> {
+
+ String[] mapRowData(T data);
+
+}
private boolean disableProfileSave;
+ private String exportTempPath;
}
}
});
}
+
+ @Command
+ public void onExport() {
+ partnersDataModel.export();
+ }
}
-<?link rel="stylesheet" type="text/css" href="~./static/css/skeleton.css" ?>
-<?link rel="stylesheet" type="text/css" href="~./static/css/webclient.css" ?>
<zk>
<!-- <style>-->
<!-- .z-listitem-selected>.z-listcell>.z-listcell-content {-->
<!-- </style>-->
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.AssociatesViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Munkatársak" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
- <toolbarbutton label="Új" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>
+ <toolbar align="end">
+ <toolbarbutton label="Új" iconSclass="z-icon-plus"
+ onClick="@command('onAdd')"/>
<toolbarbutton label="Szerkeszt" iconSclass="z-icon-edit"
- onClick="@command('onEdit')" disabled="@load(empty vm.selectedEntity)"/>
+ onClick="@command('onEdit')"
+ disabled="@load(empty vm.selectedEntity)"/>
<toolbarbutton label="Töröl" iconSclass="z-icon-remove"
- onClick="@command('onDelete')" disabled="@load(empty vm.selectedEntity)"/>
+ onClick="@command('onDelete')"
+ disabled="@load(empty vm.selectedEntity)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
<borderlayout>
<north flex="true">
<zk>
<window id="projectEditor" hflex="true" vflex="true"
viewModel="@id('vm') @init('hu.user.lis.ui.editor.ProjectEditorModel')">
- <caption label="Projekt szerkesztés"/>
+ <caption>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
+ <label value="Projekt szerkesztés" sclass="list-title"/>
+ </hbox>
+ </caption>
<borderlayout>
<center id="centerPanel" border="none" vflex="true" hflex="true" autoscroll="true">
<vlayout hflex="true" vflex="min">
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.ApproveInvoicesViewModel')">
<!-- <timer id="timer" delay="1000" repeats="true" onTimer="@command('uiTick')"/>-->
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Számla import - Jóváhagyás" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Frissít" iconSclass="z-icon-refresh" onClick="@command('onRefresh')"/>
<!-- <toolbarbutton label="Léptet" iconSclass="z-icon-tasks"-->
<!-- onClick="@command('onCompleteTask')" disabled="@load(empty vm.selectedEntity)"/>-->
</toolbar>
- </hlayout>
+ </hbox>
</caption>
-
<borderlayout>
<north flex="true">
</north>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.AssignInvoicesViewModel')">
<!-- <timer id="timer" delay="1000" repeats="true" onTimer="@command('uiTick')"/>-->
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Számla import - Csatolás" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Frissít" iconSclass="z-icon-refresh" onClick="@command('onRefresh')"/>
<!-- <toolbarbutton label="Léptet" iconSclass="z-icon-tasks"-->
<!-- onClick="@command('onCompleteTask')" disabled="@load(empty vm.selectedEntity)"/>-->
</toolbar>
- </hlayout>
+ </hbox>
</caption>
-
<borderlayout>
<north flex="true">
</north>
<zk>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.ImportInvoicesSuspendedViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Számla parkoló" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Iktatás" iconSclass="z-icon-forward" onClick="@command('onStartAssignment')"
disabled="@load(empty vm.selectedEntity)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
<borderlayout>
<north hflex="true">
</style>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicePaymentViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Számla kiegyenlítés" sclass="list-title"/>
- </hlayout>
+ </hbox>
</caption>
<borderlayout>
</zscript>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.InvoicesViewModel')">
<caption>
- <hlayout hflex="true">
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Számlák" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Szerkeszt" iconSclass="z-icon-edit" onClick="@command('onEdit')"
disabled="@load(empty vm.selectedEntity)"/>
<!-- <toolbarbutton label="Projekt módosítás" iconSclass="z-icon-forward"-->
onClick="@command('onInvoicePayment')"
disabled="@load(empty vm.selectedEntity || vm.selectedEntity.planned)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
-
<borderlayout>
<north hflex="true">
<toolbar>
onClick="@command('setIncoming', incoming=false)"/>
<separator orient="vertical"/>
-
+
<toolbarbutton mode="toggle" iconSclass="z-icon-credit-card" label="Kiegyenlítve"
checked="@bind(vm.invoiceFilter.paid)"/>
</toolbar>
<zk>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.PartnersViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Partnerek" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Új" iconSclass="z-icon-plus"
onClick="@command('onAdd')"/>
<toolbarbutton label="Szerkeszt" iconSclass="z-icon-edit"
onClick="@command('onDelete')"
disabled="@load(empty vm.selectedEntity)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
<borderlayout>
<north hflex="true">
<listbox vflex="true" model="@load(vm.partnersDataModel)" multiple="false"
itemRenderer="@load(vm.partnersDataModel.renderer)" onSelect="@command('onListSelection')"
sizedByContent="true" span="true">
- <!-- <listfoot>-->
- <!-- <listfooter colspan="@load(vm.partnersDataModel.renderer.colCount)">-->
- <!-- <toolbar>-->
- <!-- <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus"-->
- <!-- onClick="@command('onAdd')"/>-->
- <!-- <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit"-->
- <!-- onClick="@command('onEdit')"-->
- <!-- disabled="@load(empty vm.selectedEntity)"/>-->
- <!-- <toolbarbutton label="Törlés" iconSclass="z-icon-remove"-->
- <!-- onClick="@command('onDelete')"-->
- <!-- disabled="@load(empty vm.selectedEntity)"/>-->
- <!-- </toolbar>-->
- <!-- </listfooter>-->
- <!-- </listfoot>-->
<listhead sizable="true" menupopup="editPopup"
onColSize="@command('onHeaderSizeChanged', node=node)"
children="@bind(vm.partnersDataModel.renderer.columnSettings) @template('head-item')">
</listitem>
</template>
</listbox>
-
+ <!-- <div style="width: 100%; height: 10px; background: red"></div>
+ sclass="hboxRemoveWhiteStrips"
+ -->
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
+ <toolbar align="end">
+ <toolbarbutton label="Export" iconSclass="z-icon-file-excel-o"
+ onClick="@command('onExport')"/>
+ </toolbar>
+ </hbox>
</vlayout>
</center>
</borderlayout>
<zk>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.ProjectsViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Projektek" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
+ <toolbar align="end">
<toolbarbutton label="Új" iconSclass="z-icon-plus"
onClick="@command('onAdd')"/>
<toolbarbutton label="Szerkeszt" iconSclass="z-icon-edit"
onClick="@command('onStartProcess')"
disabled="@load(empty vm.selectedEntity)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
-
<borderlayout>
<north flex="true">
<toolbar>
<zk>
<window vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.ServiceRecordsViewModel')">
<caption>
- <hlayout>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
<label value="Munkalapok" sclass="list-title"/>
- <toolbar style="margin-left: 50px">
- <toolbarbutton label="Új" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>
+ <toolbar align="end">
+ <toolbarbutton label="Új" iconSclass="z-icon-plus"
+ onClick="@command('onAdd')"/>
<toolbarbutton label="Szerkeszt" iconSclass="z-icon-edit"
- onClick="@command('onEdit')" disabled="@load(empty vm.selectedEntity)"/>
+ onClick="@command('onEdit')"
+ disabled="@load(empty vm.selectedEntity)"/>
<toolbarbutton label="Töröl" iconSclass="z-icon-remove"
- onClick="@command('onDelete')" disabled="@load(empty vm.selectedEntity)"/>
+ onClick="@command('onDelete')"
+ disabled="@load(empty vm.selectedEntity)"/>
</toolbar>
- </hlayout>
+ </hbox>
</caption>
-
<borderlayout>
<north flex="true">
<toolbar>
<zk>
<window id="centerPanel" vflex="true" viewModel="@id('vm') @init('hu.user.lis.ui.view.SettingsViewModel')">
- <caption sclass="list-title" label="Beállítások"/>
+ <caption>
+ <hbox pack="stretch" sclass="hboxRemoveWhiteStrips" hflex="true">
+ <label value="Beállítások" sclass="list-title"/>
+ </hbox>
+ </caption>
<panel collapsible="true" open="false" border="rounded"
onOpen="@command('onOpenFormPanel', parentPanel=centerPanel)">
+.z-caption-content {
+ width: 100%
+}
.number-box {
text-align: right;
width: 100px;