<localView:BeWoView x:Class="BeWo.View.Detail.AccountingTransactionBookingView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:localView="clr-namespace:BeWo.View"
        xmlns:localViewModel="clr-namespace:BeWo.ViewModel" xmlns:localViewDetail="clr-namespace:BeWo.View.Detail"
        xmlns:localViewControls="clr-namespace:BeWo.View.Controls" 
        xmlns:val="clr-namespace:BeWo.Validation" xmlns:proxy="clr-namespace:BeWo.ServiceProxy"
        xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" Height="Auto" Width="Auto"
        HorizontalAlignment="Stretch" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:r="clr-namespace:BeWo.Security"
        VerticalAlignment="Stretch" Focusable="True"
        xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">
    <localView:BeWoView.Resources>
        <ControlTemplate x:Key="AccountingTransactionListBoxTemplate" TargetType="{x:Type ListBox}">
            <Border x:Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}">
                <ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}" HorizontalScrollBarVisibility="Disabled">
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ScrollViewer>
            </Border>
        </ControlTemplate>
        <Style x:Key="AccountingTransactionListStyle" TargetType="{x:Type ListBox}">
            <Setter Property="Template" Value="{StaticResource AccountingTransactionListBoxTemplate}" />
            <Setter Property="Padding" Value="2,0,2,2" />
        </Style>
        <Style x:Key="AccountingTransactionListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="#00FFFFFF" />
            <Setter Property="HorizontalContentAlignment"
                    Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
            <Setter Property="VerticalContentAlignment"
                    Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
            <Setter Property="Padding" Value="2,0,0,0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    Content="{TemplateBinding Content}"
                                    ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Foreground"
                                        Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </localView:BeWoView.Resources>
    <Grid>
        <Grid x:Name="rootGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <CheckBox Content="Buchungen für ausgewählten Hilfeplan" Grid.Row="0" IsChecked="True" Margin="0,3,0,0"
                    x:Name="chkWithClient" Checked="chkWithClient_Checked" Unchecked="chkWithClient_Unchecked" />
            <Grid x:Name="customerInfoGrid" Grid.Row="1" Margin="0,3,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="250" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <!--<ComboBox x:Name="customerComboBox" IsSynchronizedWithCurrentItem="True" AlternationCount="-1"
                        ItemTemplate="{DynamicResource CustomerComboBoxItemTemplate}"
                        SelectionChanged="customerComboBox_SelectionChanged" Height="62"
                        ItemsPanel="{DynamicResource CustomerComboBoxItemsPanelTemplate}"
                        Background="{DynamicResource SupportConceptListBrush}" HorizontalContentAlignment="Stretch"
                        Style="{DynamicResource ObjectComboBoxStyle}" PreviewTextInput="customerComboBox_PreviewTextInput"
                        LostFocus="customerComboBox_LostFocus" GotFocus="customerComboBox_GotFocus"
                        PreviewKeyDown="customerComboBox_PreviewKeyDown" />-->
                <localViewControls:SingleSupportConceptSelectionControl x:Name="supportConceptSelectionControl" 
                                        ItemSelected="supportConceptSelectionControl_ItemSelected"  Height="62" VerticalAlignment="Top"
                                        HorizontalContentAlignment="Stretch" />
                <Grid Grid.Row="0" VerticalAlignment="Top" Margin="5,5,0,0" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding Path=InformationString}" Foreground="#FF2B508B" FontSize="14" />
                </Grid>
            </Grid>
            <Grid Grid.Row="2" x:Name="customerDetailGrid" Margin="0,5,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <GroupBox Header="Neue Buchung anlegen" Padding="0,0,0,0" Style="{DynamicResource ObjectEditGroupBox}"
                        Margin="0,0,0,-3">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid x:Name="newObjectInfoGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="250" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <!-- TextBlock Foreground="Black" TextWrapping="Wrap" Margin="3,3,7,3"  Text="Klient/in:"/-->
                                <Grid Grid.Column="0" Grid.Row="1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Content="Betrag €" />
                                    <dxe:TextEdit AllowNullInput="True"  MaskType="Numeric" Mask="c" MaskUseAsDisplayFormat="True" Grid.Column="1" Grid.Row="0" Height="23" Margin="3"
                                            EditValue="{val:ValidationBinding Path=PrototypeVM.Amount, Mode=TwoWay}"/>
                                    <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="2" Margin="3,0,0,0">
                                        <TextBlock x:Name="txtMonthlyAmount">
											<Hyperlink x:Name="linkMonthlyAmount" Foreground="#FF2B508B"
                                                    Click="linkMonthlyAmount_Click">mtl. Abschlag</Hyperlink></TextBlock>
                                        <TextBlock x:Name="txtOpenAmount">
											<Hyperlink x:Name="linkOpenAmount" Foreground="#FF2B508B"
                                                    Click="linkOpenAmount_Click">Restbetrag</Hyperlink></TextBlock>
                                    </StackPanel>
                                    <Label Content="Buchungsdatum" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" />
                                    <dxe:DateEdit MaskType="DateTimeAdvancingCaret" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1" Background="White"
                                            Height="23" Margin="3"
                                            EditValue="{val:ValidationBinding Path=PrototypeVM.BookingDate, Mode=TwoWay}"/>
                                  
                                  <Label Content="Gültigkeitsdatum" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" />
                                  <dxe:DateEdit MaskType="DateTimeAdvancingCaret" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="2" Background="White"
                                          Height="23" Margin="3"
                                          EditValue="{val:ValidationBinding Path=PrototypeVM.ValidityDate, Mode=TwoWay}"/>
                                  
                                    <Label Grid.Row="3" Content="Kategorie" />
                                    <ComboBox Grid.Column="1" Grid.ColumnSpan="2" Height="23" Margin="3" Grid.Row="3"
                                            x:Name="combobox_categories"
                                            SelectedItem="{val:ValidationBinding Path=PrototypeVM.Category}" />
                                    <Label Grid.Column="0" Grid.Row="4" VerticalAlignment="Top" Content="Kommentar"
                                            HorizontalAlignment="Left" Grid.ColumnSpan="3" />
                                    <TextBox Grid.Column="0" Grid.Row="5"
                                            Text="{val:ValidationBinding Path=PrototypeVM.Notice, UpdateSourceTrigger=PropertyChanged}"
                                            VerticalAlignment="Stretch" Margin="3" Grid.ColumnSpan="3" AcceptsReturn="True"
                                            VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden"
                                            TextWrapping="Wrap" AutoWordSelection="True" />
                                </Grid>
                            </Grid>
                            <Grid Grid.Row="1" Margin="0,0,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding Path=Information}"
                                        Foreground="#FF000000" Margin="0,0,3,0" />
                                <Button x:Name="button_add" Click="button_add_Click" FontWeight="Normal" Grid.Column="1"
                                        Content="Speichern" Height="23" BorderThickness="3,3,3,3" Margin="0,0,3,0" />
                            </Grid>
                        </Grid>
                    </Grid>
                </GroupBox>
                
                <ListBox ScrollViewer.CanContentScroll="True" x:Name="accountingTransactionGrid" Grid.Row="0" Grid.Column="1"
                        IsSynchronizedWithCurrentItem="True" TabIndex="1" AlternationCount="-1" Background="{x:Null}"
                        MouseDoubleClick="AccountingTransactionGrid_MouseDoubleClick" Margin="0,0,0,25"
                        ItemTemplate="{DynamicResource AccountingTransactionListBoxItemTemplate}"
                        Style="{DynamicResource AccountingTransactionListStyle}" HorizontalContentAlignment="Stretch"
                        ItemContainerStyle="{DynamicResource AccountingTransactionListBoxItemStyle}">
                    <ListBox.Resources>
                        <DataTemplate x:Key="AccountingTransactionListBoxItemTemplate"
                                DataType="{x:Type localViewModel:AccountingTransactionVM}">
                            <Grid x:Name="template" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Border x:Name="ItemBorder" CornerRadius="4,4,4,4" Width="Auto" Height="Auto" Padding="6"
                                        Margin="0,0,0,3" Background="#FFFFFFFF" BorderThickness="1,1,1,1"
                                        BorderBrush="#FF7E7E7E">
                                    <Grid TextBlock.Foreground="{Binding Path=TextBlock.Foreground, RelativeSource={RelativeSource TemplatedParent}}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="80" />
                                            <ColumnDefinition Width="12" />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="12" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="14" />
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="24" />
                                        </Grid.RowDefinitions>
										<TextBlock Grid.Column="0" Grid.Row="0"
                                                Text="{Binding Path=Amount, StringFormat=\{0:0.00\} €}" FontWeight="Bold"
                                                Background="{x:Null}" Foreground="{Binding Path=AmountForegroundBrush}" />

										<TextBlock Grid.Column="2" Grid.Row="0"
                                                Text="{Binding Path=DatumsText}"
                                                FontWeight="Bold"
                                                Foreground="#FF494949" />
                                        <TextBlock Grid.Column="4" Grid.Row="0"
                                                Text="{Binding Path=Category}"
                                                FontWeight="Bold"
                                                Foreground="#FF494949" />
                                        <TextBox Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="5"
                                                HorizontalAlignment="Stretch" Text="{Binding Path=Notice}"
                                                HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
                                                Margin="0,0,0,0" BorderThickness="1,1,1,1" BorderBrush="{x:Null}"
                                                Background="{x:Null}" SnapsToDevicePixels="True" MaxHeight="200"
                                                TextWrapping="Wrap" AutoWordSelection="True" IsReadOnly="True"
                                                GotFocus="TextBox_GotFocus" Tag="{Binding}" IsEnabled="True" Focusable="True" />
										<TextBlock Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="5" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type localViewDetail:AccountingTransactionBookingView}}, Path=InsertedOnAndByVisibility}"
                                                VerticalAlignment="Bottom" FontSize="10">
											<TextBlock.Text>
												<MultiBinding StringFormat="{}Angelegt am {0:dd.MM.yyyy hh:mm} von {1}">
													<Binding Path="InsertedOn" />
													<Binding Path="InsUser" />
												</MultiBinding>
											</TextBlock.Text></TextBlock>
                                        <Button x:Name="btnEdit" Grid.Column="0" Grid.Row="2" Width="32" Height="22"
                                                HorizontalAlignment="Right" Margin="0,0,35,0" BorderThickness="1,1,1,1"
                                                Padding="1,1,1,1"
                                                Click="btnEdit_Click" Style="{DynamicResource GlassButton}"
                                                Tag="{Binding}"
                                                Visibility="{Binding Path=EditAllowed, Converter={StaticResource BoolVisibilityConverter}}"
                                                Grid.ColumnSpan="5">
                                            <Image Source="..\..\Ressources\Icons\Symbol Edit.png" Stretch="Uniform"
                                                    Margin="1,1,1,1" />
                                        </Button>
                                        <Button x:Name="btnDelete" Grid.Column="0" Grid.Row="2" Width="32" Height="22"
                                                HorizontalAlignment="Right" Margin="0,0,0,0" Padding="1,1,1,1"
                                                BorderThickness="1,1,1,1"
                                                Click="btnDelete_Click"
                                                Style="{DynamicResource GlassButton}"
                                                Tag="{Binding}"
                                                Visibility="{Binding Path=EditAllowed, Converter={StaticResource BoolVisibilityConverter}}"
                                                Grid.ColumnSpan="5">
                                            <Image Source="..\..\Ressources\Icons\Symbol Delete.png" Stretch="Uniform"
                                                    Margin="1,1,1,1" />
                                        </Button>
                                    </Grid>
                                </Border>
                            </Grid>
                            <DataTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" TargetName="ItemBorder" Value="#FFCCE0FF" />
                                </Trigger>
                                <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                        Value="True">
                                    <Setter Property="Background" TargetName="ItemBorder" Value="#FF93BCFF" />
                                </DataTrigger>
                            </DataTemplate.Triggers>
                        </DataTemplate>
                    </ListBox.Resources>
                </ListBox>
                <TextBlock Grid.Column="1" x:Name="txtServiceListCount" Text="{Binding Path=RecordCountInformationString}"
                        VerticalAlignment="Bottom" Margin="5,0,5,3"
                        Foreground="#FF2B508B" HorizontalAlignment="Left"
                        FontSize="14" />
                <TextBlock Grid.Column="1" x:Name="textblock_link" VerticalAlignment="Bottom" Margin="5,0,5,3"
                        HorizontalAlignment="Right" FontSize="14">
					<Hyperlink x:Name="linkExcelExport" TargetName="newWindow" Foreground="#FF2B508B"
                            RequestNavigate="linkExcelExport_RequestNavigate">
						<Run Text="Excel Export" />
					</Hyperlink></TextBlock>
            </Grid>
        </Grid>
        <Border x:Name="popup_content" />
    </Grid>
</localView:BeWoView>