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

<?import com.andrewlalis.perfin.view.component.AccountHistoryView?>
<?import com.andrewlalis.perfin.view.component.PropertiesPane?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.text.TextFlow?>
<BorderPane
        xmlns="http://javafx.com/javafx"
        xmlns:fx="http://javafx.com/fxml"
        fx:controller="com.andrewlalis.perfin.control.AccountViewController"
>
    <top>
        <Label fx:id="titleLabel" styleClass="std-padding,large-font,bold-text"/>
    </top>
    <center>
        <VBox>
            <!-- Main account properties. -->
            <PropertiesPane vgap="5" hgap="5" styleClass="std-padding,std-spacing">
                <Label text="Name" styleClass="bold-text"/>
                <Label fx:id="accountNameLabel"/>

                <Label text="Number" styleClass="bold-text"/>
                <Label fx:id="accountNumberLabel" styleClass="mono-font"/>

                <Label text="Currency" styleClass="bold-text"/>
                <Label fx:id="accountCurrencyLabel"/>

                <Label text="Created At" styleClass="bold-text"/>
                <Label fx:id="accountCreatedAtLabel" styleClass="mono-font"/>

                <Label text="Current Balance" styleClass="bold-text"/>
                <VBox>
                    <Label fx:id="accountBalanceLabel" styleClass="mono-font"/>
                    <Label
                            styleClass="small-font,secondary-color-fill"
                    >Derived using nearest recorded balance and transactions.</Label>
                </VBox>
            </PropertiesPane>

            <PropertiesPane vgap="5" hgap="5" fx:id="assetValuePane" styleClass="std-padding,std-spacing">
                <Label text="Latest Assets Value" styleClass="bold-text" labelFor="${latestAssetsValueLabel}"/>
                <VBox>
                    <Label fx:id="latestAssetsValueLabel" styleClass="mono-font"/>
                    <Label
                            styleClass="small-font,secondary-color-fill"
                    >Derived using nearest recorded asset value.</Label>
                </VBox>
            </PropertiesPane>

            <PropertiesPane vgap="5" hgap="5" fx:id="creditCardPropertiesPane" styleClass="std-padding,std-spacing">
                <Label text="Credit Limit" styleClass="bold-text" labelFor="${creditLimitLabel}"/>
                <Label fx:id="creditLimitLabel" styleClass="mono-font"/>
            </PropertiesPane>

            <PropertiesPane vgap="5" hgap="5" fx:id="descriptionPane" styleClass="std-padding,std-spacing">
                <Label text="Description" styleClass="bold-text" labelFor="${accountDescriptionText}"/>
                <TextFlow maxWidth="500"><Text fx:id="accountDescriptionText"/></TextFlow>
            </PropertiesPane>

            <!-- Action buttons -->
            <HBox fx:id="actionsBox" styleClass="std-padding,std-spacing,small-font">
                <Button text="Edit" onAction="#goToEditPage"/>
                <Button text="Record Balance" onAction="#goToCreateBalanceRecord"/>
                <Button text="Record Asset Value" onAction="#goToCreateAssetRecord"/>
                <Button text="Archive" onAction="#archiveAccount"/>
                <Button text="Delete" onAction="#deleteAccount"/>
                <Button text="Unarchive" onAction="#unarchiveAccount"/>
            </HBox>

            <!-- Historical Balance Checker -->
            <VBox styleClass="std-padding,std-spacing">
                <HBox styleClass="std-spacing">
                    <AnchorPane>
                        <Label text="Check Historical Balance" styleClass="bold-text" AnchorPane.topAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"/>
                    </AnchorPane>
                    <DatePicker fx:id="balanceCheckerDatePicker"/>
                    <Button text="Check" fx:id="balanceCheckerButton"/>
                </HBox>
                <TextFlow maxWidth="500">
                    <Text styleClass="small-font,secondary-color-fill">
                        Use this tool to check the balance of this account on any
                        given day in the past. Perfin will compute the balance
                        according to any balance records and transactions it finds
                        around that time.
                    </Text>
                </TextFlow>
            </VBox>


            <!-- Account history -->
            <VBox VBox.vgrow="ALWAYS">
                <Label text="History" styleClass="bold-text,std-padding"/>
                <AccountHistoryView fx:id="accountHistory" initialItemsToLoad="10"/>
            </VBox>
        </VBox>
    </center>
</BorderPane>
