Compare commits
42 Commits
d2e8962f31
..
1.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c818e5d31a | |||
| 8d3da0afbb | |||
| 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 |
+2
-1
@@ -11,7 +11,8 @@ out/
|
|||||||
.idea/jarRepositories.xml
|
.idea/jarRepositories.xml
|
||||||
.idea/compiler.xml
|
.idea/compiler.xml
|
||||||
.idea/libraries/
|
.idea/libraries/
|
||||||
.idea/dataSources
|
.idea/dataSources.xml
|
||||||
|
.idea/db-forest-config.xml
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|||||||
+1
-6
@@ -2,7 +2,7 @@
|
|||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="ExtractMethodRecommender" enabled="true" level="WARNING" enabled_by_default="true">
|
<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>
|
||||||
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
|
<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" />
|
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
@@ -12,10 +12,5 @@
|
|||||||
<option name="processLiterals" value="true" />
|
<option name="processLiterals" value="true" />
|
||||||
<option name="processComments" value="true" />
|
<option name="processComments" value="true" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="UnusedAssignment" enabled="false" level="WARNING" enabled_by_default="false">
|
|
||||||
<option name="REPORT_PREFIX_EXPRESSIONS" value="false" />
|
|
||||||
<option name="REPORT_POSTFIX_EXPRESSIONS" value="true" />
|
|
||||||
<option name="REPORT_REDUNDANT_INITIALIZER" value="true" />
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Main" type="Application" factoryName="Application" nameIsGenerated="true">
|
<configuration default="false" name="fi.lpam.Main" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||||
<option name="MAIN_CLASS_NAME" value="fi.lpam.ruokamanageri.Main" />
|
<option name="MAIN_CLASS_NAME" value="fi.lpam.Main" />
|
||||||
<module name="Ruokamanageri" />
|
<module name="Ruokamanageri" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="DEV" />
|
<option name="PROGRAM_PARAMETERS" value="DEV" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="fi.lpam.ruokamanageri.*" />
|
<option name="PATTERN" value="fi.lpam.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
+2
-22
@@ -1,28 +1,8 @@
|
|||||||
# 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
|
# 1.1.0
|
||||||
- Kuljetuslistaa luodessa kuljetusrivin nollaaminen/palauttaminen oletusmääriin.
|
- Kuljetuslistaa luodessa kuljetusrivin nollaaminen/palauttaminen oletusmääriin.
|
||||||
- Kuljetuslistojen ja raporttien tulostamismekanismin läpikäynti
|
- Kuljetuslistojen ja raporttien tulostamismekanismin läpikäynti
|
||||||
- Kierroshallinnassa asiakasta raahattaessa placeholderin fiksaus
|
- Kierroshallinnassa asiakasta raahattaessa placeholderin fiksaus
|
||||||
|
- Lisätty versionumero ohjelmaan
|
||||||
|
|
||||||
# 1.0.0
|
# 1.0.0
|
||||||
- Ohjelman kieli vaihdettu Pythonista Javaan, sekä tietokanta pickle-tiedostosta SQLite tietokantaan
|
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](CHANGELOG.md)
|
||||||
|
|
||||||
# [Versiohistoria](CHANGELOG.md)
|
|
||||||
|
|
||||||
# Kuvaus
|
# Kuvaus
|
||||||
Pienen kotiateriapalvelun käyttöön rakennettu ohjelma sisältäen seuraavat ominaisuudet
|
Pienen kotiateriapalvelun käyttöön rakennettu ohjelma sisältäen seuraavat ominaisuudet
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>fi.lpam.ruokamanageri</groupId>
|
<groupId>fi.lpam</groupId>
|
||||||
<artifactId>Ruokamanageri</artifactId>
|
<artifactId>Ruokamanageri</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>1.1.1</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>25</maven.compiler.source>
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
@@ -72,7 +72,6 @@
|
|||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -92,7 +91,7 @@
|
|||||||
<!-- Usage: mvn clean javafx:run -->
|
<!-- Usage: mvn clean javafx:run -->
|
||||||
<id>default-cli</id>
|
<id>default-cli</id>
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>fi.lpam.ruokamanageri.Main</mainClass>
|
<mainClass>fi.lpam.Main</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@@ -114,7 +113,7 @@
|
|||||||
<transformers>
|
<transformers>
|
||||||
<transformer implementation=
|
<transformer implementation=
|
||||||
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<mainClass>fi.lpam.ruokamanageri.Main</mainClass>
|
<mainClass>fi.lpam.Main</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
</transformers>
|
</transformers>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package fi.lpam.ruokamanageri;
|
package fi.lpam;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Tietokanta;
|
import fi.lpam.dataluokat.Tietokanta;
|
||||||
import fi.lpam.ruokamanageri.gui.Asiakashallinta;
|
import fi.lpam.gui.Asiakashallinta;
|
||||||
import fi.lpam.ruokamanageri.gui.Kierroshallinta;
|
import fi.lpam.gui.Kierroshallinta;
|
||||||
import fi.lpam.ruokamanageri.gui.KuljetusRaportit;
|
import fi.lpam.gui.KuljetusRaportit;
|
||||||
import fi.lpam.ruokamanageri.gui.KuljetusListat;
|
import fi.lpam.gui.KuljetusListat;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.geometry.Side;
|
import javafx.geometry.Side;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@@ -12,6 +12,7 @@ import javafx.scene.control.TabPane;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@SuppressWarnings("InstantiationOfUtilityClass")
|
@SuppressWarnings("InstantiationOfUtilityClass")
|
||||||
@@ -21,9 +22,10 @@ public class App extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) throws IOException {
|
||||||
new Tietokanta(Main.dev);
|
new Tietokanta(Main.dev);
|
||||||
|
|
||||||
|
|
||||||
TabPane root = new TabPane();
|
TabPane root = new TabPane();
|
||||||
root.setSide(Side.LEFT);
|
root.setSide(Side.LEFT);
|
||||||
root.setTabMinWidth(50);
|
root.setTabMinWidth(50);
|
||||||
@@ -37,7 +39,7 @@ public class App extends Application {
|
|||||||
kuljetetut = new Tab("Kuljetetut");
|
kuljetetut = new Tab("Kuljetetut");
|
||||||
root.getTabs().addAll(asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut);
|
root.getTabs().addAll(asiakasHallinta, kierrostenHallinta, kuljetusListat, kuljetetut);
|
||||||
|
|
||||||
root.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
|
root.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
switch (newValue.getText()) {
|
switch (newValue.getText()) {
|
||||||
case "Asiakashallinta": newValue.setContent(new Asiakashallinta()); break;
|
case "Asiakashallinta": newValue.setContent(new Asiakashallinta()); break;
|
||||||
case "Kierrostenhallinta": newValue.setContent(new Kierroshallinta()); break;
|
case "Kierrostenhallinta": newValue.setContent(new Kierroshallinta()); break;
|
||||||
@@ -62,6 +64,6 @@ public class App extends Application {
|
|||||||
|
|
||||||
primaryStage.setMaximized(true);
|
primaryStage.setMaximized(true);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
primaryStage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
primaryStage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package fi.lpam.ruokamanageri;
|
package fi.lpam;
|
||||||
|
|
||||||
|
import javax.print.DocFlavor;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -15,12 +17,12 @@ public class Main {
|
|||||||
dev = false;
|
dev = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
InputStream stream = Main.class.getClassLoader().getResourceAsStream("app.properties");
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
properties.load(Main.class.getClassLoader().getResourceAsStream("app.properties"));
|
try {
|
||||||
|
properties.load(stream);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
//noinspection CallToPrintStackTrace
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
+68
-176
@@ -1,24 +1,20 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.DayOfWeek;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class Asiakas implements TietokantaOlio {
|
public class Asiakas implements TietokantaOlio {
|
||||||
private int id = -1;
|
private int id = -1;
|
||||||
private String nimi;
|
private String nimi;
|
||||||
private String osoite;
|
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 int salaatit, pääruoat, jälkiruoat;
|
||||||
private String erityisruokavalio;
|
private String erityisruokavalio;
|
||||||
private String avainTieto;
|
private String avainTieto;
|
||||||
private String lisätiedot;
|
private String lisätiedot;
|
||||||
private String laskutusOsoite, yhteyshenkilönNimi, yhteyshenkilönPuhelinnumero, yhteyshenkilönSähköposti;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tyhjä konstruktori uusien luomista varten
|
* Tyhjä konstruktori uusien luomista varten
|
||||||
@@ -44,39 +40,14 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
* @param keskiviikkoKpl kuljetettava määrä
|
* @param keskiviikkoKpl kuljetettava määrä
|
||||||
* @param torstaiKpl kuljetettava määrä
|
* @param torstaiKpl kuljetettava määrä
|
||||||
* @param perjantaiKpl kuljetettava määrä
|
* @param perjantaiKpl kuljetettava määrä
|
||||||
* @param lauantaiKpl kuljetettava määrä
|
|
||||||
* @param sunnuntaiKpl kuljetettava määrä
|
|
||||||
* @param salaatit kuljetettava määrä
|
* @param salaatit kuljetettava määrä
|
||||||
* @param pääruoat kuljetettava määrä
|
* @param pääruoat kuljetettava määrä
|
||||||
* @param jälkiruoat kuljetettava määrä
|
* @param jälkiruoat kuljetettava määrä
|
||||||
* @param erityisruokavalio ...
|
* @param erityisruokavalio ...
|
||||||
* @param avainTieto ...
|
* @param avainTieto ...
|
||||||
* @param lisätiedot mahdolliset lisätilaukset/tiedot
|
* @param lisätiedot mahdolliset lisätilaukset/tiedot
|
||||||
* @param laskutusOsoite ...
|
|
||||||
* @param yhteyshenkilönNimi ...
|
|
||||||
* @param yhteyshenkilönPuhelinnumero ...
|
|
||||||
* @param yhteyshenkilönSähköposti ...
|
|
||||||
*/
|
*/
|
||||||
private Asiakas(int id,
|
private Asiakas(int id, String nimi, String osoite, int maanantaiKpl, int tiistaiKpl, int keskiviikkoKpl, int torstaiKpl, int perjantaiKpl, int salaatit, int pääruoat, int jälkiruoat, String erityisruokavalio, String avainTieto, String lisätiedot) {
|
||||||
String nimi,
|
|
||||||
String osoite,
|
|
||||||
int maanantaiKpl,
|
|
||||||
int tiistaiKpl,
|
|
||||||
int keskiviikkoKpl,
|
|
||||||
int torstaiKpl,
|
|
||||||
int perjantaiKpl,
|
|
||||||
int lauantaiKpl,
|
|
||||||
int sunnuntaiKpl,
|
|
||||||
int salaatit,
|
|
||||||
int pääruoat,
|
|
||||||
int jälkiruoat,
|
|
||||||
String erityisruokavalio,
|
|
||||||
String avainTieto,
|
|
||||||
String lisätiedot,
|
|
||||||
String laskutusOsoite,
|
|
||||||
String yhteyshenkilönNimi,
|
|
||||||
String yhteyshenkilönPuhelinnumero,
|
|
||||||
String yhteyshenkilönSähköposti) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.nimi = nimi;
|
this.nimi = nimi;
|
||||||
this.osoite = osoite;
|
this.osoite = osoite;
|
||||||
@@ -85,18 +56,43 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
this.keskiviikkoKpl = keskiviikkoKpl;
|
this.keskiviikkoKpl = keskiviikkoKpl;
|
||||||
this.torstaiKpl = torstaiKpl;
|
this.torstaiKpl = torstaiKpl;
|
||||||
this.perjantaiKpl = perjantaiKpl;
|
this.perjantaiKpl = perjantaiKpl;
|
||||||
this.lauantaiKpl = lauantaiKpl;
|
|
||||||
this.sunnuntaiKpl = sunnuntaiKpl;
|
|
||||||
this.salaatit = salaatit;
|
this.salaatit = salaatit;
|
||||||
this.pääruoat = pääruoat;
|
this.pääruoat = pääruoat;
|
||||||
this.jälkiruoat = jälkiruoat;
|
this.jälkiruoat = jälkiruoat;
|
||||||
this.erityisruokavalio = erityisruokavalio;
|
this.erityisruokavalio = erityisruokavalio;
|
||||||
this.avainTieto = avainTieto;
|
this.avainTieto = avainTieto;
|
||||||
this.lisätiedot = lisätiedot;
|
this.lisätiedot = lisätiedot;
|
||||||
this.laskutusOsoite = laskutusOsoite;
|
}
|
||||||
this.yhteyshenkilönNimi = yhteyshenkilönNimi;
|
|
||||||
this.yhteyshenkilönPuhelinnumero = yhteyshenkilönPuhelinnumero;
|
/**
|
||||||
this.yhteyshenkilönSähköposti = yhteyshenkilönSähköposti;
|
* @param nimi asiakkaan nimi
|
||||||
|
* @param osoite osoite
|
||||||
|
* @param maanantaiKpl kuljetettava määrä
|
||||||
|
* @param tiistaiKpl kuljetettava määrä
|
||||||
|
* @param keskiviikkoKpl kuljetettava määrä
|
||||||
|
* @param torstaiKpl kuljetettava määrä
|
||||||
|
* @param perjantaiKpl kuljetettava määrä
|
||||||
|
* @param salaatit kuljetettava määrä
|
||||||
|
* @param pääruoat kuljetettava määrä
|
||||||
|
* @param jälkiruoat kuljetettava määrä
|
||||||
|
* @param erityisruokavalio ...
|
||||||
|
* @param avainTieto ...
|
||||||
|
* @param lisätiedot mahdolliset lisätilaukset/tiedot
|
||||||
|
*/
|
||||||
|
public Asiakas(String nimi, String osoite, int maanantaiKpl, int tiistaiKpl, int keskiviikkoKpl, int torstaiKpl, int perjantaiKpl, int salaatit, int pääruoat, int jälkiruoat, String erityisruokavalio, String avainTieto, String lisätiedot) {
|
||||||
|
this.nimi = nimi;
|
||||||
|
this.osoite = osoite;
|
||||||
|
this.maanantaiKpl = maanantaiKpl;
|
||||||
|
this.tiistaiKpl = tiistaiKpl;
|
||||||
|
this.keskiviikkoKpl = keskiviikkoKpl;
|
||||||
|
this.torstaiKpl = torstaiKpl;
|
||||||
|
this.perjantaiKpl = perjantaiKpl;
|
||||||
|
this.salaatit = salaatit;
|
||||||
|
this.pääruoat = pääruoat;
|
||||||
|
this.jälkiruoat = jälkiruoat;
|
||||||
|
this.erityisruokavalio = erityisruokavalio;
|
||||||
|
this.avainTieto = avainTieto;
|
||||||
|
this.lisätiedot = lisätiedot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +112,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
|
* @param IDt haettavat asiakkkaat
|
||||||
* @return Haetut asiakkaat tai null
|
* @return Haetut asiakkaat tai null
|
||||||
*/
|
*/
|
||||||
@@ -127,17 +123,10 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
sbIDt.append(", ").append(IDt[i]);
|
sbIDt.append(", ").append(IDt[i]);
|
||||||
}
|
}
|
||||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
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();
|
Statement stmt = tietokanta.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery(sql);
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
|
return parsiResultSet(rs);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
SiirtoVirhe alert = new SiirtoVirhe(e);
|
SiirtoVirhe alert = new SiirtoVirhe(e);
|
||||||
@@ -165,18 +154,12 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
rs.getInt("keskiviikkoKpl"),
|
rs.getInt("keskiviikkoKpl"),
|
||||||
rs.getInt("torstaiKpl"),
|
rs.getInt("torstaiKpl"),
|
||||||
rs.getInt("perjantaiKpl"),
|
rs.getInt("perjantaiKpl"),
|
||||||
rs.getInt("lauantaiKpl"),
|
|
||||||
rs.getInt("sunnuntaiKpl"),
|
|
||||||
rs.getInt("salaatit"),
|
rs.getInt("salaatit"),
|
||||||
rs.getInt("pääruoat"),
|
rs.getInt("pääruoat"),
|
||||||
rs.getInt("jälkiruoat"),
|
rs.getInt("jälkiruoat"),
|
||||||
rs.getString("erityisruokavalio"),
|
rs.getString("erityisruokavalio"),
|
||||||
rs.getString("avainTieto"),
|
rs.getString("avainTieto"),
|
||||||
rs.getString("lisätiedot"),
|
rs.getString("lisätiedot")
|
||||||
rs.getString("laskutusOsoite"),
|
|
||||||
rs.getString("yhteyshenkilönNimi"),
|
|
||||||
rs.getString("yhteyshenkilönPuhelinnumero"),
|
|
||||||
rs.getString("yhteyshenkilönSähköposti")
|
|
||||||
);
|
);
|
||||||
asiakkaat.add(uusi);
|
asiakkaat.add(uusi);
|
||||||
}
|
}
|
||||||
@@ -195,28 +178,20 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
@Override
|
@Override
|
||||||
public boolean tallennaUusi() {
|
public boolean tallennaUusi() {
|
||||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||||
int i = 1;
|
stmt.setString(1, nimi);
|
||||||
stmt.setString(i++, nimi);
|
stmt.setString(2, osoite);
|
||||||
stmt.setString(i++, osoite);
|
stmt.setInt(3, maanantaiKpl);
|
||||||
stmt.setInt(i++, maanantaiKpl);
|
stmt.setInt(4, tiistaiKpl);
|
||||||
stmt.setInt(i++, tiistaiKpl);
|
stmt.setInt(5, keskiviikkoKpl);
|
||||||
stmt.setInt(i++, keskiviikkoKpl);
|
stmt.setInt(6, torstaiKpl);
|
||||||
stmt.setInt(i++, torstaiKpl);
|
stmt.setInt(7, perjantaiKpl);
|
||||||
stmt.setInt(i++, perjantaiKpl);
|
stmt.setInt(8, salaatit);
|
||||||
stmt.setInt(i++, lauantaiKpl);
|
stmt.setInt(9, pääruoat);
|
||||||
stmt.setInt(i++, sunnuntaiKpl);
|
stmt.setInt(10, jälkiruoat);
|
||||||
stmt.setInt(i++, salaatit);
|
stmt.setString(11, erityisruokavalio);
|
||||||
stmt.setInt(i++, pääruoat);
|
stmt.setString(12, avainTieto);
|
||||||
stmt.setInt(i++, jälkiruoat);
|
stmt.setString(13, lisätiedot);
|
||||||
stmt.setString(i++, erityisruokavalio);
|
|
||||||
stmt.setString(i++, avainTieto);
|
|
||||||
stmt.setString(i++, lisätiedot);
|
|
||||||
stmt.setString(i++, laskutusOsoite);
|
|
||||||
stmt.setString(i++, yhteyshenkilönNimi);
|
|
||||||
stmt.setString(i++, yhteyshenkilönPuhelinnumero);
|
|
||||||
stmt.setString(i++, yhteyshenkilönSähköposti);
|
|
||||||
|
|
||||||
int muokatutRivit = stmt.executeUpdate();
|
int muokatutRivit = stmt.executeUpdate();
|
||||||
|
|
||||||
if (muokatutRivit == 0) {
|
if (muokatutRivit == 0) {
|
||||||
@@ -244,29 +219,21 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
@Override
|
@Override
|
||||||
public boolean päivitäTietokantaan() {
|
public boolean päivitäTietokantaan() {
|
||||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
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 = ? WHERE id = ?");
|
||||||
int i = 1;
|
stmt.setString(1, nimi);
|
||||||
stmt.setString(i++, nimi);
|
stmt.setString(2, osoite);
|
||||||
stmt.setString(i++, osoite);
|
stmt.setInt(3, maanantaiKpl);
|
||||||
stmt.setInt(i++, maanantaiKpl);
|
stmt.setInt(4, tiistaiKpl);
|
||||||
stmt.setInt(i++, tiistaiKpl);
|
stmt.setInt(5, keskiviikkoKpl);
|
||||||
stmt.setInt(i++, keskiviikkoKpl);
|
stmt.setInt(6, torstaiKpl);
|
||||||
stmt.setInt(i++, torstaiKpl);
|
stmt.setInt(7, perjantaiKpl);
|
||||||
stmt.setInt(i++, perjantaiKpl);
|
stmt.setInt(8, salaatit);
|
||||||
stmt.setInt(i++, lauantaiKpl);
|
stmt.setInt(9, pääruoat);
|
||||||
stmt.setInt(i++, sunnuntaiKpl);
|
stmt.setInt(10, jälkiruoat);
|
||||||
stmt.setInt(i++, salaatit);
|
stmt.setString(11, erityisruokavalio);
|
||||||
stmt.setInt(i++, pääruoat);
|
stmt.setString(12, avainTieto);
|
||||||
stmt.setInt(i++, jälkiruoat);
|
stmt.setString(13, lisätiedot);
|
||||||
stmt.setString(i++, erityisruokavalio);
|
stmt.setInt(14, id);
|
||||||
stmt.setString(i++, avainTieto);
|
|
||||||
stmt.setString(i++, lisätiedot);
|
|
||||||
stmt.setString(i++, laskutusOsoite);
|
|
||||||
stmt.setString(i++, yhteyshenkilönNimi);
|
|
||||||
stmt.setString(i++, yhteyshenkilönPuhelinnumero);
|
|
||||||
stmt.setString(i++, yhteyshenkilönSähköposti);
|
|
||||||
|
|
||||||
stmt.setInt(i++, id);
|
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -310,33 +277,6 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
return this.getNimi();
|
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() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -401,22 +341,6 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
this.perjantaiKpl = perjantaiKpl;
|
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() {
|
public int getSalaatit() {
|
||||||
return salaatit;
|
return salaatit;
|
||||||
}
|
}
|
||||||
@@ -464,36 +388,4 @@ public class Asiakas implements TietokantaOlio {
|
|||||||
public void setLisätiedot(String lisätiedot) {
|
public void setLisätiedot(String lisätiedot) {
|
||||||
this.lisätiedot = lisätiedot;
|
this.lisätiedot = lisätiedot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLaskutusOsoite() {
|
|
||||||
return laskutusOsoite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLaskutusOsoite(String laskutusOsoite) {
|
|
||||||
this.laskutusOsoite = laskutusOsoite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönNimi() {
|
|
||||||
return yhteyshenkilönNimi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYhteyshenkilönNimi(String yhteyshenkilönNimi) {
|
|
||||||
this.yhteyshenkilönNimi = yhteyshenkilönNimi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönPuhelinnumero() {
|
|
||||||
return yhteyshenkilönPuhelinnumero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYhteyshenkilönPuhelinnumero(String yhteyshenkilönPuhelinnumero) {
|
|
||||||
this.yhteyshenkilönPuhelinnumero = yhteyshenkilönPuhelinnumero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönSähköposti() {
|
|
||||||
return yhteyshenkilönSähköposti;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYhteyshenkilönSähköposti(String yhteyshenkilönSähköposti) {
|
|
||||||
this.yhteyshenkilönSähköposti = yhteyshenkilönSähköposti;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
+89
-9
@@ -1,6 +1,6 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -36,9 +36,17 @@ public class Kuljetus implements TietokantaOlio {
|
|||||||
this.nimi = asiakas.getNimi();
|
this.nimi = asiakas.getNimi();
|
||||||
this.kuljetusPäivämäärä = pvm;
|
this.kuljetusPäivämäärä = pvm;
|
||||||
this.kuljetusKierros = kuljetusKierros;
|
this.kuljetusKierros = kuljetusKierros;
|
||||||
this.salaatit = asiakas.getPäivänSalaatit(pvm);
|
int kuljetusKerroin = switch (kuljetusPäivämäärä.getDayOfWeek()) {
|
||||||
this.pääruoat = asiakas.getPäivänPääruoat(pvm);
|
case MONDAY -> asiakas.getMaanantaiKpl();
|
||||||
this.jälkiruoat = asiakas.getPäivänJälkiruoat(pvm);
|
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.osoite = asiakas.getOsoite();
|
||||||
this.avainTieto = asiakas.getAvainTieto();
|
this.avainTieto = asiakas.getAvainTieto();
|
||||||
this.lisätieto = asiakas.getLisätiedot();
|
this.lisätieto = asiakas.getLisätiedot();
|
||||||
@@ -60,6 +68,36 @@ public class Kuljetus implements TietokantaOlio {
|
|||||||
this.ruokarajoite = ruokarajoite;
|
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
|
* Hakee tietyn kierroksen kuljetukset
|
||||||
* @param päivä kierroksen päivä
|
* @param päivä kierroksen päivä
|
||||||
@@ -79,6 +117,41 @@ public class Kuljetus implements TietokantaOlio {
|
|||||||
return null;
|
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
|
@Override
|
||||||
public boolean tallennaUusi() {
|
public boolean tallennaUusi() {
|
||||||
@@ -218,16 +291,23 @@ public class Kuljetus implements TietokantaOlio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void palautaMäärät(Asiakas asiakas) {
|
public void palautaMäärät(Asiakas asiakas) {
|
||||||
setSalaatit(asiakas.getPäivänSalaatit(kuljetusPäivämäärä));
|
int kuljetusKerroin = switch (kuljetusPäivämäärä.getDayOfWeek()) {
|
||||||
setPääruoat(asiakas.getPäivänPääruoat(kuljetusPäivämäärä));
|
case MONDAY -> asiakas.getMaanantaiKpl();
|
||||||
setJälkiruoat(asiakas.getPäivänJälkiruoat(kuljetusPäivämäärä));
|
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());
|
setLisätieto(asiakas.getLisätiedot());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean kuljetetaan() {
|
public boolean kuljetetaan() {
|
||||||
return salaatit > 0 || pääruoat > 0 || jälkiruoat > 0 || !lisätieto.isBlank();
|
return salaatit > 0 || pääruoat > 0 || jälkiruoat > 0 || !lisätieto.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@SuppressWarnings("ClassCanBeRecord")
|
||||||
|
public class RaporttiRivi {
|
||||||
|
private final String nimi;
|
||||||
|
private final LocalDate alkuPvm, loppuPvm;
|
||||||
|
private final int salaatit, pääruoat, jälkiruoat;
|
||||||
|
private final String lisätiedot;
|
||||||
|
|
||||||
|
public RaporttiRivi(String nimi, LocalDate alkuPvm, LocalDate loppuPvm, int salaatit, int pääruoat, int jälkiruoat, String lisätiedot) {
|
||||||
|
this.nimi = nimi;
|
||||||
|
this.alkuPvm = alkuPvm;
|
||||||
|
this.loppuPvm = loppuPvm;
|
||||||
|
this.salaatit = salaatit;
|
||||||
|
this.pääruoat = pääruoat;
|
||||||
|
this.jälkiruoat = jälkiruoat;
|
||||||
|
this.lisätiedot = lisätiedot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<RaporttiRivi> haeRaportti(LocalDate alkuPvm, LocalDate loppuPvm, boolean tarkka) {
|
||||||
|
ArrayList<RaporttiRivi> raportti = new ArrayList<>();
|
||||||
|
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
||||||
|
ResultSet rs;
|
||||||
|
if (tarkka) {
|
||||||
|
//Jokainen kuljetus saa oman rivin
|
||||||
|
PreparedStatement stmt = tietokanta.prepareStatement("select nimi, kuljetusPäivämäärä, salaatit, pääruoat, jälkiruoat, lisätieto from kuljetukset where kuljetusPäivämäärä between ? and ? order by nimi");
|
||||||
|
stmt.setDate(1, Date.valueOf(alkuPvm));
|
||||||
|
stmt.setDate(2, Date.valueOf(loppuPvm));
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
RaporttiRivi uusi = new RaporttiRivi(
|
||||||
|
rs.getString(1),
|
||||||
|
rs.getDate(2).toLocalDate(),
|
||||||
|
rs.getDate(2).toLocalDate(),
|
||||||
|
rs.getInt(3),
|
||||||
|
rs.getInt(4),
|
||||||
|
rs.getInt(5),
|
||||||
|
rs.getString(6)
|
||||||
|
);
|
||||||
|
raportti.add(uusi);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//Kuljetukset summataan yhteen riviin per vastaanottaja
|
||||||
|
PreparedStatement stmt = tietokanta.prepareStatement("select nimi, kuljetusPäivämäärä, sum(salaatit), sum(pääruoat), sum(jälkiruoat), group_concat(lisätieto, '\n') from kuljetukset where kuljetusPäivämäärä between ? and ? group by nimi order by nimi;");
|
||||||
|
stmt.setDate(1, Date.valueOf(alkuPvm));
|
||||||
|
stmt.setDate(2, Date.valueOf(loppuPvm));
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
RaporttiRivi uusi = new RaporttiRivi(
|
||||||
|
rs.getString(1),
|
||||||
|
alkuPvm,
|
||||||
|
loppuPvm,
|
||||||
|
rs.getInt(3),
|
||||||
|
rs.getInt(4),
|
||||||
|
rs.getInt(5),
|
||||||
|
rs.getString(6)
|
||||||
|
);
|
||||||
|
raportti.add(uusi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||||
|
virhe.showAndWait();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return raportti;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.nimi + ":\nSal: " + this.salaatit + ", Pr: " + this.pääruoat + ", Jr: " + this.jälkiruoat + "\nLisätiedot:\n" + this.lisätiedot.strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNimi() {
|
||||||
|
return nimi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getAlkuPvm() {
|
||||||
|
return alkuPvm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getLoppuPvm() {
|
||||||
|
return loppuPvm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSalaatit() {
|
||||||
|
return salaatit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPääruoat() {
|
||||||
|
return pääruoat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJälkiruoat() {
|
||||||
|
return jälkiruoat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLisätiedot() {
|
||||||
|
return lisätiedot;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
|
import fi.lpam.gui.virheDialogit.YhteysVirhe;
|
||||||
|
|
||||||
|
import fi.lpam.Main;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Tietokanta {
|
||||||
|
private static String osoite;
|
||||||
|
private static String dbPath = SystemUtils.getUserHome().getAbsolutePath() + "\\OneDrive\\Kuljetusruokasovellus\\tietokanta.db";
|
||||||
|
|
||||||
|
public Tietokanta(boolean dev) throws IOException {
|
||||||
|
if (dev) dbPath = "testikanta.db";
|
||||||
|
File file = new File(dbPath);
|
||||||
|
try {
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
catch (Exception _) {}
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
|
file.createNewFile();
|
||||||
|
|
||||||
|
osoite = "jdbc:sqlite:" + file.getAbsolutePath();
|
||||||
|
|
||||||
|
|
||||||
|
try (Connection conn = haeYhteys()) {
|
||||||
|
InputStream is = Objects.requireNonNull(Main.class.getResourceAsStream("tietokanta.sql"));
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
String sql = br.readAllAsString();
|
||||||
|
|
||||||
|
for (String query : sql.split(";")) {
|
||||||
|
conn.createStatement().execute(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
||||||
|
virhe.showAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Connection haeYhteys() {
|
||||||
|
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = DriverManager.getConnection(osoite);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Alert virhe = new YhteysVirhe(e);
|
||||||
|
virhe.showAndWait();
|
||||||
|
}
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
package fi.lpam.dataluokat;
|
||||||
|
|
||||||
public interface TietokantaOlio {
|
public interface TietokantaOlio {
|
||||||
|
|
||||||
+66
-137
@@ -1,19 +1,15 @@
|
|||||||
package fi.lpam.ruokamanageri.gui;
|
package fi.lpam.gui;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.IntegerSpinner;
|
import fi.lpam.gui.elementit.IntegerSpinner;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
import fi.lpam.gui.elementit.TabPohja;
|
||||||
import fi.lpam.ruokamanageri.Main;
|
import fi.lpam.Main;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.geometry.Side;
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -21,8 +17,8 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class AsiakasIkkuna extends Stage {
|
public class AsiakasIkkuna extends Stage {
|
||||||
final Asiakas käsiteltäväAsiakas;
|
final Asiakas käsiteltäväAsiakas;
|
||||||
final TextField tfNimi, tfOsoite, tfRuokarajoitteet, tfAvainTieto, tfLisätiedot, tfYhteyshenkilönNimi, tfLaskutusOsoite, tfYhteyshenkilönPuhelinnumero, tfYhteyshenkilönSähköposti;
|
final TextField tfNimi, tfOsoite, tfRuokarajoitteet, tfAvainTieto, tfLisätiedot;
|
||||||
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
|
* Luo ikkunan jossa muokataan saatua asiakasta
|
||||||
@@ -32,142 +28,93 @@ public class AsiakasIkkuna extends Stage {
|
|||||||
this.käsiteltäväAsiakas = käsiteltäväAsiakas;
|
this.käsiteltäväAsiakas = käsiteltäväAsiakas;
|
||||||
this.setTitle("Asiakasikkuna");
|
this.setTitle("Asiakasikkuna");
|
||||||
|
|
||||||
TabPane tabPane = new TabPane();
|
GridPane root = new GridPane();
|
||||||
tabPane.setSide(Side.LEFT);
|
root.setPadding(new Insets(15));
|
||||||
int korkeus = 150;
|
root.setHgap(10);
|
||||||
tabPane.setTabMinWidth(korkeus);
|
root.setVgap(10);
|
||||||
tabPane.setTabMinWidth(korkeus);
|
root.setOnKeyPressed(e -> {
|
||||||
tabPane.setTabMinHeight(35);
|
|
||||||
tabPane.setTabMaxHeight(35);
|
|
||||||
tabPane.setOnKeyPressed(e -> {
|
|
||||||
switch (e.getCode()) {
|
switch (e.getCode()) {
|
||||||
case ENTER: tallenna(); break;
|
case ENTER: tallenna(); break;
|
||||||
case ESCAPE: close(); break;
|
case ESCAPE: close(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
Tab tabKuljetusTiedot, tabAsiakastiedot;
|
root.addRow(root.getRowCount(), new Label("Vahvistetut kentät pakollisia"));
|
||||||
tabKuljetusTiedot = new Tab("Kuljetustiedot");
|
|
||||||
tabAsiakastiedot = new Tab("Asiakastiedot");
|
|
||||||
tabPane.getTabs().addAll(tabKuljetusTiedot, tabAsiakastiedot);
|
|
||||||
for (Tab tab : tabPane.getTabs()) {
|
|
||||||
tab.setClosable(false);
|
|
||||||
tab.setStyle("-fx-font-size: 18px; -fx-font-weight: bold; -fx-font-family: Open Sans");
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
GridPane asiakasTiedot = new GridPane();
|
|
||||||
asiakasTiedot.setPadding(new Insets(15));
|
|
||||||
asiakasTiedot.setHgap(10);
|
|
||||||
asiakasTiedot.setVgap(10);
|
|
||||||
tabAsiakastiedot.setContent(asiakasTiedot);
|
|
||||||
|
|
||||||
Label nimi = new Label("Asiakkaan etu- ja sukunimi");
|
Label nimi = new Label("Asiakkaan etu- ja sukunimi");
|
||||||
nimi.setStyle("-fx-font-weight: bold;");
|
nimi.setStyle("-fx-font-weight: bold;");
|
||||||
tfNimi = new TextField();
|
tfNimi = new TextField();
|
||||||
tfNimi.setPromptText("Pakollinen tieto");
|
tfNimi.setPromptText("Pakollinen tieto");
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), nimi, tfNimi);
|
root.addRow(root.getRowCount(), nimi, tfNimi);
|
||||||
|
|
||||||
Label osoite = new Label("Osoite");
|
Label osoite = new Label("Osoite");
|
||||||
osoite.setStyle("-fx-font-weight: bold;");
|
osoite.setStyle("-fx-font-weight: bold;");
|
||||||
tfOsoite = new TextField();
|
tfOsoite = new TextField();
|
||||||
tfOsoite.setPromptText("Pakollinen tieto");
|
tfOsoite.setPromptText("Pakollinen tieto");
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), osoite, tfOsoite);
|
root.addRow(root.getRowCount(), osoite, tfOsoite);
|
||||||
|
|
||||||
Label yhteyshenkilönNimi = new Label("Yhteyshenkilön etu- ja sukunimi");
|
root.addRow(root.getRowCount(), new Label("Määrät per kuljetus"));
|
||||||
tfYhteyshenkilönNimi = new TextField();
|
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönNimi, tfYhteyshenkilönNimi);
|
|
||||||
|
|
||||||
Label laskutusOsoite = new Label("Laskutusosoite");
|
Label salaatit = new Label("Salaatit");
|
||||||
tfLaskutusOsoite = new TextField();
|
tfSalaatit = new IntegerSpinner();
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), laskutusOsoite, tfLaskutusOsoite);
|
root.addRow(root.getRowCount(), salaatit, tfSalaatit);
|
||||||
|
|
||||||
Label yhteyshenkilönPuhelinnumero = new Label("Puhelinnumero");
|
Label pääruoat = new Label("Pääruoat");
|
||||||
tfYhteyshenkilönPuhelinnumero = new TextField();
|
tfPääruoat = new IntegerSpinner();
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönPuhelinnumero, tfYhteyshenkilönPuhelinnumero);
|
root.addRow(root.getRowCount(), pääruoat, tfPääruoat);
|
||||||
|
|
||||||
Label yhteyshenkilönSähköposti = new Label("Sähköposti");
|
Label jälkiruoat = new Label("Jälkiruoat");
|
||||||
tfYhteyshenkilönSähköposti = new TextField();
|
tfJälkiruoat = new IntegerSpinner();
|
||||||
asiakasTiedot.addRow(asiakasTiedot.getRowCount(), yhteyshenkilönSähköposti, tfYhteyshenkilönSähköposti);
|
root.addRow(root.getRowCount(), jälkiruoat, tfJälkiruoat);
|
||||||
|
|
||||||
|
root.addRow(root.getRowCount(), new Label("Kuljetukset per päivä"));
|
||||||
|
|
||||||
|
Label maanantai = new Label("Maanantai");
|
||||||
|
tfMaanantai = new IntegerSpinner();
|
||||||
|
root.addRow(root.getRowCount(), maanantai, tfMaanantai);
|
||||||
|
|
||||||
|
Label tiistai = new Label("Tiistai");
|
||||||
|
tfTiistai = new IntegerSpinner();
|
||||||
|
root.addRow(root.getRowCount(), tiistai, tfTiistai);
|
||||||
|
|
||||||
|
Label keskiviikko = new Label("Keskiviikko");
|
||||||
|
tfKeskiviikko = new IntegerSpinner();
|
||||||
|
root.addRow(root.getRowCount(), keskiviikko, tfKeskiviikko);
|
||||||
|
|
||||||
|
Label torstai = new Label("Torstai");
|
||||||
|
tfTorstai = new IntegerSpinner();
|
||||||
|
root.addRow(root.getRowCount(), torstai, tfTorstai);
|
||||||
|
|
||||||
|
Label perjantai = new Label("Perjantai");
|
||||||
|
tfPerjantai = new IntegerSpinner();
|
||||||
|
root.addRow(root.getRowCount(), perjantai, tfPerjantai);
|
||||||
|
|
||||||
|
Label ruokarajoitteet = new Label("Ruokarajoitteet");
|
||||||
|
tfRuokarajoitteet = new TextField();
|
||||||
|
root.addRow(root.getRowCount(), ruokarajoitteet, tfRuokarajoitteet);
|
||||||
|
|
||||||
|
Label avainTieto = new Label("Avaintieto");
|
||||||
|
tfAvainTieto = new TextField();
|
||||||
|
root.addRow(root.getRowCount(), avainTieto, tfAvainTieto);
|
||||||
|
|
||||||
|
Label lisätiedot = new Label("Kuljetuksen lisätiedot");
|
||||||
|
tfLisätiedot = new TextField();
|
||||||
|
tfLisätiedot.setPromptText("Näkyy raporteilla");
|
||||||
|
root.addRow(root.getRowCount(), lisätiedot, tfLisätiedot);
|
||||||
|
|
||||||
HBox napit = new HBox();
|
|
||||||
Button peruuta = new Button("Peruuta");
|
Button peruuta = new Button("Peruuta");
|
||||||
peruuta.setFont(TabPohja.buttonFont);
|
peruuta.setFont(TabPohja.buttonFont);
|
||||||
|
peruuta.setMinWidth(160);
|
||||||
peruuta.setOnAction(_ -> this.close());
|
peruuta.setOnAction(_ -> this.close());
|
||||||
Button tallenna = new Button("Tallenna");
|
Button tallenna = new Button("Tallenna");
|
||||||
tallenna.setFont(TabPohja.buttonFont);
|
tallenna.setFont(TabPohja.buttonFont);
|
||||||
|
tallenna.setMinWidth(160);
|
||||||
tallenna.setOnAction(_ -> tallenna());
|
tallenna.setOnAction(_ -> tallenna());
|
||||||
napit.getChildren().addAll(peruuta, tallenna);
|
root.addRow(root.getRowCount(), peruuta, tallenna);
|
||||||
napit.setAlignment(Pos.CENTER_RIGHT);
|
|
||||||
napit.setSpacing(10);
|
|
||||||
napit.setPadding(TabPohja.oletusInsets);
|
|
||||||
|
|
||||||
|
|
||||||
VBox root = new VBox();
|
|
||||||
root.getChildren().addAll(tabPane, napit);
|
|
||||||
this.setScene(new Scene(root));
|
this.setScene(new Scene(root));
|
||||||
this.getIcons().add(new Image(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
this.getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("kuljetusruokalaatikko.jpg"))));
|
||||||
this.setAlwaysOnTop(true);
|
this.setAlwaysOnTop(true);
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
|
|
||||||
@@ -189,18 +136,12 @@ public class AsiakasIkkuna extends Stage {
|
|||||||
tfKeskiviikko.getValueFactory().setValue(käsiteltäväAsiakas.getKeskiviikkoKpl());
|
tfKeskiviikko.getValueFactory().setValue(käsiteltäväAsiakas.getKeskiviikkoKpl());
|
||||||
tfTorstai.getValueFactory().setValue(käsiteltäväAsiakas.getTorstaiKpl());
|
tfTorstai.getValueFactory().setValue(käsiteltäväAsiakas.getTorstaiKpl());
|
||||||
tfPerjantai.getValueFactory().setValue(käsiteltäväAsiakas.getPerjantaiKpl());
|
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());
|
tfSalaatit.getValueFactory().setValue(käsiteltäväAsiakas.getSalaatit());
|
||||||
tfPääruoat.getValueFactory().setValue(käsiteltäväAsiakas.getPääruoat());
|
tfPääruoat.getValueFactory().setValue(käsiteltäväAsiakas.getPääruoat());
|
||||||
tfJälkiruoat.getValueFactory().setValue(käsiteltäväAsiakas.getJälkiruoat());
|
tfJälkiruoat.getValueFactory().setValue(käsiteltäväAsiakas.getJälkiruoat());
|
||||||
tfRuokarajoitteet.setText(käsiteltäväAsiakas.getErityisruokavalio());
|
tfRuokarajoitteet.setText(käsiteltäväAsiakas.getErityisruokavalio());
|
||||||
tfAvainTieto.setText(käsiteltäväAsiakas.getAvainTieto());
|
tfAvainTieto.setText(käsiteltäväAsiakas.getAvainTieto());
|
||||||
tfLisätiedot.setText(käsiteltäväAsiakas.getLisätiedot());
|
tfLisätiedot.setText(käsiteltäväAsiakas.getLisätiedot());
|
||||||
tfYhteyshenkilönNimi.setText(käsiteltäväAsiakas.getYhteyshenkilönNimi());
|
|
||||||
tfLaskutusOsoite.setText(käsiteltäväAsiakas.getLaskutusOsoite());
|
|
||||||
tfYhteyshenkilönPuhelinnumero.setText(käsiteltäväAsiakas.getYhteyshenkilönPuhelinnumero());
|
|
||||||
tfYhteyshenkilönSähköposti.setText(käsiteltäväAsiakas.getYhteyshenkilönSähköposti());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tallenna() {
|
private void tallenna() {
|
||||||
@@ -224,18 +165,12 @@ public class AsiakasIkkuna extends Stage {
|
|||||||
käsiteltäväAsiakas.setKeskiviikkoKpl(tfKeskiviikko.getValue());
|
käsiteltäväAsiakas.setKeskiviikkoKpl(tfKeskiviikko.getValue());
|
||||||
käsiteltäväAsiakas.setTorstaiKpl(tfTorstai.getValue());
|
käsiteltäväAsiakas.setTorstaiKpl(tfTorstai.getValue());
|
||||||
käsiteltäväAsiakas.setPerjantaiKpl(tfPerjantai.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.setSalaatit(tfSalaatit.getValue());
|
||||||
käsiteltäväAsiakas.setPääruoat(tfPääruoat.getValue());
|
käsiteltäväAsiakas.setPääruoat(tfPääruoat.getValue());
|
||||||
käsiteltäväAsiakas.setJälkiruoat(tfJälkiruoat.getValue());
|
käsiteltäväAsiakas.setJälkiruoat(tfJälkiruoat.getValue());
|
||||||
käsiteltäväAsiakas.setErityisruokavalio(tfRuokarajoitteet.getText());
|
käsiteltäväAsiakas.setErityisruokavalio(tfRuokarajoitteet.getText());
|
||||||
käsiteltäväAsiakas.setAvainTieto(tfAvainTieto.getText());
|
käsiteltäväAsiakas.setAvainTieto(tfAvainTieto.getText());
|
||||||
käsiteltäväAsiakas.setLisätiedot(tfLisätiedot.getText());
|
käsiteltäväAsiakas.setLisätiedot(tfLisätiedot.getText());
|
||||||
käsiteltäväAsiakas.setYhteyshenkilönNimi(tfYhteyshenkilönNimi.getText());
|
|
||||||
käsiteltäväAsiakas.setLaskutusOsoite(tfLaskutusOsoite.getText());
|
|
||||||
käsiteltäväAsiakas.setYhteyshenkilönPuhelinnumero(tfYhteyshenkilönPuhelinnumero.getText());
|
|
||||||
käsiteltäväAsiakas.setYhteyshenkilönSähköposti(tfYhteyshenkilönSähköposti.getText());
|
|
||||||
|
|
||||||
boolean läpi = false;
|
boolean läpi = false;
|
||||||
int maxYritykset = 3;
|
int maxYritykset = 3;
|
||||||
@@ -253,15 +188,9 @@ 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();
|
|
||||||
|
|
||||||
|
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();
|
||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
alert.setTitle("Onnistuimme!");
|
alert.setTitle("Onnistuimme!");
|
||||||
alert.setHeaderText("Asiakkaan tallentaminen onnistui!");
|
alert.setHeaderText("Asiakkaan tallentaminen onnistui!");
|
||||||
+17
-53
@@ -1,22 +1,15 @@
|
|||||||
package fi.lpam.ruokamanageri.gui;
|
package fi.lpam.gui;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.MaaraTableColumn;
|
import fi.lpam.gui.elementit.MaaraTableColumn;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
import fi.lpam.gui.elementit.TabPohja;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.input.KeyCode;
|
import javafx.scene.input.KeyCode;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -40,30 +33,19 @@ public class Asiakashallinta extends TabPohja {
|
|||||||
yläpalkinNapit.setSpacing(5);
|
yläpalkinNapit.setSpacing(5);
|
||||||
yläpalkki.setRight(yläpalkinNapit);
|
yläpalkki.setRight(yläpalkinNapit);
|
||||||
|
|
||||||
Button avaaVersioloki = new Button("VERSIOLOKI");
|
|
||||||
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");
|
Button poistaValittu = new Button("Poista");
|
||||||
poistaValittu.setOnAction(_ -> poistaValittu());
|
poistaValittu.setOnAction(_ -> poistaValittu());
|
||||||
poistaValittu.setFont(buttonFont);
|
poistaValittu.setFont(TabPohja.buttonFont);
|
||||||
yläpalkinNapit.getChildren().add(poistaValittu);
|
yläpalkinNapit.getChildren().add(poistaValittu);
|
||||||
|
|
||||||
Button muokkaaAsiakasta = new Button("Muokkaa");
|
Button muokkaaAsiakasta = new Button("Muokkaa");
|
||||||
muokkaaAsiakasta.setOnAction(_ -> muokkaaValittua());
|
muokkaaAsiakasta.setOnAction(_ -> muokkaaValittua());
|
||||||
muokkaaAsiakasta.setFont(buttonFont);
|
muokkaaAsiakasta.setFont(TabPohja.buttonFont);
|
||||||
yläpalkinNapit.getChildren().add(muokkaaAsiakasta);
|
yläpalkinNapit.getChildren().add(muokkaaAsiakasta);
|
||||||
|
|
||||||
Button uusiAsiakas = new Button("Uusi asiakas");
|
Button uusiAsiakas = new Button("Uusi asiakas");
|
||||||
uusiAsiakas.setOnAction(_ -> uusiAsiakas());
|
uusiAsiakas.setOnAction(_ -> uusiAsiakas());
|
||||||
uusiAsiakas.setFont(buttonFont);
|
uusiAsiakas.setFont(TabPohja.buttonFont);
|
||||||
yläpalkinNapit.getChildren().add(uusiAsiakas);
|
yläpalkinNapit.getChildren().add(uusiAsiakas);
|
||||||
|
|
||||||
tvAsiakkaat.setEditable(false);
|
tvAsiakkaat.setEditable(false);
|
||||||
@@ -90,30 +72,25 @@ public class Asiakashallinta extends TabPohja {
|
|||||||
tcOsoite.setMinWidth(250);
|
tcOsoite.setMinWidth(250);
|
||||||
tcOsoite.setCellValueFactory(new PropertyValueFactory<>("osoite"));
|
tcOsoite.setCellValueFactory(new PropertyValueFactory<>("osoite"));
|
||||||
|
|
||||||
int minWidth = 40;
|
|
||||||
TableColumn<Asiakas, MaaraTableColumn<Asiakas, Integer>> tcKuljetuspäivät = new TableColumn<>("Kuljetukset per päivä");
|
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"));
|
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"));
|
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"));
|
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"));
|
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"));
|
tcPerjantaiKpl.setCellValueFactory(new PropertyValueFactory<>("perjantaiKpl"));
|
||||||
MaaraTableColumn<Asiakas, Integer> tcLauantaiKpl = new MaaraTableColumn<>("LA", minWidth);
|
tcKuljetuspäivät.getColumns().addAll(tcMaanantaiKpl, tcTiistaiKpl, tcKeskiviikkoKpl, tcTorstaiKpl, tcPerjantaiKpl);
|
||||||
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);
|
|
||||||
|
|
||||||
TableColumn<Asiakas, MaaraTableColumn<Asiakas, Integer>> tcKuljetusmäärät = new TableColumn<>("Määrät per kuljetus");
|
TableColumn<Asiakas, MaaraTableColumn<Asiakas, Integer>> tcKuljetusmäärät = new TableColumn<>("Määrät per kuljetus");
|
||||||
MaaraTableColumn<Asiakas, Integer> tcSalaatit = new MaaraTableColumn<>("Salaatit", 80);
|
MaaraTableColumn<Asiakas, Integer> tcSalaatit = new MaaraTableColumn<>("Salaatit", 90);
|
||||||
tcSalaatit.setCellValueFactory(new PropertyValueFactory<>("salaatit"));
|
tcSalaatit.setCellValueFactory(new PropertyValueFactory<>("salaatit"));
|
||||||
MaaraTableColumn<Asiakas, Integer> tcPääruoat = new MaaraTableColumn<>("Pääruoat", 80);
|
MaaraTableColumn<Asiakas, Integer> tcPääruoat = new MaaraTableColumn<>("Pääruoat", 90);
|
||||||
tcPääruoat.setCellValueFactory(new PropertyValueFactory<>("pääruoat"));
|
tcPääruoat.setCellValueFactory(new PropertyValueFactory<>("pääruoat"));
|
||||||
MaaraTableColumn<Asiakas, Integer> tcJälkiruoat = new MaaraTableColumn<>("Jälkiruoat", 80);
|
MaaraTableColumn<Asiakas, Integer> tcJälkiruoat = new MaaraTableColumn<>("Jälkiruoat", 90);
|
||||||
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
||||||
tcKuljetusmäärät.getColumns().addAll(tcSalaatit, tcPääruoat, tcJälkiruoat);
|
tcKuljetusmäärät.getColumns().addAll(tcSalaatit, tcPääruoat, tcJälkiruoat);
|
||||||
|
|
||||||
@@ -126,21 +103,8 @@ public class Asiakashallinta extends TabPohja {
|
|||||||
TableColumn<Asiakas, String> tcLisätiedot = new TableColumn<>("Lisätieto kuljetukselle");
|
TableColumn<Asiakas, String> tcLisätiedot = new TableColumn<>("Lisätieto kuljetukselle");
|
||||||
tcLisätiedot.setMinWidth(250);
|
tcLisätiedot.setMinWidth(250);
|
||||||
tcLisätiedot.setCellValueFactory(new PropertyValueFactory<>("lisätiedot"));
|
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(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);
|
||||||
for (TableColumn<Asiakas, ?> column : tvAsiakkaat.getColumns()) {
|
for (TableColumn<Asiakas, ?> column : tvAsiakkaat.getColumns()) {
|
||||||
column.setEditable(false);
|
column.setEditable(false);
|
||||||
column.setReorderable(false);
|
column.setReorderable(false);
|
||||||
+5
-6
@@ -1,11 +1,11 @@
|
|||||||
package fi.lpam.ruokamanageri.gui;
|
package fi.lpam.gui;
|
||||||
|
|
||||||
import com.dlsc.gemsfx.MultiColumnListView;
|
import com.dlsc.gemsfx.MultiColumnListView;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Kierros;
|
import fi.lpam.dataluokat.Kierros;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.AsiakasListCell;
|
import fi.lpam.gui.elementit.AsiakasListCell;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
import fi.lpam.gui.elementit.TabPohja;
|
||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -104,7 +104,6 @@ public class Kierroshallinta extends TabPohja {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < kierrokset.size();) {
|
for (int i = 0; i < kierrokset.size();) {
|
||||||
Kierros k = kierrokset.get(i);
|
Kierros k = kierrokset.get(i);
|
||||||
k.setAsiakkaat(FXCollections.observableArrayList(new ArrayList<>()));
|
|
||||||
k.setAsiakkaat(mclv.getColumns().get(index).getItems());
|
k.setAsiakkaat(mclv.getColumns().get(index).getItems());
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
+12
-12
@@ -1,19 +1,19 @@
|
|||||||
package fi.lpam.ruokamanageri.gui;
|
package fi.lpam.gui;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Kierros;
|
import fi.lpam.dataluokat.Kierros;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
import fi.lpam.dataluokat.Kuljetus;
|
||||||
import fi.lpam.ruokamanageri.gui.tableCell.IntegerFieldTableCellFactory;
|
import fi.lpam.gui.elementit.KuljetaTableCell;
|
||||||
import fi.lpam.ruokamanageri.gui.tableCell.KuljetaTableCell;
|
import fi.lpam.tulostajat.KuljetusListaTulostaja;
|
||||||
import fi.lpam.ruokamanageri.tulostajat.KuljetusListaTulostaja;
|
import fi.lpam.gui.elementit.MaaraTableColumn;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.MaaraTableColumn;
|
import fi.lpam.gui.elementit.TabPohja;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
|
||||||
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.control.cell.ChoiceBoxTableCell;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.control.cell.TextFieldTableCell;
|
import javafx.scene.control.cell.TextFieldTableCell;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
@@ -109,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");});
|
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);
|
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.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");});
|
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);
|
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.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");});
|
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);
|
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.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");});
|
tcJälkiruoat.setOnEditCommit((TableColumn.CellEditEvent<Kuljetus, Integer> event) -> {event.getTableView().getItems().get(event.getTablePosition().getRow()).setJälkiruoat(event.getNewValue()); tallennusStatus.setText("Tallennettu: Ei");});
|
||||||
|
|
||||||
+10
-30
@@ -1,9 +1,9 @@
|
|||||||
package fi.lpam.ruokamanageri.gui;
|
package fi.lpam.gui;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
import fi.lpam.dataluokat.RaporttiRivi;
|
||||||
import fi.lpam.ruokamanageri.tulostajat.KuljetusRaporttiTulostaja;
|
import fi.lpam.tulostajat.KuljetusRaporttiTulostaja;
|
||||||
import fi.lpam.ruokamanageri.gui.tableCell.PaivamaaraTableCell;
|
import fi.lpam.gui.elementit.PaivamaaraTableCell;
|
||||||
import fi.lpam.ruokamanageri.gui.elementit.TabPohja;
|
import fi.lpam.gui.elementit.TabPohja;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@@ -59,21 +59,18 @@ public class KuljetusRaportit extends TabPohja {
|
|||||||
Button tulostaRaportti = new Button("Tulosta raportti");
|
Button tulostaRaportti = new Button("Tulosta raportti");
|
||||||
tulostaRaportti.setFont(buttonFont);
|
tulostaRaportti.setFont(buttonFont);
|
||||||
tulostaRaportti.setOnAction(_ ->tulostaRaportti());
|
tulostaRaportti.setOnAction(_ ->tulostaRaportti());
|
||||||
yläpalkinNapit.getChildren().addAll(tarkka,
|
yläpalkinNapit.getChildren().addAll(tarkka, new Label("Hae kuljetukset välillä:"), alkuPvm, new Label("-"), loppuPvm, haeKuljetukset, tulostaRaportti);
|
||||||
new Label("Hae kuljetukset välillä:"),
|
|
||||||
alkuPvm, new Label("-"), loppuPvm,
|
|
||||||
haeKuljetukset, tulostaRaportti);
|
|
||||||
|
|
||||||
root.setCenter(tableView);
|
root.setCenter(tableView);
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcNimi = new TableColumn<>("Nimi");
|
TableColumn<RaporttiRivi, String> tcNimi = new TableColumn<>("Nimi");
|
||||||
tcNimi.setMinWidth(200);
|
tcNimi.setMinWidth(150);
|
||||||
tcNimi.setCellValueFactory(new PropertyValueFactory<>("nimi"));
|
tcNimi.setCellValueFactory(new PropertyValueFactory<>("nimi"));
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, LocalDate> tcPvm = new TableColumn<>("Päivämäärä");
|
TableColumn<RaporttiRivi, LocalDate> tcPvm = new TableColumn<>("Päivämäärä");
|
||||||
tcPvm.setMinWidth(150);
|
tcPvm.setMinWidth(150);
|
||||||
tcPvm.setCellFactory(_ ->new PaivamaaraTableCell());
|
tcPvm.setCellFactory(_ ->new PaivamaaraTableCell());
|
||||||
tcPvm.setCellValueFactory(new PropertyValueFactory<>("pvm"));
|
tcPvm.setCellValueFactory(new PropertyValueFactory<>("loppuPvm"));
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, Integer> tcSalaatit = new TableColumn<>("Salaatit");
|
TableColumn<RaporttiRivi, Integer> tcSalaatit = new TableColumn<>("Salaatit");
|
||||||
tcSalaatit.setMinWidth(100);
|
tcSalaatit.setMinWidth(100);
|
||||||
@@ -88,27 +85,10 @@ public class KuljetusRaportit extends TabPohja {
|
|||||||
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
tcJälkiruoat.setCellValueFactory(new PropertyValueFactory<>("jälkiruoat"));
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcLisätiedot = new TableColumn<>("Lisätiedot");
|
TableColumn<RaporttiRivi, String> tcLisätiedot = new TableColumn<>("Lisätiedot");
|
||||||
tcLisätiedot.setMinWidth(300);
|
tcLisätiedot.setMinWidth(500);
|
||||||
tcLisätiedot.setCellValueFactory(new PropertyValueFactory<>("lisätiedot"));
|
tcLisätiedot.setCellValueFactory(new PropertyValueFactory<>("lisätiedot"));
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcYhteyshenkilönNimi = new TableColumn<>("Yhteyshenkilön nimi");
|
tableView.getColumns().addAll(tcNimi, tcPvm, tcSalaatit, tcPääruoat, tcJälkiruoat, tcLisätiedot);
|
||||||
tcYhteyshenkilönNimi.setMinWidth(200);
|
|
||||||
tcYhteyshenkilönNimi.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönNimi"));
|
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcLaskutusOsoite = new TableColumn<>("Laskutusosoite");
|
|
||||||
tcLaskutusOsoite.setMinWidth(200);
|
|
||||||
tcLaskutusOsoite.setCellValueFactory(new PropertyValueFactory<>("laskutusOsoite"));
|
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcYhteyshenkilönPuhelinnumero = new TableColumn<>("Puhelinnumero");
|
|
||||||
tcYhteyshenkilönPuhelinnumero.setMinWidth(200);
|
|
||||||
tcYhteyshenkilönPuhelinnumero.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönPuhelinnumero"));
|
|
||||||
|
|
||||||
TableColumn<RaporttiRivi, String> tcYhteyshenkilönSähköposti = new TableColumn<>("Sähköposti");
|
|
||||||
tcYhteyshenkilönSähköposti.setMinWidth(200);
|
|
||||||
tcYhteyshenkilönSähköposti.setCellValueFactory(new PropertyValueFactory<>("yhteyshenkilönSähköposti"));
|
|
||||||
|
|
||||||
tableView.getColumns().addAll(tcNimi, tcPvm, tcSalaatit, tcPääruoat, tcJälkiruoat, tcLisätiedot,
|
|
||||||
tcYhteyshenkilönNimi, tcLaskutusOsoite, tcYhteyshenkilönPuhelinnumero, tcYhteyshenkilönSähköposti);
|
|
||||||
tableView.setPlaceholder(new Label("Hae raportti"));
|
tableView.setPlaceholder(new Label("Hae raportti"));
|
||||||
for (TableColumn<RaporttiRivi, ?> sarake : tableView.getColumns()) {
|
for (TableColumn<RaporttiRivi, ?> sarake : tableView.getColumns()) {
|
||||||
sarake.setSortable(false);
|
sarake.setSortable(false);
|
||||||
+3
-2
@@ -1,9 +1,10 @@
|
|||||||
package fi.lpam.ruokamanageri.gui.elementit;
|
package fi.lpam.gui.elementit;
|
||||||
|
|
||||||
import com.dlsc.gemsfx.MultiColumnListView;
|
import com.dlsc.gemsfx.MultiColumnListView;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.ContentDisplay;
|
import javafx.scene.control.ContentDisplay;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package fi.lpam.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.ruokamanageri.gui.tableCell;
|
package fi.lpam.gui.elementit;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Asiakas;
|
import fi.lpam.dataluokat.Asiakas;
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
import fi.lpam.dataluokat.Kuljetus;
|
||||||
import fi.lpam.ruokamanageri.gui.KuljetusListat;
|
import fi.lpam.gui.KuljetusListat;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ContentDisplay;
|
import javafx.scene.control.ContentDisplay;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
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) {
|
||||||
|
super(columnLabel);
|
||||||
|
this.setResizable(false);
|
||||||
|
this.setReorderable(false);
|
||||||
|
this.setMinWidth(minWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package fi.lpam.ruokamanageri.gui.tableCell;
|
package fi.lpam.gui.elementit;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
import fi.lpam.dataluokat.RaporttiRivi;
|
||||||
import javafx.scene.control.TableCell;
|
import javafx.scene.control.TableCell;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
package fi.lpam.ruokamanageri.gui.elementit;
|
package fi.lpam.gui.elementit;
|
||||||
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
@@ -12,6 +12,7 @@ import javafx.scene.text.FontWeight;
|
|||||||
public class TabPohja extends StackPane {
|
public class TabPohja extends StackPane {
|
||||||
public static final Insets oletusInsets = new Insets(5);
|
public static final Insets oletusInsets = new Insets(5);
|
||||||
public static final String oletusStyle = "-fx-background-color: lightgray;";
|
public static final String oletusStyle = "-fx-background-color: lightgray;";
|
||||||
|
public static final Font otsikkoFont = Font.font("Open Sans", FontWeight.BOLD, 18);
|
||||||
public static final Font buttonFont = Font.font("Open Sans", FontWeight.BOLD, 16);
|
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 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 static final Border oletusBorder = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package fi.lpam.ruokamanageri.gui.virheDialogit;
|
package fi.lpam.gui.virheDialogit;
|
||||||
|
|
||||||
public class SiirtoVirhe extends TietokantaVirhe{
|
public class SiirtoVirhe extends TietokantaVirhe{
|
||||||
public SiirtoVirhe(Exception e){
|
public SiirtoVirhe(Exception e){
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package fi.lpam.ruokamanageri.gui.virheDialogit;
|
package fi.lpam.gui.virheDialogit;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.Main;
|
import fi.lpam.Main;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
@@ -12,7 +12,7 @@ abstract class TietokantaVirhe extends Alert {
|
|||||||
public TietokantaVirhe() {
|
public TietokantaVirhe() {
|
||||||
super(AlertType.ERROR);
|
super(AlertType.ERROR);
|
||||||
this.setTitle("Tietokanta");
|
this.setTitle("Tietokanta");
|
||||||
ImageView sql = new ImageView(new Image(Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("tietokanta.png"))));
|
ImageView sql = new ImageView(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("tietokanta.png"))));
|
||||||
sql.setPreserveRatio(true);
|
sql.setPreserveRatio(true);
|
||||||
sql.setFitHeight(100);
|
sql.setFitHeight(100);
|
||||||
this.setGraphic(sql);
|
this.setGraphic(sql);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package fi.lpam.gui.virheDialogit;
|
||||||
|
|
||||||
|
public class YhteysVirhe extends TietokantaVirhe{
|
||||||
|
public YhteysVirhe(Exception error){
|
||||||
|
this.setHeaderText("Virhe yhdistäessä tietokantaan");
|
||||||
|
this.setContentText(error.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
@SuppressWarnings({"ClassCanBeRecord", "DuplicatedCode"})
|
|
||||||
public class RaporttiRivi {
|
|
||||||
private final String nimi;
|
|
||||||
private final LocalDate pvm;
|
|
||||||
private final int salaatit, pääruoat, jälkiruoat;
|
|
||||||
private final String lisätiedot;
|
|
||||||
private final String yhteyshenkilönNimi, laskutusOsoite, yhteyshenkilönPuhelinnumero, yhteyshenkilönSähköposti;
|
|
||||||
|
|
||||||
public RaporttiRivi(String nimi,
|
|
||||||
LocalDate pvm,
|
|
||||||
int salaatit,
|
|
||||||
int pääruoat,
|
|
||||||
int jälkiruoat,
|
|
||||||
String lisätiedot,
|
|
||||||
String yhteyshenkilönNimi,
|
|
||||||
String laskutusOsoite,
|
|
||||||
String yhteyshenkilönPuhelinnumero,
|
|
||||||
String yhteyshenkilönSähköposti) {
|
|
||||||
this.nimi = nimi;
|
|
||||||
this.pvm = pvm;
|
|
||||||
this.salaatit = salaatit;
|
|
||||||
this.pääruoat = pääruoat;
|
|
||||||
this.jälkiruoat = jälkiruoat;
|
|
||||||
this.lisätiedot = lisätiedot;
|
|
||||||
this.yhteyshenkilönNimi = yhteyshenkilönNimi;
|
|
||||||
this.laskutusOsoite = laskutusOsoite;
|
|
||||||
this.yhteyshenkilönPuhelinnumero = yhteyshenkilönPuhelinnumero;
|
|
||||||
this.yhteyshenkilönSähköposti = yhteyshenkilönSähköposti;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<RaporttiRivi> haeRaportti(LocalDate alkuPvm, LocalDate loppuPvm, boolean tarkka) {
|
|
||||||
ArrayList<RaporttiRivi> raportti = new ArrayList<>();
|
|
||||||
try (Connection tietokanta = Tietokanta.haeYhteys()) {
|
|
||||||
ResultSet rs;
|
|
||||||
if (tarkka) {
|
|
||||||
//Jokainen kuljetus saa oman rivin
|
|
||||||
PreparedStatement stmt = tietokanta.prepareStatement("""
|
|
||||||
select kuljetukset.asiakasID,
|
|
||||||
kuljetukset.nimi,
|
|
||||||
kuljetukset.kuljetusPäivämäärä,
|
|
||||||
kuljetukset.salaatit,
|
|
||||||
kuljetukset.pääruoat,
|
|
||||||
kuljetukset.jälkiruoat,
|
|
||||||
kuljetukset.lisätieto,
|
|
||||||
asiakkaat.yhteyshenkilönNimi,
|
|
||||||
asiakkaat.laskutusosoite,
|
|
||||||
asiakkaat.yhteyshenkilönPuhelinnumero,
|
|
||||||
asiakkaat.yhteyshenkilönSähköposti
|
|
||||||
from kuljetukset
|
|
||||||
left join asiakkaat on kuljetukset.asiakasID=asiakkaat.id
|
|
||||||
where kuljetusPäivämäärä between ? and ?
|
|
||||||
order by kuljetukset.nimi
|
|
||||||
""");
|
|
||||||
stmt.setDate(1, Date.valueOf(alkuPvm));
|
|
||||||
stmt.setDate(2, Date.valueOf(loppuPvm));
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
int i = 2;
|
|
||||||
RaporttiRivi uusi = new RaporttiRivi(
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getDate(i++).toLocalDate(),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++)
|
|
||||||
);
|
|
||||||
raportti.add(uusi);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//Kuljetukset summataan yhteen riviin per vastaanottaja
|
|
||||||
PreparedStatement stmt = tietokanta.prepareStatement("""
|
|
||||||
select kuljetukset.asiakasID,
|
|
||||||
kuljetukset.nimi,
|
|
||||||
kuljetukset.kuljetusPäivämäärä,
|
|
||||||
sum(kuljetukset.salaatit),
|
|
||||||
sum(kuljetukset.pääruoat),
|
|
||||||
sum(kuljetukset.jälkiruoat),
|
|
||||||
group_concat(kuljetukset.lisätieto, ?),
|
|
||||||
asiakkaat.yhteyshenkilönNimi,
|
|
||||||
asiakkaat.laskutusosoite,
|
|
||||||
asiakkaat.yhteyshenkilönPuhelinnumero,
|
|
||||||
asiakkaat.yhteyshenkilönSähköposti
|
|
||||||
from kuljetukset
|
|
||||||
left join asiakkaat on kuljetukset.asiakasID=asiakkaat.id
|
|
||||||
where kuljetusPäivämäärä between ? and ?
|
|
||||||
group by kuljetukset.nimi
|
|
||||||
order by kuljetukset.nimi
|
|
||||||
""");
|
|
||||||
stmt.setString(1, "\n");
|
|
||||||
stmt.setDate(2, Date.valueOf(alkuPvm));
|
|
||||||
stmt.setDate(3, Date.valueOf(loppuPvm));
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
int i = 2;
|
|
||||||
RaporttiRivi uusi = new RaporttiRivi(
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getDate(i++).toLocalDate(),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getInt(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++),
|
|
||||||
rs.getString(i++)
|
|
||||||
);
|
|
||||||
raportti.add(uusi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
|
||||||
virhe.showAndWait();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return raportti;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
String laskutustiedot = "\n" + yhteyshenkilönNimi +
|
|
||||||
"\n" + laskutusOsoite +
|
|
||||||
"\n" + yhteyshenkilönPuhelinnumero +
|
|
||||||
"\n" + yhteyshenkilönSähköposti;
|
|
||||||
|
|
||||||
return nimi +
|
|
||||||
"\nSal: " + salaatit + ", Pr: " + pääruoat + ", Jr: " + jälkiruoat +
|
|
||||||
"\nLisätiedot:\n" +
|
|
||||||
getLisätiedot() +
|
|
||||||
laskutustiedot.replace("\nnull", "").strip();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNimi() {
|
|
||||||
return nimi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDate getPvm() {
|
|
||||||
return pvm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSalaatit() {
|
|
||||||
return salaatit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPääruoat() {
|
|
||||||
return pääruoat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getJälkiruoat() {
|
|
||||||
return jälkiruoat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLisätiedot() {
|
|
||||||
if (lisätiedot == null) return null;
|
|
||||||
return lisätiedot.strip().trim().stripLeading().stripTrailing();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönNimi() {
|
|
||||||
return yhteyshenkilönNimi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLaskutusOsoite() {
|
|
||||||
return laskutusOsoite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönPuhelinnumero() {
|
|
||||||
return yhteyshenkilönPuhelinnumero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYhteyshenkilönSähköposti() {
|
|
||||||
return yhteyshenkilönSähköposti;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
package fi.lpam.ruokamanageri.dataluokat;
|
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.Main;
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Tietokanta {
|
|
||||||
private static String osoite;
|
|
||||||
private static String dbPath = SystemUtils.getUserHome().getAbsolutePath() + "\\OneDrive\\Kuljetusruokasovellus\\tietokanta.db";
|
|
||||||
|
|
||||||
public Tietokanta(boolean dev) {
|
|
||||||
if (dev) dbPath = "testikanta.db";
|
|
||||||
File file = new File(dbPath);
|
|
||||||
try {
|
|
||||||
boolean _ = file.getParentFile().mkdirs();
|
|
||||||
boolean _ = file.createNewFile();
|
|
||||||
}
|
|
||||||
catch (Exception _) {}
|
|
||||||
|
|
||||||
osoite = "jdbc:sqlite:" + file.getAbsolutePath();
|
|
||||||
|
|
||||||
|
|
||||||
try (Connection conn = haeYhteys()) {
|
|
||||||
InputStream is = Objects.requireNonNull(Main.class.getClassLoader().getResourceAsStream("tietokanta.sql"));
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
|
||||||
String sql = br.readAllAsString();
|
|
||||||
|
|
||||||
for (String query : sql.split(";")) {
|
|
||||||
conn.createStatement().execute(query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException | IOException e) {
|
|
||||||
handleException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Lisää kuljetuspäivät asiakassarakkeeseen (v2.0.2->3.x.x)
|
|
||||||
String[] sarakkeet = {"lauantaiKpl", "sunnuntaiKpl"};
|
|
||||||
for (String sarake : sarakkeet) {
|
|
||||||
try (Connection conn = haeYhteys()) {
|
|
||||||
PreparedStatement stmt = conn.prepareStatement("alter table asiakkaat add column " + sarake + " int not null default 0");
|
|
||||||
stmt.execute();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
if (!e.getMessage().contains("duplicate column name")) {
|
|
||||||
handleException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Connection haeYhteys() {
|
|
||||||
Connection connection = null;
|
|
||||||
try {
|
|
||||||
connection = DriverManager.getConnection(osoite);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
handleException(e);
|
|
||||||
}
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleException(Exception e) {
|
|
||||||
SiirtoVirhe virhe = new SiirtoVirhe(e);
|
|
||||||
virhe.showAndWait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package fi.lpam.ruokamanageri.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,21 +0,0 @@
|
|||||||
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 width) {
|
|
||||||
super(columnLabel);
|
|
||||||
this.setResizable(false);
|
|
||||||
this.setReorderable(false);
|
|
||||||
this.setMinWidth(width);
|
|
||||||
this.setMaxWidth(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaaraTableColumn(String columnLabel, int minWidth, int maxWidth) {
|
|
||||||
super(columnLabel);
|
|
||||||
this.setResizable(false);
|
|
||||||
this.setReorderable(false);
|
|
||||||
this.setMinWidth(minWidth);
|
|
||||||
this.setMaxWidth(maxWidth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package fi.lpam.ruokamanageri.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+4
-4
@@ -1,11 +1,12 @@
|
|||||||
package fi.lpam.ruokamanageri.tulostajat;
|
package fi.lpam.tulostajat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.Kuljetus;
|
import fi.lpam.dataluokat.Kuljetus;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class KuljetusListaTulostaja extends Tulostaja{
|
public class KuljetusListaTulostaja extends Tulostaja{
|
||||||
final float NIMEN_LEVEYS = 200;
|
final float NIMEN_LEVEYS = 200;
|
||||||
final float OSOITTEEN_LEVEYS = 200;
|
final float OSOITTEEN_LEVEYS = 200;
|
||||||
@@ -44,9 +45,8 @@ public class KuljetusListaTulostaja extends Tulostaja{
|
|||||||
siirräOsoitinta(NIMEN_LEVEYS);
|
siirräOsoitinta(NIMEN_LEVEYS);
|
||||||
sisältö.showText(kuljetus.getLisätieto());
|
sisältö.showText(kuljetus.getLisätieto());
|
||||||
uusiRivi(RIVI_KORKEUS*0.1F);
|
uusiRivi(RIVI_KORKEUS*0.1F);
|
||||||
sisältö.showText("___________________________________________________________________"); //67 alaviivaa (noin sivun leveys)
|
sisältö.showText("___________________________________________________________________");
|
||||||
}
|
}
|
||||||
|
|
||||||
tulosta();
|
tulosta();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
+12
-4
@@ -1,16 +1,24 @@
|
|||||||
package fi.lpam.ruokamanageri.tulostajat;
|
package fi.lpam.tulostajat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.dataluokat.RaporttiRivi;
|
import fi.lpam.dataluokat.RaporttiRivi;
|
||||||
|
|
||||||
|
import java.awt.print.PrinterJob;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDPage;
|
||||||
|
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||||
|
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
||||||
|
import org.apache.pdfbox.printing.PDFPageable;
|
||||||
|
|
||||||
|
@SuppressWarnings("DuplicatedCode")
|
||||||
public class KuljetusRaporttiTulostaja extends Tulostaja {
|
public class KuljetusRaporttiTulostaja extends Tulostaja {
|
||||||
public void luoRaportti(ArrayList<RaporttiRivi> raporttiRivit, LocalDate alkuPvm, LocalDate loppuPvm) {
|
public void luoRaportti(ArrayList<RaporttiRivi> raporttiRivit, LocalDate alkuPvm, LocalDate loppuPvm) {
|
||||||
try {
|
try {
|
||||||
sisältö.showText("Raportti aikaväliltä " + alkuPvm.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + " - " + loppuPvm.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
|
sisältö.showText("Raportti aikaväliltä " + alkuPvm + " - " + loppuPvm);
|
||||||
uusiRivi();
|
uusiRivi();
|
||||||
uusiRivi();
|
uusiRivi();
|
||||||
|
|
||||||
+8
-8
@@ -1,6 +1,6 @@
|
|||||||
package fi.lpam.ruokamanageri.tulostajat;
|
package fi.lpam.tulostajat;
|
||||||
|
|
||||||
import fi.lpam.ruokamanageri.gui.virheDialogit.SiirtoVirhe;
|
import fi.lpam.gui.virheDialogit.SiirtoVirhe;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
import org.apache.pdfbox.pdmodel.PDPage;
|
||||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||||
@@ -15,18 +15,18 @@ import java.awt.print.PrinterJob;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class Tulostaja {
|
public abstract class Tulostaja {
|
||||||
final PDRectangle SIVUKOKO = PDRectangle.A4;
|
PDRectangle SIVUKOKO = PDRectangle.A4;
|
||||||
final PDFont FONTTI = new PDType1Font(Standard14Fonts.FontName.HELVETICA);
|
final PDFont FONTTI = new PDType1Font(Standard14Fonts.FontName.HELVETICA);
|
||||||
final float FONTTI_KOKO = 13;
|
final float FONTTI_KOKO = 13;
|
||||||
final float MARGINAALI = 50;
|
final float MARGINAALI = 50;
|
||||||
final float RIVI_KORKEUS = FONTTI_KOKO * 1.2F;
|
final float RIVI_KORKEUS = FONTTI_KOKO * 1.2F;
|
||||||
|
|
||||||
final PDDocument dokumentti;
|
PDDocument dokumentti;
|
||||||
PDPage nykyinenSivu = null;
|
PDPage nykyinenSivu = null;
|
||||||
PDPageContentStream sisältö = null;
|
PDPageContentStream sisältö = null;
|
||||||
final float sivunLeveys;
|
float sivunLeveys;
|
||||||
final float startX;
|
float startX;
|
||||||
final float startY;
|
float startY;
|
||||||
float yOffset;
|
float yOffset;
|
||||||
float xOffset;
|
float xOffset;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public abstract class Tulostaja {
|
|||||||
uusiRivi(RIVI_KORKEUS);
|
uusiRivi(RIVI_KORKEUS);
|
||||||
}
|
}
|
||||||
/**Siirtää osoitinta sivulla. + oikealle, - vasemmalle*/
|
/**Siirtää osoitinta sivulla. + oikealle, - vasemmalle*/
|
||||||
void siirräOsoitinta(@SuppressWarnings("SameParameterValue") float tX) {
|
void siirräOsoitinta(float tX) {
|
||||||
try {
|
try {
|
||||||
sisältö.newLineAtOffset(tX, 0);
|
sisältö.newLineAtOffset(tX, 0);
|
||||||
xOffset += tX;
|
xOffset += tX;
|
||||||
@@ -9,6 +9,6 @@ module fi.lpam.ruokamanageri {
|
|||||||
requires org.apache.pdfbox;
|
requires org.apache.pdfbox;
|
||||||
requires org.apache.commons.lang3;
|
requires org.apache.commons.lang3;
|
||||||
|
|
||||||
opens fi.lpam.ruokamanageri.dataluokat to javafx.base;
|
opens fi.lpam.dataluokat to javafx.base;
|
||||||
exports fi.lpam.ruokamanageri;
|
exports fi.lpam;
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: fi.lpam.ruokamanageri.Main
|
Main-Class: fi.lpam.Main
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 267 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
@@ -12,11 +12,7 @@ create table if not exists asiakkaat (
|
|||||||
jälkiruoat int not null,
|
jälkiruoat int not null,
|
||||||
erityisruokavalio varchar(255),
|
erityisruokavalio varchar(255),
|
||||||
avainTieto varchar(255),
|
avainTieto varchar(255),
|
||||||
lisätiedot text,
|
lisätiedot text
|
||||||
laskutusosoite varchar(255),
|
|
||||||
yhteyshenkilönNimi varchar(255),
|
|
||||||
yhteyshenkilönPuhelinnumero varchar(255),
|
|
||||||
yhteyshenkilönSähköposti varchar(255)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists kierrokset (
|
create table if not exists kierrokset (
|
||||||
Reference in New Issue
Block a user