<?xml version="1.0" encoding="UTF-8"?>

<!--
/*
* Copyright (C) 2018, 2019, 2023 Andrew Gegg
 *
 *	This file is part of the Gardeners Notebook application
 *
  * The Gardeners Notebook application is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl.html>.
 */

/*
    Change log
    2.5.0   First version
    2.9.5   Removed unused row in outer GridPane
    3.1.0	Use SafeDatePicker.
 */

-->

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.ContextMenu?>
<!--<?import javafx.scene.control.DatePicker?>-->
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<?import uk.co.gardennotebook.SafeDatePicker?>

<fx:root hgap="5.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="404.0" prefWidth="600.0"
         type="javafx.scene.layout.GridPane" vgap="5.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
    <stylesheets>
        <URL value="@notebook.css"/>
    </stylesheets>

    <columnConstraints>
        <ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
        <ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
        <ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
        <ColumnConstraints hgrow="NEVER" minWidth="10.0"/>
        <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0"/>
    </columnConstraints>

    <rowConstraints>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER"/>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER"/>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER"/>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS"/>
        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER"/>
    </rowConstraints>

    <padding>
        <Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
    </padding>

    <Label alignment="CENTER_RIGHT" prefHeight="17.0" text="%lbl.date" GridPane.columnIndex="0" GridPane.halignment="RIGHT" GridPane.rowIndex="0"/>
<!--    <DatePicker id="dtpDate" fx:id="dtpDate" editable="true" prefWidth="150.0" styleClass="notebook-mandatory-field" GridPane.columnIndex="1"-->
    <SafeDatePicker id="dtpDate" fx:id="dtpDate" editable="true" prefWidth="150.0" styleClass="notebook-mandatory-field" GridPane.columnIndex="1"
                    GridPane.rowIndex="0"/>

    <Label alignment="CENTER_RIGHT" prefHeight="17.0" text="%lbl.purchasedby" GridPane.columnIndex="0" GridPane.halignment="RIGHT" GridPane.rowIndex="1"/>
    <TextField id="purchasedBy" fx:id="purchasedBy" editable="true" prefWidth="150.0" styleClass="notebook-mandatory-field" GridPane.columnIndex="1"
               GridPane.rowIndex="1"/>

    <Label alignment="CENTER_RIGHT" prefHeight="17.0" text="%lbl.totalprice" GridPane.columnIndex="0" GridPane.halignment="RIGHT" GridPane.rowIndex="2"/>
    <TextField id="numTotalPrice" fx:id="numTotalPrice" editable="true" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="2"/>

    <SplitPane dividerPositions="0.20, 0.60" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity"
               orientation="VERTICAL" GridPane.columnIndex="0" GridPane.columnSpan="2147483647" GridPane.hgrow="ALWAYS" GridPane.rowIndex="3"
               GridPane.vgrow="ALWAYS">
        <GridPane>
            <columnConstraints>
                <ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0"/>
            </columnConstraints>
            <rowConstraints>
                <RowConstraints minHeight="10.0" vgrow="NEVER"/>
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS"/>
            </rowConstraints>
            <padding>
                <Insets bottom="5.0"/>
            </padding>
            <Label prefHeight="17.0" text="%lbl.comments" GridPane.halignment="LEFT" GridPane.rowIndex="0" GridPane.valignment="TOP"/>
            <TableView id="tbvComment" fx:id="tbvComment" editable="true" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="0"
                       GridPane.rowIndex="1">
                <columns>
                    <TableColumn fx:id="tbvCommentDate" minWidth="50.0" prefWidth="-1.0" text="%col.comment.date"/>
                    <TableColumn fx:id="tbvCommentText" minWidth="50.0" prefWidth="-1.0" text="%col.comment.text"/>
                </columns>
            </TableView>
        </GridPane>

        <GridPane>
            <columnConstraints>
                <ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0"/>
            </columnConstraints>
            <rowConstraints>
                <RowConstraints minHeight="10.0" vgrow="NEVER"/>
                <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS"/>
            </rowConstraints>
            <padding>
                <Insets bottom="5.0"/>
            </padding>
            <Label text="%lbl.purchaseitems" GridPane.halignment="LEFT" GridPane.rowIndex="0" GridPane.valignment="TOP"/>
            <!-- The SaleItems table must be editable so that new items can be entered directly but existing products must NOT be editable
                        This is enforced in the code
                    -->
            <TableView id="tbvItems" fx:id="tbvItems" editable="true" prefHeight="91.0" prefWidth="483.0" GridPane.rowIndex="1">
                <columns>
                    <TableColumn id="tbvPlantSpecies" fx:id="tbvPlantSpecies" prefWidth="75.0" text="%col.plant.species"/>
                    <TableColumn id="tbvPlantVariety" fx:id="tbvPlantVariety" prefWidth="75.0" text="%col.plant.variety"/>
                    <TableColumn id="tbvQuantity" fx:id="tbvQuantity" style="-fx-alignment: center-right;" text="%col.quantity"/>
                    <TableColumn id="tbvUnit" fx:id="tbvUnit" text="%col.unit"/>
                    <TableColumn id="tbvItemCost" fx:id="tbvItemCost" prefWidth="75.0" style="-fx-alignment: center-right;" text="%col.itemcost"/>
                    <TableColumn id="tbvSIComment" fx:id="tbvSIComment" prefWidth="75.0" text="%col.comment"/>
                </columns>
                <contextMenu>
                    <ContextMenu onShowing="#ctxmnuTopOnAction">
                        <items>
                            <MenuItem id="ctxmnuDelete" fx:id="ctxmnuDelete" onAction="#ctxmnuDeleteOnAction" text="%menu.delete"/>
                            <Menu id="ctxmnuTopHistory" fx:id="ctxmnuTopHistory" mnemonicParsing="false" text="%menu.history">
                                <MenuItem id="ctxmnuAncestors" fx:id="ctxmnuAncestors" onAction="#ctxmnuAncestorsOnAction" text="%menu.ancestors"/>
                            </Menu>
                        </items>
                    </ContextMenu>
                </contextMenu>
            </TableView>
        </GridPane>


    </SplitPane>

    <ButtonBar prefHeight="40.0" prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="4">
        <buttons>
            <Button id="btnCancel" cancelButton="true" mnemonicParsing="false" onAction="#btnCancelOnAction" styleClass="notebook-cmd-button"
                    text="%btn.cancel"/>
            <Button id="btnSave" fx:id="btnSave" mnemonicParsing="false" onAction="#btnSaveOnAction" styleClass="notebook-cmd-button"
                    text="%btn.save"/>   <!-- defaultButton="true" -->
            <Button id="btnDelete" fx:id="btnDelete" mnemonicParsing="false" onAction="#btnDeleteOnAction" styleClass="notebook-cmd-button" text="%btn.delete"/>
        </buttons>
    </ButtonBar>

</fx:root>
