Compare commits
61 Commits
2ad2d85c58
..
2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 5abcbc8903 | |||
| 83ae429c65 | |||
| 4d3946d4b0 | |||
| 1fee120043 | |||
| 797e7206b3 | |||
| 05398f54af | |||
| 475c700b13 | |||
| c3d26a42f5 | |||
| 9412e23b07 | |||
| a17578398b | |||
| a42c4e1115 | |||
| c9b7db72ae | |||
| 1cdef78244 | |||
| 212738ce83 | |||
| 1179abbcd1 | |||
| 8ef0349929 | |||
| 8302e5a8ba | |||
| c818e5d31a | |||
| 8d3da0afbb | |||
| 4945afb839 | |||
| 3d73415764 | |||
| d47f7dbddb | |||
| 26019f6582 | |||
| 3d487050da | |||
| ac85156379 | |||
| 436bb240bb | |||
| 7eb54ba98f | |||
| 1b68ae3a08 | |||
| 66ef3c4066 | |||
| 6fcc33fe8d | |||
| 25cd8e9a43 | |||
| 2147b462f0 | |||
| 798960bd57 | |||
| 89195f4ae1 | |||
| a3c4635690 | |||
| d030098366 | |||
| 3192cf3efc | |||
| ec70e7e020 | |||
| 8cd7e23587 | |||
| 0cf99495f3 | |||
| 4067ae188b | |||
| 8cdbb9fd45 | |||
| 34d303ed39 | |||
| f9d72eb043 | |||
| 6441b73830 | |||
| 95ad199494 | |||
| c14938ae9c | |||
| 857de290e2 | |||
| 9ee28d46c8 | |||
| 3a76911a0c | |||
| 6dcbb3830b | |||
| 61ae6e777a | |||
| 481942f4e2 | |||
| a8e8cf50a0 | |||
| 8d62afa438 | |||
| f8b3396da6 | |||
| 941f6282d3 | |||
| eea36b5774 | |||
| f8ae09221b | |||
| 444f8a7b41 | |||
| 2d4000f6cd |
+1
-1
@@ -2,7 +2,7 @@
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ExtractMethodRecommender" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="minLength" value="951" />
|
||||
<option name="minLength" value="735" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
|
||||
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
|
||||
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Main" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="fi.lpam.Main" />
|
||||
<option name="MAIN_CLASS_NAME" value="fi.lpam.ruokamanageri.Main" />
|
||||
<module name="Ruokamanageri" />
|
||||
<option name="PROGRAM_PARAMETERS" value="DEV" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="fi.lpam.*" />
|
||||
<option name="PATTERN" value="fi.lpam.ruokamanageri.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="PROJECT" dialect="SQLite" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
# 2.0.0
|
||||
- Asiakkaalle lisätty tietoihin laskutusosoite ja yhteyshenkilön yhteystiedot
|
||||
- Tiedot nousevat kuljetusraportille laskutusta varten
|
||||
- Lisätty ohjelmaan linkki muutoslokiin
|
||||
|
||||
# 1.1.1
|
||||
- Integroitu versionumerointi projektiin
|
||||
|
||||
# 1.1.0
|
||||
- Kuljetuslistaa luodessa kuljetusrivin nollaaminen/palauttaminen oletusmääriin.
|
||||
- Kuljetuslistojen ja raporttien tulostamismekanismin läpikäynti
|
||||
- Kierroshallinnassa asiakasta raahattaessa placeholderin fiksaus
|
||||
|
||||
# 1.0.0
|
||||
Ohjelman kieli vaihdettu Pythonista Javaan, sekä tietokanta pickle-tiedostosta SQLite tietokantaan
|
||||
@@ -1,202 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2026 Lauri Maaninka
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# [LICENSE](LICENSE)
|
||||
|
||||
# [Versiohistoria](src/main/resources/CHANGELOG.md)
|
||||
## [Versiohistoria](CHANGELOG.md)
|
||||
|
||||
# Kuvaus
|
||||
Pienen kotiateriapalvelun käyttöön rakennettu ohjelma sisältäen seuraavat ominaisuudet
|
||||
@@ -9,18 +7,19 @@ Pienen kotiateriapalvelun käyttöön rakennettu ohjelma sisältäen seuraavat o
|
||||
- Kuljetuslistojen luominen
|
||||
- Kuljetettujen määrien raportointi
|
||||
|
||||
# Toteutus
|
||||
## Toteutus
|
||||
- SQLite tietokanta
|
||||
- JavaFX GUI
|
||||
- Java 25
|
||||
- Maven
|
||||
|
||||
# Käyttöönotto
|
||||
## Käyttöönotto
|
||||
- Vaatimukset
|
||||
- Windows
|
||||
- Java 25+
|
||||
- Usean tietokoneen käyttöön OneDrive -tili (samanaikaisuus ei tuettu)
|
||||
- Lataa haluamasi ohjelmaversio julkaisuista
|
||||
- Aja .JAR tiedosto
|
||||
- Tietokanta sijaitsee osoitteessa `~/OneDrive/Kuljetusruokasovellus/tietokanta.db`
|
||||
- Lataa haluamasi julkaisuversio lähdekoodista
|
||||
- Maven `package` komennolla projektista luodaan .jar tiedosto
|
||||
- .jar tiedosto sisältää kaikki riippuvuudet
|
||||
- Tietokantatiedosto asuu osoitteessa `$KOTIKANSIO/OneDrive/Kuljetusruokasovellus/tietokanta.db`
|
||||
- Ohjelma luo tietokannan, mikäli sitä ei löydy.
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fi.lpam.ruokamanageri</groupId>
|
||||
<artifactId>Ruokamanageri</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>2.0.0</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
@@ -43,31 +43,26 @@
|
||||
<dependency>
|
||||
<groupId>com.dlsc.gemsfx</groupId>
|
||||
<artifactId>gemsfx</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>3.10.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>3.0.7</version>
|
||||
<version>3.0.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.3.6</version>
|
||||
<version>1.3.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.53.1.0</version>
|
||||
<version>3.51.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>one.jpro.platform</groupId>
|
||||
<artifactId>jpro-mdfx</artifactId>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -97,7 +92,7 @@
|
||||
<!-- Usage: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<mainClass>fi.lpam.Main</mainClass>
|
||||
<mainClass>fi.lpam.ruokamanageri.Main</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -119,7 +114,7 @@
|
||||
<transformers>
|
||||
<transformer implementation=
|
||||
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>fi.lpam.Main</mainClass>
|
||||
<mainClass>fi.lpam.ruokamanageri.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package fi.lpam;
|
||||
import fi.lpam.dataluokat.Tietokanta;
|
||||
import fi.lpam.gui.*;
|
||||
import fi.lpam.gui.elementit.MuutosIlmoitus;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import javafx.application.Application;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("InstantiationOfUtilityClass")
|
||||
public class App extends Application {
|
||||
TabPohja asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut, asetukset;
|
||||
|
||||
static void main() {
|
||||
launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
new Tietokanta(Main.dev);
|
||||
|
||||
StringBuilder title = new StringBuilder();
|
||||
title.append("Ruokamanageri");
|
||||
title.append(" v").append(Main.properties.getProperty("version"));
|
||||
if (Main.dev) title.append(" KEHITYS");
|
||||
primaryStage.setTitle(title.toString());
|
||||
|
||||
primaryStage.setMaximized(true);
|
||||
|
||||
primaryStage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
||||
|
||||
TabPane tabPane = new TabPane();
|
||||
tabPane.setSide(Side.LEFT);
|
||||
tabPane.setTabMinWidth(50);
|
||||
tabPane.setTabMinHeight(Double.parseDouble(Main.properties.getProperty("buttonFonttiKoko"))*2);
|
||||
tabPane.setTabMaxHeight(Double.parseDouble(Main.properties.getProperty("buttonFonttiKoko"))*2);
|
||||
|
||||
asiakasHallinta = new Asiakashallinta();
|
||||
kierrostenHallinta = new Kierroshallinta();
|
||||
kuljetusListat = new KuljetusListat();
|
||||
kuljetetut = new KuljetusRaportit();
|
||||
asetukset = new Asetukset();
|
||||
tabPane.getTabs().addAll(asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut, asetukset);
|
||||
|
||||
Scene scene = new Scene(tabPane);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
|
||||
if (!Main.properties.getProperty("version").equals(Main.properties.getProperty("viimeisinVersio", "0.0.0"))) new MuutosIlmoitus();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package fi.lpam;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Main {
|
||||
public static boolean dev;
|
||||
public static Properties properties;
|
||||
|
||||
public static final File asetustiedosto = Path.of(SystemUtils.getUserHome().getAbsolutePath(), "OneDrive", "Kuljetusruokasovellus", "asetukset.properties").toFile();
|
||||
|
||||
static void main(String[] args) {
|
||||
//noinspection RedundantIfStatement
|
||||
if (args.length > 0) {
|
||||
dev = true;
|
||||
} else {
|
||||
dev = false;
|
||||
}
|
||||
|
||||
try {
|
||||
Properties defaults = new Properties();
|
||||
defaults.load(Main.class.getClassLoader().getResourceAsStream("defaults.properties"));
|
||||
properties = new Properties(defaults);
|
||||
properties.load(new FileInputStream(asetustiedosto));
|
||||
}
|
||||
catch (IOException e) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
App.main();
|
||||
|
||||
try (OutputStream os = new FileOutputStream(asetustiedosto)) {
|
||||
properties.store(os, "");
|
||||
} catch (IOException e) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package fi.lpam.gui;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.text.Font;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class Asetukset extends TabPohja {
|
||||
private static final Properties prop = Main.properties;
|
||||
private static final ObservableList<String> järjestelmäFontit = FXCollections.observableArrayList(Font.getFamilies());
|
||||
|
||||
|
||||
public Asetukset() {
|
||||
super("Asetukset");
|
||||
|
||||
HBox yläpalkki = new HBox();
|
||||
yläpalkki.setSpacing(5);
|
||||
yläpalkki.setAlignment(Pos.CENTER_RIGHT);
|
||||
Button btnNollaa = new Button("Palauta oletukset");
|
||||
btnNollaa.setFont(BUTTON_FONT);
|
||||
btnNollaa.setOnAction(_ -> palautaOletukset());
|
||||
yläpalkki.getChildren().add(btnNollaa);
|
||||
root.setTop(yläpalkki);
|
||||
|
||||
root.setCenter(getFonttiAsetukset());
|
||||
|
||||
}
|
||||
|
||||
private Spinner<Integer> tekstiFonttiKoko, buttonFonttiKoko, tulostusFonttiKoko, insets;
|
||||
private ComboBox<String> tekstiFontti, buttonFontti;
|
||||
|
||||
/**
|
||||
* Luo paneelin fonttien asetusten säätämiseen
|
||||
* @return paneeli
|
||||
*/
|
||||
private GridPane getFonttiAsetukset() {
|
||||
GridPane root = new GridPane();
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setHgap(SPACING *2);
|
||||
root.setVgap(SPACING *2);
|
||||
root.setBorder(BORDER);
|
||||
root.setPadding(INSETS);
|
||||
int row = 0;
|
||||
|
||||
Label otsikko = new Label("Fonttien asetukset");
|
||||
otsikko.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, otsikko);
|
||||
|
||||
int minFonttiKoko = 8;
|
||||
int maxFonttiKoko = 18;
|
||||
int stepFontti = 1;
|
||||
tekstiFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Integer.parseInt(prop.getProperty("tekstiFonttiKoko")), stepFontti);
|
||||
tekstiFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("tekstiFonttiKoko", String.valueOf(tekstiFonttiKoko.getValue())));
|
||||
Label tekstinKoko = new Label("Tekstin koko");
|
||||
tekstinKoko.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, tekstinKoko, tekstiFonttiKoko);
|
||||
|
||||
tekstiFontti = new ComboBox<>();
|
||||
tekstiFontti.setItems(järjestelmäFontit);
|
||||
tekstiFontti.getSelectionModel().select(prop.getProperty("tekstiFontti"));
|
||||
tekstiFontti.valueProperty().addListener((_) -> prop.setProperty("tekstiFontti", tekstiFontti.getValue()));
|
||||
Label tekstinFontti = new Label("Tekstin fontti");
|
||||
tekstinFontti.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, tekstinFontti, tekstiFontti);
|
||||
|
||||
buttonFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Integer.parseInt(prop.getProperty("buttonFonttiKoko")), stepFontti);
|
||||
buttonFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("buttonFonttiKoko", String.valueOf(buttonFonttiKoko.getValue())));
|
||||
Label nappiTekstinKoko = new Label("Painikkeiden koko");
|
||||
nappiTekstinKoko.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, nappiTekstinKoko, buttonFonttiKoko);
|
||||
|
||||
buttonFontti = new ComboBox<>();
|
||||
buttonFontti.setItems(järjestelmäFontit);
|
||||
buttonFontti.getSelectionModel().select(prop.getProperty("buttonFontti"));
|
||||
buttonFontti.valueProperty().addListener((_) -> prop.setProperty("buttonFontti", buttonFontti.getValue()));
|
||||
Label napinFontti = new Label("Painikkeiden fontti");
|
||||
napinFontti.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, napinFontti, buttonFontti);
|
||||
|
||||
tulostusFonttiKoko = new Spinner<>(minFonttiKoko, maxFonttiKoko, Integer.parseInt(prop.getProperty("tulostusFonttiKoko")), stepFontti);
|
||||
tulostusFonttiKoko.valueProperty().addListener((_) -> prop.setProperty("tulostusFonttiKoko", String.valueOf(tulostusFonttiKoko.getValue())));
|
||||
Label tulostusFontinKoko = new Label("Tulostusfontin koko");
|
||||
tulostusFontinKoko.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, tulostusFontinKoko, tulostusFonttiKoko);
|
||||
|
||||
insets = new Spinner<>(0, 10, Integer.parseInt(prop.getProperty("insets")), 1);
|
||||
insets.valueProperty().addListener((_) -> prop.setProperty("insets", String.valueOf(insets.getValue())));
|
||||
Label insetsi = new Label("Yleinen fyllinki");
|
||||
insetsi.setFont(TEKSTI_FONT);
|
||||
root.addRow(row++, insetsi, insets);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private void palautaOletukset() {
|
||||
try {
|
||||
Properties defaults = new Properties();
|
||||
defaults.load(Main.class.getClassLoader().getResourceAsStream("defaults.properties"));
|
||||
|
||||
tekstiFonttiKoko.getValueFactory().setValue(Integer.valueOf(defaults.getProperty("tekstiFonttiKoko")));
|
||||
tekstiFontti.getSelectionModel().select(defaults.getProperty("tekstiFontti"));
|
||||
buttonFonttiKoko.getValueFactory().setValue(Integer.valueOf(defaults.getProperty("buttonFonttiKoko")));
|
||||
buttonFontti.getSelectionModel().select(defaults.getProperty("buttonFontti"));
|
||||
tulostusFonttiKoko.getValueFactory().setValue(Integer.valueOf(defaults.getProperty("tulostusFonttiKoko")));
|
||||
insets.getValueFactory().setValue(Integer.valueOf(defaults.getProperty("insets")));
|
||||
}
|
||||
catch (IOException e) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.text.Font;
|
||||
|
||||
public class FontLabel extends Label {
|
||||
public FontLabel(Font font, String text) {
|
||||
super(text);
|
||||
this.setFont(font);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory;
|
||||
|
||||
public class IntegerSpinner extends Spinner<Integer> {
|
||||
public IntegerSpinner() {
|
||||
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 500));
|
||||
this.setEditable(true);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import javafx.scene.control.TableColumn;
|
||||
|
||||
public class MaaraTableColumn<Asiakas, Integer> extends TableColumn<Asiakas, Integer> {
|
||||
public MaaraTableColumn(String columnLabel, int minWidth, int maxWidth) {
|
||||
super(columnLabel);
|
||||
this.setResizable(true);
|
||||
this.setReorderable(false);
|
||||
this.setMinWidth(minWidth);
|
||||
this.setMaxWidth(maxWidth);
|
||||
this.setStyle("-fx-alignment: CENTER; -fx-font-size: 16px;");
|
||||
}
|
||||
|
||||
public MaaraTableColumn(String columnLabel, int width) {
|
||||
this(columnLabel, width, width);
|
||||
this.setResizable(false);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Stage;
|
||||
import one.jpro.platform.mdfx.MarkdownView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MuutosIlmoitus extends Stage {
|
||||
public MuutosIlmoitus() {
|
||||
super();
|
||||
VBox root = new VBox();
|
||||
root.setBorder(TabPohja.BORDER);
|
||||
root.setPadding(TabPohja.INSETS);
|
||||
root.setAlignment(Pos.CENTER);
|
||||
root.setSpacing(10);
|
||||
|
||||
String md;
|
||||
try (InputStreamReader isr = new InputStreamReader(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("CHANGELOG.md")))) {
|
||||
md = isr.readAllAsString();
|
||||
int toinenMerkintä = md.indexOf("# ", 1);
|
||||
int kolmasMerkintä = md.indexOf("# ", toinenMerkintä + 1);
|
||||
int endIndex = md.indexOf("# ", kolmasMerkintä + 1);
|
||||
md = md.substring(0, endIndex);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
md = "# Virhe versiolokin haussa";
|
||||
}
|
||||
|
||||
MarkdownView markdownView = new MarkdownView(md);
|
||||
root.getChildren().add(markdownView);
|
||||
|
||||
Button ok = new Button("OK");
|
||||
ok.setFont(TabPohja.BUTTON_FONT);
|
||||
ok.setOnAction(e -> this.close());
|
||||
root.getChildren().add(ok);
|
||||
|
||||
Scene scene = new Scene(root);
|
||||
this.setScene(scene);
|
||||
this.setTitle("Uusi versio, katso muutokset alta!");
|
||||
this.setResizable(false);
|
||||
this.show();
|
||||
|
||||
Main.properties.setProperty("viimeisinVersio", Main.properties.getProperty("version"));
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Käyttöliittymän välilehden pohja
|
||||
*/
|
||||
public class TabPohja extends Tab {
|
||||
public static Insets INSETS;
|
||||
public static Border BORDER = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
|
||||
public static String STYLE;
|
||||
public static Font BUTTON_FONT;
|
||||
public static Font TEKSTI_FONT;
|
||||
public static double SPACING;
|
||||
|
||||
protected BorderPane root = new BorderPane();
|
||||
|
||||
public TabPohja(String title) {
|
||||
super(title);
|
||||
Properties prop = Main.properties;
|
||||
INSETS = new Insets(Double.parseDouble(prop.getProperty("insets")));
|
||||
SPACING = Double.parseDouble(prop.getProperty("insets"));
|
||||
STYLE = "-fx-background-color: " + prop.getProperty("taustaVari");
|
||||
BUTTON_FONT = Font.font(prop.getProperty("buttonFontti"), FontWeight.BOLD, Double.parseDouble(prop.getProperty("buttonFonttiKoko")));
|
||||
TEKSTI_FONT = Font.font(prop.getProperty("tekstiFontti"), FontWeight.NORMAL, Double.parseDouble(prop.getProperty("tekstiFonttiKoko")));
|
||||
|
||||
this.setStyle(
|
||||
"-fx-font-size: " + Main.properties.getProperty("buttonFonttiKoko") + "px;" +
|
||||
"-fx-font-weight: bold;" +
|
||||
"-fx-font-family: " + Main.properties.getProperty("buttonFontti") + ";"
|
||||
);
|
||||
this.setClosable(false);
|
||||
this.setOnSelectionChanged(e -> {if (e.getTarget() == this) päivitä();});
|
||||
|
||||
root.setStyle(STYLE);
|
||||
root.setPadding(INSETS);
|
||||
root.setBorder(BORDER);
|
||||
this.setContent(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodi, jota kutsutaan kun tähän välilehteen palataan
|
||||
* Luokan toteuttaja määrittää, mitä tarvitsee päivittää välilehteen palattaessa
|
||||
*/
|
||||
public void päivitä() {}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package fi.lpam.gui.tableCell;
|
||||
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.converter.IntegerStringConverter;
|
||||
|
||||
public class IntegerFieldTableCellFactory<T> implements Callback<TableColumn<T, Integer>, TableCell<T, Integer>> {
|
||||
@Override
|
||||
public TableCell<T, Integer> call(TableColumn<T, Integer> param ) {
|
||||
return new TextFieldTableCell<>(new IntegerStringConverter()) {
|
||||
private boolean filterSet = false;
|
||||
|
||||
@Override
|
||||
public void startEdit() {
|
||||
super.startEdit();
|
||||
if (!filterSet) {
|
||||
getGraphic().addEventFilter(KeyEvent.KEY_TYPED, KE -> {
|
||||
if (!"0123456789".contains(KE.getCharacter())) {
|
||||
KE.consume();
|
||||
}
|
||||
});
|
||||
filterSet = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package fi.lpam.ruokamanageri;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Tietokanta;
|
||||
import fi.lpam.ruokamanageri.gui.Asiakashallinta;
|
||||
import fi.lpam.ruokamanageri.gui.Kierroshallinta;
|
||||
import fi.lpam.ruokamanageri.gui.KuljetusRaportit;
|
||||
import fi.lpam.ruokamanageri.gui.KuljetusListat;
|
||||
import javafx.application.Application;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("InstantiationOfUtilityClass")
|
||||
public class App extends Application {
|
||||
static void main() {
|
||||
launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
new Tietokanta(Main.dev);
|
||||
|
||||
TabPane root = new TabPane();
|
||||
root.setSide(Side.LEFT);
|
||||
root.setTabMinWidth(50);
|
||||
root.setTabMinHeight(35);
|
||||
root.setTabMaxHeight(50);
|
||||
|
||||
Tab asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut;
|
||||
asiakasHallinta = new Tab("Asiakashallinta", new Asiakashallinta());
|
||||
kierrostenHallinta = new Tab("Kierrostenhallinta");
|
||||
kuljetusListat = new Tab("Kuljetuslistat");
|
||||
kuljetetut = new Tab("Kuljetetut");
|
||||
root.getTabs().addAll(asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut);
|
||||
|
||||
root.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
|
||||
switch (newValue.getText()) {
|
||||
case "Asiakashallinta": newValue.setContent(new Asiakashallinta()); break;
|
||||
case "Kierrostenhallinta": newValue.setContent(new Kierroshallinta()); break;
|
||||
case "Kuljetuslistat": newValue.setContent(new KuljetusListat()); break;
|
||||
case "Kuljetetut": newValue.setContent(new KuljetusRaportit()); break;
|
||||
}
|
||||
});
|
||||
|
||||
for (Tab tab : root.getTabs()) {
|
||||
tab.setClosable(false);
|
||||
tab.setStyle("-fx-font-size: 18px; -fx-font-weight: bold; -fx-font-family: Open Sans");
|
||||
}
|
||||
|
||||
Scene scene = new Scene(root);
|
||||
primaryStage.setScene(scene);
|
||||
|
||||
StringBuilder title = new StringBuilder();
|
||||
title.append("Ruokamanageri");
|
||||
title.append(" v").append(Main.properties.getProperty("version"));
|
||||
if (Main.dev) title.append(" KEHITYS");
|
||||
primaryStage.setTitle(title.toString());
|
||||
|
||||
primaryStage.setMaximized(true);
|
||||
primaryStage.show();
|
||||
primaryStage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package fi.lpam.ruokamanageri;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Main {
|
||||
public static boolean dev;
|
||||
public static Properties properties;
|
||||
|
||||
static void main(String[] args) {
|
||||
//noinspection RedundantIfStatement
|
||||
if (args.length > 0) {
|
||||
dev = true;
|
||||
} else {
|
||||
dev = false;
|
||||
}
|
||||
|
||||
try {
|
||||
properties = new Properties();
|
||||
properties.load(Main.class.getClassLoader().getResourceAsStream("app.properties"));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
App.main();
|
||||
}
|
||||
}
|
||||
+27
-92
@@ -1,19 +1,15 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class Asiakas implements TietokantaOlio {
|
||||
private int id = -1;
|
||||
private String nimi;
|
||||
private String osoite;
|
||||
private int maanantaiKpl, tiistaiKpl, keskiviikkoKpl, torstaiKpl, perjantaiKpl, lauantaiKpl, sunnuntaiKpl;
|
||||
private int maanantaiKpl, tiistaiKpl, keskiviikkoKpl, torstaiKpl, perjantaiKpl;
|
||||
private int salaatit, pääruoat, jälkiruoat;
|
||||
private String erityisruokavalio;
|
||||
private String avainTieto;
|
||||
@@ -44,8 +40,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
* @param keskiviikkoKpl kuljetettava määrä
|
||||
* @param torstaiKpl kuljetettava määrä
|
||||
* @param perjantaiKpl kuljetettava määrä
|
||||
* @param lauantaiKpl kuljetettava määrä
|
||||
* @param sunnuntaiKpl kuljetettava määrä
|
||||
* @param salaatit kuljetettava määrä
|
||||
* @param pääruoat kuljetettava määrä
|
||||
* @param jälkiruoat kuljetettava määrä
|
||||
@@ -65,8 +59,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
int keskiviikkoKpl,
|
||||
int torstaiKpl,
|
||||
int perjantaiKpl,
|
||||
int lauantaiKpl,
|
||||
int sunnuntaiKpl,
|
||||
int salaatit,
|
||||
int pääruoat,
|
||||
int jälkiruoat,
|
||||
@@ -85,8 +77,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
this.keskiviikkoKpl = keskiviikkoKpl;
|
||||
this.torstaiKpl = torstaiKpl;
|
||||
this.perjantaiKpl = perjantaiKpl;
|
||||
this.lauantaiKpl = lauantaiKpl;
|
||||
this.sunnuntaiKpl = sunnuntaiKpl;
|
||||
this.salaatit = salaatit;
|
||||
this.pääruoat = pääruoat;
|
||||
this.jälkiruoat = jälkiruoat;
|
||||
@@ -116,7 +106,7 @@ public class Asiakas implements TietokantaOlio {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hakee tietokannasta asiakasidn perusteella asiakkaat ja palauttaa ne annetussa järjestyksessä
|
||||
* Hakee tietokannasta asiakasidn perusteella asiakkaat
|
||||
* @param IDt haettavat asiakkkaat
|
||||
* @return Haetut asiakkaat tai null
|
||||
*/
|
||||
@@ -127,17 +117,10 @@ public class Asiakas implements TietokantaOlio {
|
||||
sbIDt.append(", ").append(IDt[i]);
|
||||
}
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
String sql = "select * from asiakkaat where id in (" + sbIDt + ")";
|
||||
String sql = "select * from asiakkaat where id in (" + sbIDt + ") order by instr('" + sbIDt + "', id)";
|
||||
Statement stmt = tietokanta.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
HashMap<Integer, Asiakas> asiakkaat = new HashMap<>(IDt.length);
|
||||
parsiResultSet(rs).forEach(asiakas -> asiakkaat.put(asiakas.getId(), asiakas));
|
||||
ArrayList<Asiakas> järjestetyt = new ArrayList<>(asiakkaat.size());
|
||||
for (int id : IDt) {
|
||||
järjestetyt.add(asiakkaat.get(id));
|
||||
}
|
||||
return järjestetyt;
|
||||
return parsiResultSet(rs);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
SiirtoVirhe alert = new SiirtoVirhe(e);
|
||||
@@ -156,27 +139,26 @@ public class Asiakas implements TietokantaOlio {
|
||||
|
||||
try {
|
||||
while (rs.next()) {
|
||||
int i = 1;
|
||||
Asiakas uusi = new Asiakas(
|
||||
rs.getInt("id"),
|
||||
rs.getString("nimi"),
|
||||
rs.getString("osoite"),
|
||||
rs.getInt("maanantaiKpl"),
|
||||
rs.getInt("tiistaiKpl"),
|
||||
rs.getInt("keskiviikkoKpl"),
|
||||
rs.getInt("torstaiKpl"),
|
||||
rs.getInt("perjantaiKpl"),
|
||||
rs.getInt("lauantaiKpl"),
|
||||
rs.getInt("sunnuntaiKpl"),
|
||||
rs.getInt("salaatit"),
|
||||
rs.getInt("pääruoat"),
|
||||
rs.getInt("jälkiruoat"),
|
||||
rs.getString("erityisruokavalio"),
|
||||
rs.getString("avainTieto"),
|
||||
rs.getString("lisätiedot"),
|
||||
rs.getString("laskutusOsoite"),
|
||||
rs.getString("yhteyshenkilönNimi"),
|
||||
rs.getString("yhteyshenkilönPuhelinnumero"),
|
||||
rs.getString("yhteyshenkilönSähköposti")
|
||||
rs.getInt(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getInt(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++),
|
||||
rs.getString(i++)
|
||||
);
|
||||
asiakkaat.add(uusi);
|
||||
}
|
||||
@@ -195,7 +177,7 @@ public class Asiakas implements TietokantaOlio {
|
||||
@Override
|
||||
public boolean tallennaUusi() {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("INSERT INTO asiakkaat (nimi, osoite, maanantaiKpl, tiistaiKpl, keskiviikkoKpl, torstaiKpl, perjantaiKpl, lauantaiKpl, sunnuntaiKpl, salaatit, pääruoat, jälkiruoat, erityisruokavalio, avainTieto, lisätiedot, laskutusosoite, yhteyshenkilönNimi, yhteyshenkilönPuhelinnumero, yhteyshenkilönSähköposti) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("INSERT INTO asiakkaat (nimi, osoite, maanantaiKpl, tiistaiKpl, keskiviikkoKpl, torstaiKpl, perjantaiKpl, salaatit, pääruoat, jälkiruoat, erityisruokavalio, avainTieto, lisätiedot, laskutusosoite, yhteyshenkilönNimi, yhteyshenkilönPuhelinnumero, yhteyshenkilönSähköposti) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
int i = 1;
|
||||
stmt.setString(i++, nimi);
|
||||
stmt.setString(i++, osoite);
|
||||
@@ -204,8 +186,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
stmt.setInt(i++, keskiviikkoKpl);
|
||||
stmt.setInt(i++, torstaiKpl);
|
||||
stmt.setInt(i++, perjantaiKpl);
|
||||
stmt.setInt(i++, lauantaiKpl);
|
||||
stmt.setInt(i++, sunnuntaiKpl);
|
||||
stmt.setInt(i++, salaatit);
|
||||
stmt.setInt(i++, pääruoat);
|
||||
stmt.setInt(i++, jälkiruoat);
|
||||
@@ -244,7 +224,7 @@ public class Asiakas implements TietokantaOlio {
|
||||
@Override
|
||||
public boolean päivitäTietokantaan() {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("UPDATE asiakkaat set nimi = ?, osoite = ?, maanantaiKpl = ?, tiistaiKpl = ?, keskiviikkoKpl = ?, torstaiKpl = ?, perjantaiKpl = ?, lauantaiKpl = ?, sunnuntaiKpl = ?, salaatit = ?, pääruoat = ?, jälkiruoat = ?, erityisruokavalio = ?, avainTieto = ?, lisätiedot = ?, laskutusosoite = ?, yhteyshenkilönNimi = ?, yhteyshenkilönPuhelinnumero = ?, yhteyshenkilönSähköposti = ? WHERE id = ?");
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("UPDATE asiakkaat set nimi = ?, osoite = ?, maanantaiKpl = ?, tiistaiKpl = ?, keskiviikkoKpl = ?, torstaiKpl = ?, perjantaiKpl = ?, salaatit = ?, pääruoat = ?, jälkiruoat = ?, erityisruokavalio = ?, avainTieto = ?, lisätiedot = ?, laskutusosoite = ?, yhteyshenkilönNimi = ?, yhteyshenkilönPuhelinnumero = ?, yhteyshenkilönSähköposti = ? WHERE id = ?");
|
||||
int i = 1;
|
||||
stmt.setString(i++, nimi);
|
||||
stmt.setString(i++, osoite);
|
||||
@@ -253,8 +233,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
stmt.setInt(i++, keskiviikkoKpl);
|
||||
stmt.setInt(i++, torstaiKpl);
|
||||
stmt.setInt(i++, perjantaiKpl);
|
||||
stmt.setInt(i++, lauantaiKpl);
|
||||
stmt.setInt(i++, sunnuntaiKpl);
|
||||
stmt.setInt(i++, salaatit);
|
||||
stmt.setInt(i++, pääruoat);
|
||||
stmt.setInt(i++, jälkiruoat);
|
||||
@@ -310,33 +288,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
return this.getNimi();
|
||||
}
|
||||
|
||||
public int getPäivänSalaatit(LocalDate päivä) {
|
||||
int kerroin = getKuljetusKerroin(päivä);
|
||||
return kerroin * getSalaatit();
|
||||
}
|
||||
|
||||
public int getPäivänPääruoat(LocalDate päivä) {
|
||||
int kerroin = getKuljetusKerroin(päivä);
|
||||
return kerroin * getPääruoat();
|
||||
}
|
||||
|
||||
public int getPäivänJälkiruoat(LocalDate päivä) {
|
||||
int kerroin = getKuljetusKerroin(päivä);
|
||||
return kerroin * getJälkiruoat();
|
||||
}
|
||||
|
||||
private int getKuljetusKerroin(LocalDate päivä) {
|
||||
return switch (päivä.getDayOfWeek()) {
|
||||
case DayOfWeek.MONDAY -> getMaanantaiKpl();
|
||||
case DayOfWeek.TUESDAY -> getTiistaiKpl();
|
||||
case DayOfWeek.WEDNESDAY -> getKeskiviikkoKpl();
|
||||
case DayOfWeek.THURSDAY -> getTorstaiKpl();
|
||||
case DayOfWeek.FRIDAY -> getPerjantaiKpl();
|
||||
case DayOfWeek.SATURDAY -> getLauantaiKpl();
|
||||
case DayOfWeek.SUNDAY -> getSunnuntaiKpl();
|
||||
};
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -401,22 +352,6 @@ public class Asiakas implements TietokantaOlio {
|
||||
this.perjantaiKpl = perjantaiKpl;
|
||||
}
|
||||
|
||||
public int getLauantaiKpl() {
|
||||
return lauantaiKpl;
|
||||
}
|
||||
|
||||
public void setLauantaiKpl(int lauantaiKpl) {
|
||||
this.lauantaiKpl = lauantaiKpl;
|
||||
}
|
||||
|
||||
public int getSunnuntaiKpl() {
|
||||
return sunnuntaiKpl;
|
||||
}
|
||||
|
||||
public void setSunnuntaiKpl(int sunnuntaiKpl) {
|
||||
this.sunnuntaiKpl = sunnuntaiKpl;
|
||||
}
|
||||
|
||||
public int getSalaatit() {
|
||||
return salaatit;
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
+89
-9
@@ -1,6 +1,6 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
@@ -36,9 +36,17 @@ public class Kuljetus implements TietokantaOlio {
|
||||
this.nimi = asiakas.getNimi();
|
||||
this.kuljetusPäivämäärä = pvm;
|
||||
this.kuljetusKierros = kuljetusKierros;
|
||||
this.salaatit = asiakas.getPäivänSalaatit(pvm);
|
||||
this.pääruoat = asiakas.getPäivänPääruoat(pvm);
|
||||
this.jälkiruoat = asiakas.getPäivänJälkiruoat(pvm);
|
||||
int kuljetusKerroin = switch (kuljetusPäivämäärä.getDayOfWeek()) {
|
||||
case MONDAY -> asiakas.getMaanantaiKpl();
|
||||
case TUESDAY -> asiakas.getTiistaiKpl();
|
||||
case WEDNESDAY -> asiakas.getKeskiviikkoKpl();
|
||||
case THURSDAY -> asiakas.getTorstaiKpl();
|
||||
case FRIDAY -> asiakas.getPerjantaiKpl();
|
||||
default -> 0;
|
||||
};
|
||||
this.salaatit = kuljetusKerroin * asiakas.getSalaatit();
|
||||
this.pääruoat = kuljetusKerroin * asiakas.getPääruoat();
|
||||
this.jälkiruoat = kuljetusKerroin * asiakas.getJälkiruoat();
|
||||
this.osoite = asiakas.getOsoite();
|
||||
this.avainTieto = asiakas.getAvainTieto();
|
||||
this.lisätieto = asiakas.getLisätiedot();
|
||||
@@ -60,6 +68,36 @@ public class Kuljetus implements TietokantaOlio {
|
||||
this.ruokarajoite = ruokarajoite;
|
||||
}
|
||||
|
||||
public static ArrayList<Kuljetus> haeKaikki() {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
Statement stmt = tietokanta.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM kuljetukset;");
|
||||
return parsiResultSet(rs);
|
||||
} catch (SQLException e) {
|
||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||
virhe.showAndWait();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hakee yhden päivän kuljetukset riippumatta kierroksesta
|
||||
* @param päivä haettava päivä
|
||||
* @return päivän kuljetukset
|
||||
*/
|
||||
public static ArrayList<Kuljetus> haePäivänKuljetukset(LocalDate päivä) {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("SELECT * FROM kuljetukset WHERE kuljetusPäivämäärä = ?;");
|
||||
stmt.setDate(1, Date.valueOf(päivä));
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
return parsiResultSet(rs);
|
||||
} catch (SQLException e) {
|
||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||
virhe.showAndWait();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hakee tietyn kierroksen kuljetukset
|
||||
* @param päivä kierroksen päivä
|
||||
@@ -79,6 +117,41 @@ public class Kuljetus implements TietokantaOlio {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Hakee kuljetukset aikajakson perusteella
|
||||
*
|
||||
* @param alku jakson alku (sisältyen)
|
||||
* @param loppu jakson loppu (sisältyen)
|
||||
* @return Jakson kuljetukset
|
||||
*/
|
||||
public static ArrayList<Kuljetus> haeAikaJakso(LocalDate alku, LocalDate loppu) {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("SELECT * FROM kuljetukset WHERE kuljetusPäivämäärä BETWEEN ? AND ?");
|
||||
stmt.setDate(1, Date.valueOf(alku));
|
||||
stmt.setDate(2, Date.valueOf(loppu));
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
return parsiResultSet(rs);
|
||||
} catch (SQLException e) {
|
||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||
virhe.showAndWait();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Kuljetus> haeAikaJaksollaJaKierroksella(LocalDate alku, LocalDate loppu, int kuljetusKierros) {
|
||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||
PreparedStatement stmt = tietokanta.prepareStatement("SELECT * FROM kuljetukset WHERE kuljetusKierros = ? and kuljetusPäivämäärä BETWEEN ? AND ?");
|
||||
stmt.setInt(1, kuljetusKierros);
|
||||
stmt.setDate(2, Date.valueOf(alku));
|
||||
stmt.setDate(3, Date.valueOf(loppu));
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
return parsiResultSet(rs);
|
||||
} catch (SQLException e) {
|
||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||
virhe.showAndWait();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tallennaUusi() {
|
||||
@@ -218,16 +291,23 @@ public class Kuljetus implements TietokantaOlio {
|
||||
}
|
||||
|
||||
public void palautaMäärät(Asiakas asiakas) {
|
||||
setSalaatit(asiakas.getPäivänSalaatit(kuljetusPäivämäärä));
|
||||
setPääruoat(asiakas.getPäivänPääruoat(kuljetusPäivämäärä));
|
||||
setJälkiruoat(asiakas.getPäivänJälkiruoat(kuljetusPäivämäärä));
|
||||
int kuljetusKerroin = switch (kuljetusPäivämäärä.getDayOfWeek()) {
|
||||
case MONDAY -> asiakas.getMaanantaiKpl();
|
||||
case TUESDAY -> asiakas.getTiistaiKpl();
|
||||
case WEDNESDAY -> asiakas.getKeskiviikkoKpl();
|
||||
case THURSDAY -> asiakas.getTorstaiKpl();
|
||||
case FRIDAY -> asiakas.getPerjantaiKpl();
|
||||
default -> 0;
|
||||
};
|
||||
setSalaatit(asiakas.getSalaatit() * kuljetusKerroin);
|
||||
setPääruoat(asiakas.getPääruoat() * kuljetusKerroin);
|
||||
setJälkiruoat(asiakas.getJälkiruoat() * kuljetusKerroin);
|
||||
setLisätieto(asiakas.getLisätiedot());
|
||||
}
|
||||
|
||||
public boolean kuljetetaan() {
|
||||
return salaatit > 0 || pääruoat > 0 || jälkiruoat > 0 || !lisätieto.isBlank();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
+12
-12
@@ -1,28 +1,28 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.ruokamanageri.Main;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.*;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Tietokanta {
|
||||
private static String osoite;
|
||||
private static File tietokantatiedosto = Path.of(SystemUtils.getUserHome().getAbsolutePath(), "OneDrive", "Kuljetusruokasovellus", "tietokanta.db").toFile();
|
||||
private static String dbPath = SystemUtils.getUserHome().getAbsolutePath() + "\\OneDrive\\Kuljetusruokasovellus\\tietokanta.db";
|
||||
|
||||
public Tietokanta(boolean dev) {
|
||||
if (dev) tietokantatiedosto = new File("testikanta.db");
|
||||
if (dev) dbPath = "testikanta.db";
|
||||
File file = new File(dbPath);
|
||||
try {
|
||||
boolean _ = tietokantatiedosto.getParentFile().mkdirs();
|
||||
boolean _ = tietokantatiedosto.createNewFile();
|
||||
boolean _ = file.getParentFile().mkdirs();
|
||||
boolean _ = file.createNewFile();
|
||||
}
|
||||
catch (Exception _) {}
|
||||
|
||||
osoite = "jdbc:sqlite:" + tietokantatiedosto.getAbsolutePath();
|
||||
osoite = "jdbc:sqlite:" + file.getAbsolutePath();
|
||||
|
||||
|
||||
try (Connection conn = haeYhteys()) {
|
||||
@@ -38,11 +38,11 @@ public class Tietokanta {
|
||||
handleException(e);
|
||||
}
|
||||
|
||||
//Lisää kuljetuspäivät asiakassarakkeeseen (v2.0.2->3.x.x)
|
||||
String[] sarakkeet = {"lauantaiKpl", "sunnuntaiKpl"};
|
||||
//Lisää laskutustiedot asiakastauluun
|
||||
String[] sarakkeet = {"laskutusosoite", "yhteyshenkilönNimi", "yhteyshenkilönPuhelinnumero", "yhteyshenkilönSähköposti"};
|
||||
for (String sarake : sarakkeet) {
|
||||
try (Connection conn = haeYhteys()) {
|
||||
PreparedStatement stmt = conn.prepareStatement("alter table asiakkaat add column " + sarake + " int not null default 0");
|
||||
PreparedStatement stmt = conn.prepareStatement("alter table asiakkaat add column " + sarake + " varchar(255)");
|
||||
stmt.execute();
|
||||
} catch (SQLException e) {
|
||||
if (!e.getMessage().contains("duplicate column name")) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package fi.lpam.dataluokat;
|
||||
package fi.lpam.ruokamanageri.dataluokat;
|
||||
|
||||
public interface TietokantaOlio {
|
||||
|
||||
+82
-98
@@ -1,10 +1,10 @@
|
||||
package fi.lpam.gui;
|
||||
package fi.lpam.ruokamanageri.gui;
|
||||
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
|
||||
import fi.lpam.gui.elementit.IntegerSpinner;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.IntegerSpinner;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
||||
import fi.lpam.ruokamanageri.Main;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Side;
|
||||
@@ -22,7 +22,7 @@ import java.util.Objects;
|
||||
public class AsiakasIkkuna extends Stage {
|
||||
final Asiakas käsiteltäväAsiakas;
|
||||
final TextField tfNimi, tfOsoite, tfRuokarajoitteet, tfAvainTieto, tfLisätiedot, tfYhteyshenkilönNimi, tfLaskutusOsoite, tfYhteyshenkilönPuhelinnumero, tfYhteyshenkilönSähköposti;
|
||||
final IntegerSpinner tfMaanantai, tfTiistai, tfKeskiviikko, tfTorstai, tfPerjantai, tfLauantai, tfSunnuntai, tfSalaatit, tfPääruoat, tfJälkiruoat;
|
||||
final IntegerSpinner tfMaanantai, tfTiistai, tfKeskiviikko, tfTorstai, tfPerjantai, tfSalaatit, tfPääruoat, tfJälkiruoat;
|
||||
|
||||
/**
|
||||
* Luo ikkunan jossa muokataan saatua asiakasta
|
||||
@@ -30,12 +30,7 @@ public class AsiakasIkkuna extends Stage {
|
||||
*/
|
||||
public AsiakasIkkuna(Asiakas käsiteltäväAsiakas) {
|
||||
this.käsiteltäväAsiakas = käsiteltäväAsiakas;
|
||||
if (käsiteltäväAsiakas.getNimi() != null) {
|
||||
this.setTitle(käsiteltäväAsiakas.getNimi());
|
||||
}
|
||||
else {
|
||||
this.setTitle("Uusi asiakas");
|
||||
}
|
||||
this.setTitle("Asiakasikkuna");
|
||||
|
||||
TabPane tabPane = new TabPane();
|
||||
tabPane.setSide(Side.LEFT);
|
||||
@@ -51,78 +46,22 @@ public class AsiakasIkkuna extends Stage {
|
||||
default: break;
|
||||
}});
|
||||
|
||||
Tab tabKuljetusTiedot, tabAsiakastiedot;
|
||||
tabKuljetusTiedot = new TabPohja("Kuljetustiedot");
|
||||
tabAsiakastiedot = new TabPohja("Asiakastiedot");
|
||||
tabPane.getTabs().addAll(tabKuljetusTiedot, tabAsiakastiedot);
|
||||
|
||||
GridPane kuljetusTiedot = new GridPane();
|
||||
kuljetusTiedot.setPadding(new Insets(15));
|
||||
kuljetusTiedot.setHgap(10);
|
||||
kuljetusTiedot.setVgap(10);
|
||||
tabKuljetusTiedot.setContent(kuljetusTiedot);
|
||||
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), new Label("Määrät per kuljetus"));
|
||||
|
||||
Label salaatit = new Label("Salaatit");
|
||||
tfSalaatit = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), salaatit, tfSalaatit);
|
||||
|
||||
Label pääruoat = new Label("Pääruoat");
|
||||
tfPääruoat = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), pääruoat, tfPääruoat);
|
||||
|
||||
Label jälkiruoat = new Label("Jälkiruoat");
|
||||
tfJälkiruoat = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), jälkiruoat, tfJälkiruoat);
|
||||
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), new Label("Kuljetukset per päivä"));
|
||||
|
||||
Label maanantai = new Label("Maanantai");
|
||||
tfMaanantai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), maanantai, tfMaanantai);
|
||||
|
||||
Label tiistai = new Label("Tiistai");
|
||||
tfTiistai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), tiistai, tfTiistai);
|
||||
|
||||
Label keskiviikko = new Label("Keskiviikko");
|
||||
tfKeskiviikko = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), keskiviikko, tfKeskiviikko);
|
||||
|
||||
Label torstai = new Label("Torstai");
|
||||
tfTorstai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), torstai, tfTorstai);
|
||||
|
||||
Label perjantai = new Label("Perjantai");
|
||||
tfPerjantai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), perjantai, tfPerjantai);
|
||||
|
||||
tfLauantai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), new Label("Lauantai"), tfLauantai);
|
||||
|
||||
tfSunnuntai = new IntegerSpinner();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), new Label("Sunnuntai"), tfSunnuntai);
|
||||
|
||||
Label ruokarajoitteet = new Label("Ruokarajoitteet");
|
||||
tfRuokarajoitteet = new TextField();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), ruokarajoitteet, tfRuokarajoitteet);
|
||||
|
||||
Label avainTieto = new Label("Avaintieto");
|
||||
tfAvainTieto = new TextField();
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), avainTieto, tfAvainTieto);
|
||||
|
||||
Label lisätiedot = new Label("Kuljetuksen lisätiedot");
|
||||
tfLisätiedot = new TextField();
|
||||
tfLisätiedot.setPromptText("Näkyy raporteilla");
|
||||
kuljetusTiedot.addRow(kuljetusTiedot.getRowCount(), lisätiedot, tfLisätiedot);
|
||||
|
||||
Tab tabAsiakasTiedot, tabLaskutusTiedot;
|
||||
tabAsiakasTiedot = new Tab("Asiakastiedot");
|
||||
tabLaskutusTiedot = new Tab("Laskutustiedot");
|
||||
tabPane.getTabs().addAll(tabAsiakasTiedot, tabLaskutusTiedot);
|
||||
for (Tab tab : tabPane.getTabs()) {
|
||||
tab.setClosable(false);
|
||||
tab.setStyle("-fx-font-size: 18px; -fx-font-weight: bold; -fx-font-family: Open Sans");
|
||||
}
|
||||
|
||||
GridPane asiakasTiedot = new GridPane();
|
||||
asiakasTiedot.setPadding(new Insets(15));
|
||||
asiakasTiedot.setHgap(10);
|
||||
asiakasTiedot.setVgap(10);
|
||||
tabAsiakastiedot.setContent(asiakasTiedot);
|
||||
tabAsiakasTiedot.setContent(asiakasTiedot);
|
||||
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), new Label("Vahvistetut kentät pakollisia"));
|
||||
|
||||
Label nimi = new Label("Asiakkaan etu- ja sukunimi");
|
||||
nimi.setStyle("-fx-font-weight: bold;");
|
||||
@@ -136,33 +75,89 @@ public class AsiakasIkkuna extends Stage {
|
||||
tfOsoite.setPromptText("Pakollinen tieto");
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), osoite, tfOsoite);
|
||||
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), new Label("Määrät per kuljetus"));
|
||||
|
||||
Label salaatit = new Label("Salaatit");
|
||||
tfSalaatit = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), salaatit, tfSalaatit);
|
||||
|
||||
Label pääruoat = new Label("Pääruoat");
|
||||
tfPääruoat = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), pääruoat, tfPääruoat);
|
||||
|
||||
Label jälkiruoat = new Label("Jälkiruoat");
|
||||
tfJälkiruoat = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), jälkiruoat, tfJälkiruoat);
|
||||
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), new Label("Kuljetukset per päivä"));
|
||||
|
||||
Label maanantai = new Label("Maanantai");
|
||||
tfMaanantai = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), maanantai, tfMaanantai);
|
||||
|
||||
Label tiistai = new Label("Tiistai");
|
||||
tfTiistai = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), tiistai, tfTiistai);
|
||||
|
||||
Label keskiviikko = new Label("Keskiviikko");
|
||||
tfKeskiviikko = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), keskiviikko, tfKeskiviikko);
|
||||
|
||||
Label torstai = new Label("Torstai");
|
||||
tfTorstai = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), torstai, tfTorstai);
|
||||
|
||||
Label perjantai = new Label("Perjantai");
|
||||
tfPerjantai = new IntegerSpinner();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), perjantai, tfPerjantai);
|
||||
|
||||
Label ruokarajoitteet = new Label("Ruokarajoitteet");
|
||||
tfRuokarajoitteet = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), ruokarajoitteet, tfRuokarajoitteet);
|
||||
|
||||
Label avainTieto = new Label("Avaintieto");
|
||||
tfAvainTieto = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), avainTieto, tfAvainTieto);
|
||||
|
||||
Label lisätiedot = new Label("Kuljetuksen lisätiedot");
|
||||
tfLisätiedot = new TextField();
|
||||
tfLisätiedot.setPromptText("Näkyy raporteilla");
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), lisätiedot, tfLisätiedot);
|
||||
|
||||
|
||||
GridPane laskutusTiedot = new GridPane();
|
||||
laskutusTiedot.setPadding(new Insets(15));
|
||||
laskutusTiedot.setHgap(10);
|
||||
laskutusTiedot.setVgap(10);
|
||||
tabLaskutusTiedot.setContent(laskutusTiedot);
|
||||
|
||||
Label yhteyshenkilönNimi = new Label("Yhteyshenkilön etu- ja sukunimi");
|
||||
tfYhteyshenkilönNimi = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönNimi, tfYhteyshenkilönNimi);
|
||||
laskutusTiedot.addRow(laskutusTiedot.getRowCount(), yhteyshenkilönNimi, tfYhteyshenkilönNimi);
|
||||
|
||||
Label laskutusOsoite = new Label("Laskutusosoite");
|
||||
tfLaskutusOsoite = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), laskutusOsoite, tfLaskutusOsoite);
|
||||
laskutusTiedot.addRow(laskutusTiedot.getRowCount(), laskutusOsoite, tfLaskutusOsoite);
|
||||
|
||||
Label yhteyshenkilönPuhelinnumero = new Label("Puhelinnumero");
|
||||
tfYhteyshenkilönPuhelinnumero = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönPuhelinnumero, tfYhteyshenkilönPuhelinnumero);
|
||||
laskutusTiedot.addRow(laskutusTiedot.getRowCount(), yhteyshenkilönPuhelinnumero, tfYhteyshenkilönPuhelinnumero);
|
||||
|
||||
Label yhteyshenkilönSähköposti = new Label("Sähköposti");
|
||||
tfYhteyshenkilönSähköposti = new TextField();
|
||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönSähköposti, tfYhteyshenkilönSähköposti);
|
||||
laskutusTiedot.addRow(laskutusTiedot.getRowCount(), yhteyshenkilönSähköposti, tfYhteyshenkilönSähköposti);
|
||||
|
||||
HBox napit = new HBox();
|
||||
Button peruuta = new Button("Peruuta");
|
||||
peruuta.setFont(TabPohja.BUTTON_FONT);
|
||||
peruuta.setFont(TabPohja.buttonFont);
|
||||
peruuta.setOnAction(_ -> this.close());
|
||||
Button tallenna = new Button("Tallenna");
|
||||
tallenna.setFont(TabPohja.BUTTON_FONT);
|
||||
tallenna.setFont(TabPohja.buttonFont);
|
||||
tallenna.setOnAction(_ -> tallenna());
|
||||
napit.getChildren().addAll(peruuta, tallenna);
|
||||
napit.setAlignment(Pos.CENTER_RIGHT);
|
||||
napit.setSpacing(10);
|
||||
napit.setPadding(TabPohja.INSETS);
|
||||
napit.setPadding(TabPohja.oletusInsets);
|
||||
|
||||
|
||||
VBox root = new VBox();
|
||||
@@ -190,8 +185,6 @@ public class AsiakasIkkuna extends Stage {
|
||||
tfKeskiviikko.getValueFactory().setValue(käsiteltäväAsiakas.getKeskiviikkoKpl());
|
||||
tfTorstai.getValueFactory().setValue(käsiteltäväAsiakas.getTorstaiKpl());
|
||||
tfPerjantai.getValueFactory().setValue(käsiteltäväAsiakas.getPerjantaiKpl());
|
||||
tfLauantai.getValueFactory().setValue(käsiteltäväAsiakas.getLauantaiKpl());
|
||||
tfSunnuntai.getValueFactory().setValue(käsiteltäväAsiakas.getSunnuntaiKpl());
|
||||
tfSalaatit.getValueFactory().setValue(käsiteltäväAsiakas.getSalaatit());
|
||||
tfPääruoat.getValueFactory().setValue(käsiteltäväAsiakas.getPääruoat());
|
||||
tfJälkiruoat.getValueFactory().setValue(käsiteltäväAsiakas.getJälkiruoat());
|
||||
@@ -225,8 +218,6 @@ public class AsiakasIkkuna extends Stage {
|
||||
käsiteltäväAsiakas.setKeskiviikkoKpl(tfKeskiviikko.getValue());
|
||||
käsiteltäväAsiakas.setTorstaiKpl(tfTorstai.getValue());
|
||||
käsiteltäväAsiakas.setPerjantaiKpl(tfPerjantai.getValue());
|
||||
käsiteltäväAsiakas.setLauantaiKpl(tfLauantai.getValue());
|
||||
käsiteltäväAsiakas.setSunnuntaiKpl(tfSunnuntai.getValue());
|
||||
käsiteltäväAsiakas.setSalaatit(tfSalaatit.getValue());
|
||||
käsiteltäväAsiakas.setPääruoat(tfPääruoat.getValue());
|
||||
käsiteltäväAsiakas.setJälkiruoat(tfJälkiruoat.getValue());
|
||||
@@ -255,14 +246,7 @@ public class AsiakasIkkuna extends Stage {
|
||||
}
|
||||
|
||||
if (läpi) {
|
||||
int viikonKuljetukset = käsiteltäväAsiakas.getMaanantaiKpl() +
|
||||
käsiteltäväAsiakas.getTiistaiKpl() +
|
||||
käsiteltäväAsiakas.getKeskiviikkoKpl() +
|
||||
käsiteltäväAsiakas.getTorstaiKpl() +
|
||||
käsiteltäväAsiakas.getPerjantaiKpl() +
|
||||
käsiteltäväAsiakas.getLauantaiKpl() +
|
||||
käsiteltäväAsiakas.getSunnuntaiKpl();
|
||||
|
||||
int viikonKuljetukset = käsiteltäväAsiakas.getMaanantaiKpl() + käsiteltäväAsiakas.getTiistaiKpl() + käsiteltäväAsiakas.getKeskiviikkoKpl() + käsiteltäväAsiakas.getTorstaiKpl() + käsiteltäväAsiakas.getPerjantaiKpl();
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Onnistuimme!");
|
||||
alert.setHeaderText("Asiakkaan tallentaminen onnistui!");
|
||||
+69
-80
@@ -1,10 +1,9 @@
|
||||
package fi.lpam.gui;
|
||||
package fi.lpam.ruokamanageri.gui;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.gui.elementit.FontLabel;
|
||||
import fi.lpam.gui.elementit.MaaraTableColumn;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import fi.lpam.ruokamanageri.Main;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.MaaraTableColumn;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Button;
|
||||
@@ -16,8 +15,10 @@ import javafx.scene.layout.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -27,9 +28,45 @@ public class Asiakashallinta extends TabPohja {
|
||||
final TableView<Asiakas> tvAsiakkaat = new TableView<>();
|
||||
|
||||
public Asiakashallinta() {
|
||||
super("Asiakashallinta");
|
||||
root.setTop(getYläpalkki());
|
||||
BorderPane root = new BorderPane();
|
||||
this.getChildren().add(root);
|
||||
root.setPadding(oletusInsets);
|
||||
|
||||
BorderPane yläpalkki = new BorderPane();
|
||||
root.setTop(yläpalkki);
|
||||
Label otsikko = new Label("Asiakashallinta");
|
||||
otsikko.setFont(tekstiFont);
|
||||
yläpalkki.setLeft(otsikko);
|
||||
|
||||
HBox yläpalkinNapit = new HBox();
|
||||
yläpalkinNapit.setSpacing(5);
|
||||
yläpalkki.setRight(yläpalkinNapit);
|
||||
|
||||
Button avaaVersioloki = new Button("Avaa muutosloki");
|
||||
avaaVersioloki.setFont(buttonFont);
|
||||
avaaVersioloki.setOnAction(_ -> {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://git.lpam.fi/laurimaaninka/Ruokamanageri/src/branch/master/CHANGELOG.md"));
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
});
|
||||
yläpalkinNapit.getChildren().add(avaaVersioloki);
|
||||
|
||||
Button poistaValittu = new Button("Poista");
|
||||
poistaValittu.setOnAction(_ -> poistaValittu());
|
||||
poistaValittu.setFont(buttonFont);
|
||||
yläpalkinNapit.getChildren().add(poistaValittu);
|
||||
|
||||
Button muokkaaAsiakasta = new Button("Muokkaa");
|
||||
muokkaaAsiakasta.setOnAction(_ -> muokkaaValittua());
|
||||
muokkaaAsiakasta.setFont(buttonFont);
|
||||
yläpalkinNapit.getChildren().add(muokkaaAsiakasta);
|
||||
|
||||
Button uusiAsiakas = new Button("Uusi asiakas");
|
||||
uusiAsiakas.setOnAction(_ -> uusiAsiakas());
|
||||
uusiAsiakas.setFont(buttonFont);
|
||||
yläpalkinNapit.getChildren().add(uusiAsiakas);
|
||||
|
||||
tvAsiakkaat.setEditable(false);
|
||||
tvAsiakkaat.setPlaceholder(new Label("Ei vielä tietoja"));
|
||||
@@ -48,107 +85,70 @@ public class Asiakashallinta extends TabPohja {
|
||||
});
|
||||
root.setCenter(tvAsiakkaat);
|
||||
|
||||
TableColumn<Asiakas, String> tcId = new TableColumn<>("Id");
|
||||
tcId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
TableColumn<Asiakas, String> tcNimi = new TableColumn<>("Nimi");
|
||||
tcNimi.setMinWidth(180);
|
||||
tcNimi.setCellValueFactory(new PropertyValueFactory<>("nimi"));
|
||||
TableColumn<Asiakas, String> tcOsoite = new TableColumn<>("Osoite");
|
||||
tcOsoite.setMinWidth(250);
|
||||
tcOsoite.setCellValueFactory(new PropertyValueFactory<>("osoite"));
|
||||
|
||||
int minWidth = 40;
|
||||
TableColumn<Asiakas, MaaraTableColumn<Asiakas, Integer>> tcKuljetuspäivät = new TableColumn<>("Kuljetukset per päivä");
|
||||
MaaraTableColumn<Asiakas, Integer> tcMaanantaiKpl = new MaaraTableColumn<>("MA", minWidth);
|
||||
MaaraTableColumn<Asiakas, Integer> tcMaanantaiKpl = new MaaraTableColumn<>("MA", 20);
|
||||
tcMaanantaiKpl.setCellValueFactory(new PropertyValueFactory<>("maanantaiKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcTiistaiKpl = new MaaraTableColumn<>("TI", minWidth);
|
||||
MaaraTableColumn<Asiakas, Integer> tcTiistaiKpl = new MaaraTableColumn<>("TI", 20);
|
||||
tcTiistaiKpl.setCellValueFactory(new PropertyValueFactory<>("tiistaiKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcKeskiviikkoKpl = new MaaraTableColumn<>("KE", minWidth);
|
||||
MaaraTableColumn<Asiakas, Integer> tcKeskiviikkoKpl = new MaaraTableColumn<>("KE", 20);
|
||||
tcKeskiviikkoKpl.setCellValueFactory(new PropertyValueFactory<>("keskiviikkoKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcTorstaiKpl = new MaaraTableColumn<>("TO", minWidth);
|
||||
MaaraTableColumn<Asiakas, Integer> tcTorstaiKpl = new MaaraTableColumn<>("TO", 20);
|
||||
tcTorstaiKpl.setCellValueFactory(new PropertyValueFactory<>("torstaiKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcPerjantaiKpl = new MaaraTableColumn<>("PE", minWidth);
|
||||
MaaraTableColumn<Asiakas, Integer> tcPerjantaiKpl = new MaaraTableColumn<>("PE", 20);
|
||||
tcPerjantaiKpl.setCellValueFactory(new PropertyValueFactory<>("perjantaiKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcLauantaiKpl = new MaaraTableColumn<>("LA", minWidth);
|
||||
tcLauantaiKpl.setCellValueFactory(new PropertyValueFactory<>("lauantaiKpl"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcSunnuntaiKpl = new MaaraTableColumn<>("SU", minWidth);
|
||||
tcSunnuntaiKpl.setCellValueFactory(new PropertyValueFactory<>("sunnuntaiKpl"));
|
||||
tcKuljetuspäivät.getColumns().addAll(tcMaanantaiKpl, tcTiistaiKpl, tcKeskiviikkoKpl, tcTorstaiKpl, tcPerjantaiKpl, tcLauantaiKpl, tcSunnuntaiKpl);
|
||||
tcKuljetuspäivät.getColumns().addAll(tcMaanantaiKpl, tcTiistaiKpl, tcKeskiviikkoKpl, tcTorstaiKpl, tcPerjantaiKpl);
|
||||
|
||||
TableColumn<Asiakas, MaaraTableColumn<Asiakas, Integer>> tcKuljetusmäärät = new TableColumn<>("Määrät per kuljetus");
|
||||
MaaraTableColumn<Asiakas, Integer> tcSalaatit = new MaaraTableColumn<>("Salaatit", minWidth, 150);
|
||||
MaaraTableColumn<Asiakas, Integer> tcSalaatit = new MaaraTableColumn<>("Salaatit", 90);
|
||||
tcSalaatit.setCellValueFactory(new PropertyValueFactory<>("salaatit"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcPääruoat = new MaaraTableColumn<>("Pääruoat", minWidth, 150);
|
||||
MaaraTableColumn<Asiakas, Integer> tcPääruoat = new MaaraTableColumn<>("Pääruoat", 90);
|
||||
tcPääruoat.setCellValueFactory(new PropertyValueFactory<>("pääruoat"));
|
||||
MaaraTableColumn<Asiakas, Integer> tcJälkiruoat = new MaaraTableColumn<>("Jälkiruoat", minWidth, 150);
|
||||
MaaraTableColumn<Asiakas, Integer> tcJälkiruoat = new MaaraTableColumn<>("Jälkiruoat", 90);
|
||||
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
||||
tcKuljetusmäärät.getColumns().addAll(tcSalaatit, tcPääruoat, tcJälkiruoat);
|
||||
|
||||
TableColumn<Asiakas, String> tcErityisruokavalio = new TableColumn<>("Ruokarajoitteet");
|
||||
tcErityisruokavalio.setMinWidth(150);
|
||||
tcErityisruokavalio.setCellValueFactory(new PropertyValueFactory<>("erityisruokavalio"));
|
||||
TableColumn<Asiakas, String> tcAvainTieto = new TableColumn<>("Avaintieto");
|
||||
tcAvainTieto.setMinWidth(150);
|
||||
tcAvainTieto.setCellValueFactory(new PropertyValueFactory<>("avainTieto"));
|
||||
TableColumn<Asiakas, String> tcLisätiedot = new TableColumn<>("Lisätieto kuljetukselle");
|
||||
tcLisätiedot.setMinWidth(250);
|
||||
tcLisätiedot.setCellValueFactory(new PropertyValueFactory<>("lisätiedot"));
|
||||
TableColumn<Asiakas, String> tcYhteyshenkilönNimi = new TableColumn<>("Yhteyshenkilö");
|
||||
tcYhteyshenkilönNimi.setMinWidth(250);
|
||||
tcYhteyshenkilönNimi.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönNimi"));
|
||||
TableColumn<Asiakas, String> tcLaskutusOsoite = new TableColumn<>("Laskutusosoite");
|
||||
tcLaskutusOsoite.setMinWidth(250);
|
||||
tcLaskutusOsoite.setCellValueFactory(new PropertyValueFactory<>("laskutusOsoite"));
|
||||
TableColumn<Asiakas, String> tcYhteyshenkilönPuhelinnumero = new TableColumn<>("Yhteyshenkilön puhelinnumero");
|
||||
tcYhteyshenkilönPuhelinnumero.setMinWidth(250);
|
||||
tcYhteyshenkilönPuhelinnumero.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönPuhelinnumero"));
|
||||
TableColumn<Asiakas, String> tcYhteyshenkilönSähköposti = new TableColumn<>("Yhteyshenkilön sähköposti");
|
||||
tcYhteyshenkilönSähköposti.setMinWidth(250);
|
||||
tcYhteyshenkilönSähköposti.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönSähköposti"));
|
||||
|
||||
tvAsiakkaat.getColumns().addAll(tcId, tcNimi, tcOsoite, tcKuljetuspäivät, tcKuljetusmäärät, tcErityisruokavalio, tcAvainTieto, tcLisätiedot, tcYhteyshenkilönNimi, tcLaskutusOsoite, tcYhteyshenkilönPuhelinnumero, tcYhteyshenkilönSähköposti);
|
||||
tvAsiakkaat.getColumns().addAll(tcNimi, tcOsoite, tcKuljetuspäivät, tcKuljetusmäärät, tcErityisruokavalio, tcAvainTieto, tcLisätiedot, tcYhteyshenkilönNimi, tcLaskutusOsoite, tcYhteyshenkilönPuhelinnumero, tcYhteyshenkilönSähköposti);
|
||||
|
||||
for (TableColumn<Asiakas, ?> column : tvAsiakkaat.getColumns()) {
|
||||
column.getColumns().forEach(this::määritäColumn);
|
||||
määritäColumn(column);
|
||||
column.setEditable(false);
|
||||
column.setReorderable(false);
|
||||
column.setResizable(false);
|
||||
column.setStyle("-fx-alignment: CENTER; -fx-font-size: 16px;");
|
||||
|
||||
}
|
||||
|
||||
tvAsiakkaat.setItems(FXCollections.observableArrayList(Objects.requireNonNull(Asiakas.haeKaikki())));
|
||||
//tvAsiakkaat.setPrefSize(1920, 1080); //Tämä estää oudon bugin? (asiakkaiden ollessa 31 TV sekoaa)
|
||||
}
|
||||
|
||||
private BorderPane getYläpalkki() {
|
||||
BorderPane yläpalkki = new BorderPane();
|
||||
Label otsikko = new FontLabel(TEKSTI_FONT, "Asiakashallinta");
|
||||
yläpalkki.setLeft(otsikko);
|
||||
|
||||
HBox yläpalkinNapit = new HBox();
|
||||
yläpalkinNapit.setSpacing(SPACING);
|
||||
yläpalkinNapit.setPadding(INSETS);
|
||||
yläpalkki.setRight(yläpalkinNapit);
|
||||
|
||||
Button avaaVersioloki = new Button("VERSIOLOKI");
|
||||
avaaVersioloki.setFont(BUTTON_FONT);
|
||||
avaaVersioloki.setOnAction(_ -> {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://git.lpam.fi/laurimaaninka/Ruokamanageri/src/branch/master/CHANGELOG.md"));
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
});
|
||||
yläpalkinNapit.getChildren().add(avaaVersioloki);
|
||||
|
||||
Button poistaValittu = new Button("Poista");
|
||||
poistaValittu.setOnAction(_ -> poistaValittu());
|
||||
poistaValittu.setFont(BUTTON_FONT);
|
||||
yläpalkinNapit.getChildren().add(poistaValittu);
|
||||
|
||||
Button muokkaaAsiakasta = new Button("Muokkaa");
|
||||
muokkaaAsiakasta.setOnAction(_ -> muokkaaValittua());
|
||||
muokkaaAsiakasta.setFont(BUTTON_FONT);
|
||||
yläpalkinNapit.getChildren().add(muokkaaAsiakasta);
|
||||
|
||||
Button uusiAsiakas = new Button("Uusi asiakas");
|
||||
uusiAsiakas.setOnAction(_ -> uusiAsiakas());
|
||||
uusiAsiakas.setFont(BUTTON_FONT);
|
||||
yläpalkinNapit.getChildren().add(uusiAsiakas);
|
||||
|
||||
return yläpalkki;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void uusiAsiakas() {
|
||||
Asiakas luotavaAsiakas = new Asiakas();
|
||||
AsiakasIkkuna asiakasIkkuna = new AsiakasIkkuna(luotavaAsiakas);
|
||||
@@ -186,15 +186,4 @@ public class Asiakashallinta extends TabPohja {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void määritäColumn(TableColumn<Asiakas, ?> column) {
|
||||
column.setEditable(false);
|
||||
column.setReorderable(false);
|
||||
column.setResizable(true);
|
||||
column.setStyle(
|
||||
"-fx-alignment: CENTER;" +
|
||||
"-fx-font-size: " + Main.properties.getProperty("tekstiFonttiKoko") + "px;" +
|
||||
"-fx-font-family: " + Main.properties.getProperty("tekstiFontti")
|
||||
);
|
||||
}
|
||||
}
|
||||
+29
-33
@@ -1,12 +1,11 @@
|
||||
package fi.lpam.gui;
|
||||
package fi.lpam.ruokamanageri.gui;
|
||||
|
||||
import com.dlsc.gemsfx.MultiColumnListView;
|
||||
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.dataluokat.Kierros;
|
||||
import fi.lpam.gui.elementit.AsiakasMCLVListCell;
|
||||
import fi.lpam.gui.elementit.FontLabel;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Kierros;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.AsiakasListCell;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
@@ -23,13 +22,15 @@ import java.util.Objects;
|
||||
public class Kierroshallinta extends TabPohja {
|
||||
private final MultiColumnListView<Asiakas> mclv = new MultiColumnListView<>();
|
||||
private final ArrayList<Kierros> kierrokset = Kierros.haeKaikki();
|
||||
private ArrayList<Asiakas> kaikkiAsiakkaat = Asiakas.haeKaikki();
|
||||
private final ArrayList<Asiakas> kaikkiAsiakkaat = Asiakas.haeKaikki();
|
||||
|
||||
public Kierroshallinta() {
|
||||
super("Kierroshallinta");
|
||||
BorderPane root = new BorderPane();
|
||||
this.getChildren().add(root);
|
||||
root.setPadding(oletusInsets);
|
||||
root.setCenter(mclv);
|
||||
|
||||
mclv.setCellFactory(_ -> new AsiakasMCLVListCell(mclv));
|
||||
mclv.setCellFactory(_ -> new AsiakasListCell(mclv));
|
||||
mclv.setPlaceholderFrom(new Asiakas(""));
|
||||
mclv.setPlaceholderTo(new Asiakas(""));
|
||||
rakennaSarakkeet();
|
||||
@@ -37,7 +38,8 @@ public class Kierroshallinta extends TabPohja {
|
||||
BorderPane yläpalkki = new BorderPane();
|
||||
root.setTop(yläpalkki);
|
||||
|
||||
Label infoTeksti = new FontLabel(TEKSTI_FONT, "Siirrä asiakkaat haluamallesi kierrokselle. Kierroksia voit lisätä painamalla lisää uusi kierros painiketta.\nKierrosnumerot päivittyvät, sekä tyhjät poistuvat kierroksia tallentaessa.");
|
||||
Label infoTeksti = new Label("Siirrä asiakkaat haluamallesi kierrokselle. Kierroksia voit lisätä painamalla lisää uusi kierros painiketta.\nKierrosnumerot päivittyvät, sekä tyhjät poistuvat kierroksia tallentaessa.");
|
||||
infoTeksti.setFont(tekstiFont);
|
||||
yläpalkki.setLeft(infoTeksti);
|
||||
|
||||
HBox yläpalkinNapit = new HBox();
|
||||
@@ -45,15 +47,12 @@ public class Kierroshallinta extends TabPohja {
|
||||
yläpalkki.setRight(yläpalkinNapit);
|
||||
|
||||
Button lisääKierros = new Button("Lisää uusi kierros");
|
||||
lisääKierros.setOnAction(_ -> {
|
||||
int uudenKierroksenNumero = mclv.getColumns().size();
|
||||
lisaaKierros(new Kierros(uudenKierroksenNumero, FXCollections.observableArrayList(new ArrayList<>())));
|
||||
});
|
||||
lisääKierros.setFont(BUTTON_FONT);
|
||||
lisääKierros.setOnAction(_ -> lisaaKierros());
|
||||
lisääKierros.setFont(TabPohja.buttonFont);
|
||||
yläpalkinNapit.getChildren().add(lisääKierros);
|
||||
|
||||
Button tallenna = new Button("Tallenna kierrokset");
|
||||
tallenna.setFont(BUTTON_FONT);
|
||||
tallenna.setFont(TabPohja.buttonFont);
|
||||
tallenna.setOnAction(_ ->tallennaKierrokset());
|
||||
yläpalkinNapit.getChildren().add(tallenna);
|
||||
|
||||
@@ -64,16 +63,18 @@ public class Kierroshallinta extends TabPohja {
|
||||
|
||||
private void rakennaSarakkeet() {
|
||||
mclv.getColumns().clear();
|
||||
kaikkiAsiakkaat = Asiakas.haeKaikki();
|
||||
ObservableList<Asiakas> eiKierroksella = FXCollections.observableArrayList(new ArrayList<>());
|
||||
HashSet<Integer> kierroksellaOlevatAsiakasIDt = new HashSet<>();
|
||||
|
||||
if (!kierrokset.isEmpty()) {
|
||||
for (Kierros kierros : kierrokset) {
|
||||
lisaaKierros(kierros);
|
||||
for (Asiakas asiakas : kierros.getAsiakkaat()) {
|
||||
for (Kierros k : kierrokset) {
|
||||
MultiColumnListView.ListViewColumn<Asiakas> sarake = new MultiColumnListView.ListViewColumn<>();
|
||||
sarake.setHeader(new Label("Kierros " + k.getKierrosNumero()));
|
||||
sarake.setItems(k.getAsiakkaat());
|
||||
for (Asiakas asiakas : k.getAsiakkaat()) {
|
||||
kierroksellaOlevatAsiakasIDt.add(asiakas.getId());
|
||||
}
|
||||
mclv.getColumns().add(sarake);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,18 +84,19 @@ public class Kierroshallinta extends TabPohja {
|
||||
}
|
||||
}
|
||||
MultiColumnListView.ListViewColumn<Asiakas> colEiKierroksella = new MultiColumnListView.ListViewColumn<>();
|
||||
Label labelEiKierroksella = new FontLabel(TEKSTI_FONT, "Ei vielä kierroksella");
|
||||
colEiKierroksella.setHeader(labelEiKierroksella);
|
||||
colEiKierroksella.setHeader(new Label("Ei vielä kierroksella"));
|
||||
colEiKierroksella.setItems(FXCollections.observableArrayList(eiKierroksella));
|
||||
mclv.getColumns().add(colEiKierroksella);
|
||||
}
|
||||
|
||||
private void lisaaKierros(Kierros kierros) {
|
||||
if (kierros.getId() == -1) kierrokset.add(kierros);
|
||||
private void lisaaKierros() {
|
||||
int uudenKierroksenNumero = mclv.getColumns().size();
|
||||
Kierros lisättäväKierros = new Kierros(uudenKierroksenNumero, FXCollections.observableArrayList(new ArrayList<>()));
|
||||
kierrokset.add(lisättäväKierros);
|
||||
MultiColumnListView.ListViewColumn<Asiakas> uusiSarake = new MultiColumnListView.ListViewColumn<>();
|
||||
uusiSarake.setHeader(new FontLabel(TEKSTI_FONT, "Kierros " + kierros.getKierrosNumero()));
|
||||
uusiSarake.setItems(kierros.getAsiakkaat());
|
||||
mclv.getColumns().add(kierros.getKierrosNumero()-1, uusiSarake);
|
||||
uusiSarake.setHeader(new Label("Kierros " + uudenKierroksenNumero));
|
||||
uusiSarake.setItems(lisättäväKierros.getAsiakkaat());
|
||||
mclv.getColumns().add(uudenKierroksenNumero-1, uusiSarake);
|
||||
}
|
||||
|
||||
private void tallennaKierrokset() {
|
||||
@@ -102,7 +104,6 @@ public class Kierroshallinta extends TabPohja {
|
||||
int index = 0;
|
||||
for (int i = 0; i < kierrokset.size();) {
|
||||
Kierros k = kierrokset.get(i);
|
||||
k.setAsiakkaat(FXCollections.observableArrayList(new ArrayList<>()));
|
||||
k.setAsiakkaat(mclv.getColumns().get(index).getItems());
|
||||
index++;
|
||||
|
||||
@@ -125,9 +126,4 @@ public class Kierroshallinta extends TabPohja {
|
||||
info.setContentText(null);
|
||||
info.showAndWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void päivitä() {
|
||||
rakennaSarakkeet();
|
||||
}
|
||||
}
|
||||
+31
-38
@@ -1,21 +1,19 @@
|
||||
package fi.lpam.gui;
|
||||
package fi.lpam.ruokamanageri.gui;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.dataluokat.Kierros;
|
||||
import fi.lpam.dataluokat.Kuljetus;
|
||||
import fi.lpam.gui.elementit.FontLabel;
|
||||
import fi.lpam.gui.tableCell.IntegerFieldTableCellFactory;
|
||||
import fi.lpam.gui.tableCell.KuljetaTableCell;
|
||||
import fi.lpam.tulostajat.KuljetusListaTulostaja;
|
||||
import fi.lpam.gui.elementit.MaaraTableColumn;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Kierros;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.KuljetaTableCell;
|
||||
import fi.lpam.ruokamanageri.tulostajat.KuljetusListaTulostaja;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.MaaraTableColumn;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.ChoiceBoxTableCell;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
@@ -38,8 +36,6 @@ public class KuljetusListat extends TabPohja {
|
||||
private final HashMap<Integer, Asiakas> asiakkaat = new HashMap<>();
|
||||
|
||||
public KuljetusListat() {
|
||||
super("Kuljetuslistat");
|
||||
|
||||
ObservableList<Integer> määräVaihtoehdot = FXCollections.observableArrayList();
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
määräVaihtoehdot.add(i);}
|
||||
@@ -48,45 +44,51 @@ public class KuljetusListat extends TabPohja {
|
||||
asiakkaat.put(asiakas.getId(), asiakas);
|
||||
}
|
||||
|
||||
BorderPane root = new BorderPane();
|
||||
root.setPadding(oletusInsets);
|
||||
this.getChildren().add(root);
|
||||
|
||||
BorderPane yläpalkki = new BorderPane();
|
||||
Label infoTeksti = new FontLabel(TEKSTI_FONT, "Kuljetuslistojen luonti");
|
||||
Label infoTeksti = new Label("Kuljetuslistojen luonti");
|
||||
infoTeksti.setFont(tekstiFont);
|
||||
yläpalkki.setLeft(infoTeksti);
|
||||
|
||||
HBox kierroksenValintaLaatikko = new HBox();
|
||||
kierroksenValintaLaatikko.setSpacing(SPACING);
|
||||
kierroksenValintaLaatikko.setSpacing(5);
|
||||
kierroksenValintaLaatikko.setSpacing(5);
|
||||
kierroksenValintaLaatikko.setAlignment(Pos.CENTER);
|
||||
Button valitse = new Button("Valitse");
|
||||
valitse.setFont(BUTTON_FONT);
|
||||
valitse.setFont(buttonFont);
|
||||
valitse.setOnAction(_ -> päivitäListanäkymä());
|
||||
tallennusStatus = new FontLabel(TEKSTI_FONT, "Tallennettu: Kyllä");
|
||||
tallennusStatus.setFont(TEKSTI_FONT);
|
||||
tallennusStatus = new Label("Tallennettu: Kyllä");
|
||||
tallennusStatus.setFont(tekstiFont);
|
||||
datePicker.valueProperty().addListener(_ -> päivitäListanäkymä());
|
||||
kierrosValinta.valueProperty().addListener(_ -> päivitäListanäkymä());
|
||||
kierroksenValintaLaatikko.getChildren().addAll(
|
||||
new FontLabel(TEKSTI_FONT, "Päivämäärä:"),
|
||||
new Label("Valitse päivämäärä:"),
|
||||
datePicker,
|
||||
new FontLabel(TEKSTI_FONT, "Kierros:"),
|
||||
new Label("Valitse kierros:"),
|
||||
kierrosValinta, tallennusStatus);
|
||||
yläpalkki.setCenter(kierroksenValintaLaatikko);
|
||||
|
||||
HBox napit = new HBox();
|
||||
napit.setSpacing(SPACING);
|
||||
napit.setSpacing(5);
|
||||
Button poista = new Button("Poista kuljetusrivi");
|
||||
poista.setOnAction(_ ->poistaRivi());
|
||||
poista.setFont(BUTTON_FONT);
|
||||
poista.setFont(buttonFont);
|
||||
Button tallenna = new Button("Tallenna");
|
||||
tallenna.setFont(BUTTON_FONT);
|
||||
tallenna.setFont(buttonFont);
|
||||
tallenna.setOnAction(_ -> tallennaKierros());
|
||||
btnTulosta = new Button("Tulosta lista");
|
||||
btnTulosta.setDisable(true);
|
||||
btnTulosta.setFont(BUTTON_FONT);
|
||||
btnTulosta.setFont(buttonFont);
|
||||
btnTulosta.setOnAction(_ ->tulostaLista());
|
||||
napit.getChildren().addAll(poista, tallenna, btnTulosta);
|
||||
yläpalkki.setRight(napit);
|
||||
root.setTop(yläpalkki);
|
||||
|
||||
tableView.setEditable(true);
|
||||
tableView.setPlaceholder(new FontLabel(BUTTON_FONT, "Valitse kierros aloittaaksesi"));
|
||||
tableView.setPlaceholder(new Label("Valitse kierros aloittaaksesi"));
|
||||
root.setCenter(tableView);
|
||||
|
||||
TableColumn<Kuljetus, Boolean> tcNappi = new TableColumn<>("Kuljeta");
|
||||
@@ -107,17 +109,17 @@ public class KuljetusListat extends TabPohja {
|
||||
tcOsoite.setOnEditCommit((TableColumn.CellEditEvent<Kuljetus, String> event) -> {event.getTableView().getItems().get(event.getTablePosition().getRow()).setOsoite(event.getNewValue()); tallennusStatus.setText("Tallennettu: Ei");});
|
||||
|
||||
TableColumn<Kuljetus, Integer> tcSalaatit = new MaaraTableColumn<>("Salaatit", 100);
|
||||
tcSalaatit.setCellFactory(new IntegerFieldTableCellFactory<>());
|
||||
tcSalaatit.setCellFactory(ChoiceBoxTableCell.forTableColumn(määräVaihtoehdot));
|
||||
tcSalaatit.setCellValueFactory(new PropertyValueFactory<>("salaatit"));
|
||||
tcSalaatit.setOnEditCommit((TableColumn.CellEditEvent<Kuljetus, Integer> event) -> {event.getTableView().getItems().get(event.getTablePosition().getRow()).setSalaatit(event.getNewValue()); tallennusStatus.setText("Tallennettu: Ei");});
|
||||
|
||||
TableColumn<Kuljetus, Integer> tcPääruoat = new MaaraTableColumn<>("Pääruoat", 100);
|
||||
tcPääruoat.setCellFactory(new IntegerFieldTableCellFactory<>());
|
||||
tcPääruoat.setCellFactory(ChoiceBoxTableCell.forTableColumn(määräVaihtoehdot));
|
||||
tcPääruoat.setCellValueFactory(new PropertyValueFactory<>("pääruoat"));
|
||||
tcPääruoat.setOnEditCommit((TableColumn.CellEditEvent<Kuljetus, Integer> event) -> {event.getTableView().getItems().get(event.getTablePosition().getRow()).setPääruoat(event.getNewValue()); tallennusStatus.setText("Tallennettu: Ei");});
|
||||
|
||||
TableColumn<Kuljetus, Integer> tcJälkiruoat = new MaaraTableColumn<>("Jälkiruoat", 100);
|
||||
tcJälkiruoat.setCellFactory(new IntegerFieldTableCellFactory<>());
|
||||
tcJälkiruoat.setCellFactory(ChoiceBoxTableCell.forTableColumn(määräVaihtoehdot));
|
||||
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
||||
tcJälkiruoat.setOnEditCommit((TableColumn.CellEditEvent<Kuljetus, Integer> event) -> {event.getTableView().getItems().get(event.getTablePosition().getRow()).setJälkiruoat(event.getNewValue()); tallennusStatus.setText("Tallennettu: Ei");});
|
||||
|
||||
@@ -145,10 +147,7 @@ public class KuljetusListat extends TabPohja {
|
||||
sarake.setSortable(false);
|
||||
sarake.setEditable(true);
|
||||
sarake.setResizable(true);
|
||||
sarake.setStyle(
|
||||
"-fx-alignment: CENTER;" +
|
||||
"-fx-font-size: " + Main.properties.getProperty("tekstiFonttiKoko") + "px;" +
|
||||
"-fx-font-family: " + Main.properties.getProperty("tekstiFontti"));
|
||||
sarake.setStyle("-fx-alignment: CENTER; -fx-font-size: 16px;");
|
||||
}
|
||||
tcNimi.setEditable(false);
|
||||
tcNimi.setResizable(false);
|
||||
@@ -218,10 +217,4 @@ public class KuljetusListat extends TabPohja {
|
||||
private void tulostaLista() {
|
||||
new KuljetusListaTulostaja().luoKuljetusLista(tableView.getItems(), kierrosValinta.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void päivitä() {
|
||||
if (kierrosValinta.getValue() == null) return;
|
||||
päivitäListanäkymä();
|
||||
}
|
||||
}
|
||||
+17
-23
@@ -1,11 +1,9 @@
|
||||
package fi.lpam.gui;
|
||||
package fi.lpam.ruokamanageri.gui;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.dataluokat.RaporttiRivi;
|
||||
import fi.lpam.gui.elementit.FontLabel;
|
||||
import fi.lpam.tulostajat.KuljetusRaporttiTulostaja;
|
||||
import fi.lpam.gui.tableCell.PaivamaaraTableCell;
|
||||
import fi.lpam.gui.elementit.TabPohja;
|
||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
||||
import fi.lpam.ruokamanageri.tulostajat.KuljetusRaporttiTulostaja;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.PaivamaaraTableCell;
|
||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
@@ -36,32 +34,34 @@ public class KuljetusRaportit extends TabPohja {
|
||||
}
|
||||
|
||||
public KuljetusRaportit() {
|
||||
super("Raportit");
|
||||
BorderPane root = new BorderPane();
|
||||
root.setPadding(oletusInsets);
|
||||
this.getChildren().add(root);
|
||||
|
||||
BorderPane yläpalkki = new BorderPane();
|
||||
root.setTop(yläpalkki);
|
||||
|
||||
Label infoTeksti = new FontLabel(TEKSTI_FONT, "Kuljetusraportit. \nTarkka-valinnalla koostetun raportin \ntulostaminen paperille ei suositeltua.");
|
||||
Label infoTeksti = new Label("Kuljetusraportit. \nTarkka-valinnalla koostetun raportin tulostaminen paperille ei suositeltua.");
|
||||
infoTeksti.setFont(tekstiFont);
|
||||
yläpalkki.setLeft(infoTeksti);
|
||||
|
||||
HBox yläpalkinNapit = new HBox();
|
||||
yläpalkinNapit.setAlignment(Pos.CENTER);
|
||||
yläpalkinNapit.setSpacing(SPACING);
|
||||
yläpalkinNapit.setSpacing(5);
|
||||
yläpalkki.setRight(yläpalkinNapit);
|
||||
|
||||
tarkka = new CheckBox("Tarkka");
|
||||
tarkka.setFont(TEKSTI_FONT);
|
||||
alkuPvm = new DatePicker(LocalDate.now().minusDays(LocalDate.now().getDayOfMonth() - 1));
|
||||
loppuPvm = new DatePicker(LocalDate.now());
|
||||
Button haeKuljetukset = new Button("Hae");
|
||||
haeKuljetukset.setFont(BUTTON_FONT);
|
||||
haeKuljetukset.setFont(buttonFont);
|
||||
haeKuljetukset.setOnAction(_ ->haeRaportti());
|
||||
Button tulostaRaportti = new Button("Tulosta raportti");
|
||||
tulostaRaportti.setFont(BUTTON_FONT);
|
||||
tulostaRaportti.setFont(buttonFont);
|
||||
tulostaRaportti.setOnAction(_ ->tulostaRaportti());
|
||||
yläpalkinNapit.getChildren().addAll(tarkka,
|
||||
//new FontLabel(tekstiFont,"Hae kuljetukset välillä:"),
|
||||
alkuPvm, new FontLabel(TEKSTI_FONT,"-"), loppuPvm,
|
||||
new Label("Hae kuljetukset välillä:"),
|
||||
alkuPvm, new Label("-"), loppuPvm,
|
||||
haeKuljetukset, tulostaRaportti);
|
||||
|
||||
root.setCenter(tableView);
|
||||
@@ -109,18 +109,12 @@ public class KuljetusRaportit extends TabPohja {
|
||||
|
||||
tableView.getColumns().addAll(tcNimi, tcPvm, tcSalaatit, tcPääruoat, tcJälkiruoat, tcLisätiedot,
|
||||
tcYhteyshenkilönNimi, tcLaskutusOsoite, tcYhteyshenkilönPuhelinnumero, tcYhteyshenkilönSähköposti);
|
||||
tableView.setPlaceholder(new FontLabel(BUTTON_FONT, "Hae raportti"));
|
||||
tableView.setPlaceholder(new Label("Hae raportti"));
|
||||
for (TableColumn<RaporttiRivi, ?> sarake : tableView.getColumns()) {
|
||||
sarake.setSortable(false);
|
||||
sarake.setEditable(false);
|
||||
sarake.setResizable(true);
|
||||
sarake.setStyle(
|
||||
"-fx-alignment: CENTER;" +
|
||||
"-fx-font-size: " + Main.properties.getProperty("tekstiFonttiKoko") + "px;" +
|
||||
"-fx-font-family: " + Main.properties.getProperty("tekstiFontti"));
|
||||
sarake.setStyle("-fx-alignment: CENTER; -fx-font-size: 16px;");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void päivitä() {}
|
||||
}
|
||||
+9
-10
@@ -1,10 +1,9 @@
|
||||
package fi.lpam.gui.elementit;
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import com.dlsc.gemsfx.MultiColumnListView;
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
import javafx.scene.control.Label;
|
||||
@@ -12,13 +11,15 @@ import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
|
||||
public class AsiakasMCLVListCell extends MultiColumnListView.ColumnListCell<Asiakas> {
|
||||
public class AsiakasListCell extends MultiColumnListView.ColumnListCell<Asiakas> {
|
||||
private final StackPane wrapper;
|
||||
|
||||
public AsiakasMCLVListCell(MultiColumnListView<Asiakas> multiColumnListView) {
|
||||
public AsiakasListCell(MultiColumnListView multiColumnListView) {
|
||||
//noinspection unchecked
|
||||
super(multiColumnListView);
|
||||
this.setMinHeight(TabPohja.TEKSTI_FONT.getSize()*4);
|
||||
this.setMaxHeight(TabPohja.TEKSTI_FONT.getSize()*4);
|
||||
this.setHeight(150);
|
||||
this.setPrefHeight(50);
|
||||
|
||||
|
||||
VBox content = new VBox();
|
||||
content.visibleProperty().bind(placeholder.not().and(emptyProperty().not()));
|
||||
@@ -29,11 +30,9 @@ public class AsiakasMCLVListCell extends MultiColumnListView.ColumnListCell<Asia
|
||||
contentPlaceholder.managedProperty().bind(placeholder);
|
||||
|
||||
Label label = new Label();
|
||||
label.setFont(TabPohja.TEKSTI_FONT);
|
||||
label.textProperty().bind(textProperty());
|
||||
|
||||
wrapper = new StackPane(content, contentPlaceholder, label);
|
||||
wrapper.setAlignment(Pos.CENTER_LEFT);
|
||||
setGraphic(wrapper);
|
||||
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
|
||||
}
|
||||
@@ -60,7 +59,7 @@ public class AsiakasMCLVListCell extends MultiColumnListView.ColumnListCell<Asia
|
||||
placeholder.set(true);
|
||||
setText("");
|
||||
} else {
|
||||
setText(asiakas.getNimi() + "\n" + asiakas.getOsoite());
|
||||
setText(asiakas.getNimi() + ": " + asiakas.getOsoite());
|
||||
}
|
||||
} else {
|
||||
setText("");
|
||||
@@ -0,0 +1,24 @@
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory;
|
||||
|
||||
public class IntegerSpinner extends Spinner<Integer> {
|
||||
/**
|
||||
* Min 0, Max 50
|
||||
*/
|
||||
public IntegerSpinner() {
|
||||
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 50));
|
||||
this.setEditable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param min _
|
||||
* @param max _
|
||||
*/
|
||||
public IntegerSpinner(int min, int max) {
|
||||
super(new SpinnerValueFactory.IntegerSpinnerValueFactory(min, max));
|
||||
this.setEditable(true);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
package fi.lpam.gui.tableCell;
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import fi.lpam.dataluokat.Asiakas;
|
||||
import fi.lpam.dataluokat.Kuljetus;
|
||||
import fi.lpam.gui.KuljetusListat;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
||||
import fi.lpam.ruokamanageri.gui.KuljetusListat;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
@@ -0,0 +1,12 @@
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import javafx.scene.control.TableColumn;
|
||||
|
||||
public class MaaraTableColumn<Asiakas, Integer> extends TableColumn<Asiakas, Integer> {
|
||||
public MaaraTableColumn(String columnLabel, int minWidth) {
|
||||
super(columnLabel);
|
||||
this.setResizable(false);
|
||||
this.setReorderable(false);
|
||||
this.setMinWidth(minWidth);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package fi.lpam.gui.tableCell;
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import fi.lpam.dataluokat.RaporttiRivi;
|
||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
||||
import javafx.scene.control.TableCell;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -0,0 +1,24 @@
|
||||
package fi.lpam.ruokamanageri.gui.elementit;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
|
||||
/**
|
||||
* Käyttöliittymän pohja
|
||||
*/
|
||||
public class TabPohja extends StackPane {
|
||||
public static final Insets oletusInsets = new Insets(5);
|
||||
public static final String oletusStyle = "-fx-background-color: lightgray;";
|
||||
public static final Font buttonFont = Font.font("Open Sans", FontWeight.BOLD, 16);
|
||||
public static final Font tekstiFont = Font.font("Open Sans", FontWeight.NORMAL, 16);
|
||||
public static final Border oletusBorder = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
|
||||
|
||||
public TabPohja() {
|
||||
this.setStyle(oletusStyle);
|
||||
this.setPadding(oletusInsets);
|
||||
this.setBorder(oletusBorder);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package fi.lpam.gui.virheDialogit;
|
||||
package fi.lpam.ruokamanageri.gui.virheDialogit;
|
||||
|
||||
public class SiirtoVirhe extends TietokantaVirhe{
|
||||
public SiirtoVirhe(Exception e){
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package fi.lpam.gui.virheDialogit;
|
||||
package fi.lpam.ruokamanageri.gui.virheDialogit;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.ruokamanageri.Main;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -0,0 +1,8 @@
|
||||
package fi.lpam.ruokamanageri.gui.virheDialogit;
|
||||
|
||||
public class YhteysVirhe extends TietokantaVirhe{
|
||||
public YhteysVirhe(Exception error){
|
||||
this.setHeaderText("Virhe yhdistäessä tietokantaan");
|
||||
this.setContentText(error.getMessage());
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,11 +1,12 @@
|
||||
package fi.lpam.tulostajat;
|
||||
package fi.lpam.ruokamanageri.tulostajat;
|
||||
|
||||
import fi.lpam.dataluokat.Kuljetus;
|
||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class KuljetusListaTulostaja extends Tulostaja{
|
||||
final float NIMEN_LEVEYS = 200;
|
||||
final float OSOITTEEN_LEVEYS = 200;
|
||||
@@ -44,8 +45,7 @@ public class KuljetusListaTulostaja extends Tulostaja{
|
||||
siirräOsoitinta(NIMEN_LEVEYS);
|
||||
sisältö.showText(kuljetus.getLisätieto());
|
||||
uusiRivi(RIVI_KORKEUS*0.1F);
|
||||
//67 alaviivaa fonttikoolla 13 (noin sivun leveys)
|
||||
sisältö.showText("_".repeat((int) (67*13/FONTTI_KOKO)));
|
||||
sisältö.showText("___________________________________________________________________"); //67 alaviivaa (noin sivun leveys)
|
||||
}
|
||||
|
||||
tulosta();
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package fi.lpam.tulostajat;
|
||||
package fi.lpam.ruokamanageri.tulostajat;
|
||||
|
||||
import fi.lpam.dataluokat.RaporttiRivi;
|
||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class KuljetusRaporttiTulostaja extends Tulostaja {
|
||||
public void luoRaportti(ArrayList<RaporttiRivi> raporttiRivit, LocalDate alkuPvm, LocalDate loppuPvm) {
|
||||
try {
|
||||
+9
-10
@@ -1,7 +1,6 @@
|
||||
package fi.lpam.tulostajat;
|
||||
package fi.lpam.ruokamanageri.tulostajat;
|
||||
|
||||
import fi.lpam.Main;
|
||||
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
@@ -16,18 +15,18 @@ import java.awt.print.PrinterJob;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class Tulostaja {
|
||||
final PDRectangle SIVUKOKO = PDRectangle.A4;
|
||||
PDRectangle SIVUKOKO = PDRectangle.A4;
|
||||
final PDFont FONTTI = new PDType1Font(Standard14Fonts.FontName.HELVETICA);
|
||||
final float FONTTI_KOKO = Float.parseFloat(Main.properties.getProperty("tulostusFonttiKoko"));
|
||||
final float FONTTI_KOKO = 13;
|
||||
final float MARGINAALI = 50;
|
||||
final float RIVI_KORKEUS = FONTTI_KOKO * 1.2F;
|
||||
|
||||
final PDDocument dokumentti;
|
||||
PDDocument dokumentti;
|
||||
PDPage nykyinenSivu = null;
|
||||
PDPageContentStream sisältö = null;
|
||||
final float sivunLeveys;
|
||||
final float startX;
|
||||
final float startY;
|
||||
float sivunLeveys;
|
||||
float startX;
|
||||
float startY;
|
||||
float yOffset;
|
||||
float xOffset;
|
||||
|
||||
@@ -79,7 +78,7 @@ public abstract class Tulostaja {
|
||||
uusiRivi(RIVI_KORKEUS);
|
||||
}
|
||||
/**Siirtää osoitinta sivulla. + oikealle, - vasemmalle*/
|
||||
void siirräOsoitinta(@SuppressWarnings("SameParameterValue") float tX) {
|
||||
void siirräOsoitinta(float tX) {
|
||||
try {
|
||||
sisältö.newLineAtOffset(tX, 0);
|
||||
xOffset += tX;
|
||||
@@ -8,8 +8,7 @@ module fi.lpam.ruokamanageri {
|
||||
requires java.desktop;
|
||||
requires org.apache.pdfbox;
|
||||
requires org.apache.commons.lang3;
|
||||
requires one.jpro.platform.mdfx;
|
||||
|
||||
opens fi.lpam.dataluokat to javafx.base;
|
||||
exports fi.lpam;
|
||||
opens fi.lpam.ruokamanageri.dataluokat to javafx.base;
|
||||
exports fi.lpam.ruokamanageri;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
# 3.1.0
|
||||
- Muutosloki näkyy käynnistäessä uutta versiota ensimmäistä kertaa
|
||||
- Ohjelman taustariippuvuuksia päivitetty
|
||||
- Yleistä huoltoa
|
||||
|
||||
# 3.0.1
|
||||
- Kierroshallinnan muokkaus tukemaan paremmin useampaa kierrosta
|
||||
- Kosmeettisia viilauksia muuallekin
|
||||
|
||||
# 3.0.0
|
||||
- Lisätty lauantai ja sunnuntai mahdollisiksi kuljetuspäiviksi
|
||||
- Mahdollisuus kuljettaa (ja muokata listaa) yli 10 ateriaa per asiakas
|
||||
- Versioloki näkyy taas
|
||||
- Pieniä viilauksia asiakashallinnan näkymään
|
||||
|
||||
# 2.0.2
|
||||
- Korjattu virhe kierroksen asiakkaiden hakemisessa, joka aiheutti vääriä järjestyksiä kierroksella
|
||||
|
||||
# 2.0.1
|
||||
- Vaihdettu versioloki avautumaan paikallisena tiedostona
|
||||
|
||||
# 2.0.0
|
||||
### Palaaminen aiempaan versioon ei tuettu
|
||||
- Asiakkaalle lisätty tietoihin laskutusosoite ja yhteyshenkilön yhteystiedot
|
||||
- Tiedot nousevat kuljetusraportille laskutusta varten
|
||||
- Lisätty ohjelmaan linkki muutoslokiin
|
||||
|
||||
# 1.1.1
|
||||
- Integroitu versionumerointi projektiin
|
||||
|
||||
# 1.1.0
|
||||
- Kuljetuslistaa luodessa kuljetusrivin nollaaminen/palauttaminen oletusmääriin.
|
||||
- Kuljetuslistojen ja raporttien tulostamismekanismin läpikäynti
|
||||
- Kierroshallinnassa asiakasta raahattaessa placeholderin fiksaus
|
||||
|
||||
# 1.0.0
|
||||
- Ohjelman kieli vaihdettu Pythonista Javaan, sekä tietokanta pickle-tiedostosta SQLite tietokantaan
|
||||
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: fi.lpam.ruokamanageri.Main
|
||||
@@ -0,0 +1 @@
|
||||
version=${project.version}
|
||||
@@ -1,13 +0,0 @@
|
||||
version=${project.version}
|
||||
|
||||
buttonFonttiKoko=16
|
||||
buttonFontti=Arial
|
||||
|
||||
tekstiFonttiKoko=16
|
||||
tekstiFontti=Arial
|
||||
|
||||
tulostusFonttiKoko=13
|
||||
|
||||
taustaVari=lightgray
|
||||
|
||||
insets=5
|
||||
@@ -12,11 +12,7 @@ create table if not exists asiakkaat (
|
||||
jälkiruoat int not null,
|
||||
erityisruokavalio varchar(255),
|
||||
avainTieto varchar(255),
|
||||
lisätiedot text,
|
||||
laskutusosoite varchar(255),
|
||||
yhteyshenkilönNimi varchar(255),
|
||||
yhteyshenkilönPuhelinnumero varchar(255),
|
||||
yhteyshenkilönSähköposti varchar(255)
|
||||
lisätiedot text
|
||||
);
|
||||
|
||||
create table if not exists kierrokset (
|
||||
|
||||
Reference in New Issue
Block a user