<localView:BeWoView x:Class="BeWo.View.Detail.Accounting.SettlementInvoiceItemEditView2"
        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.Accounting"
        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">
    <Grid>
        <GroupBox MinHeight="300" Width="800" Style="{StaticResource PopUpWindowStyle}">
            <GroupBox.Header>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,0">
                    <Image Source="..\..\Ressources\Icons\CoinsDisabled.png" Height="28" />
                    <TextBox Text="Rechnung bearbeiten" Margin="10,4,0,0" Background="{x:Null}"
                            Foreground="{DynamicResource MainGroupBoxForegroundBrush}" FontSize="20" BorderBrush="{x:Null}"
                            VerticalAlignment="Stretch" BorderThickness="0,0,0,0" Padding="0,0,0,0" />
                </StackPanel>
            </GroupBox.Header>
            <Grid Background="{StaticResource ObjectEditBackgroundBrush}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Rectangle Fill="{DynamicResource AccountingContentBrush}" VerticalAlignment="Top" Height="6" />
                <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                    <Grid Grid.IsSharedSizeScope="True" Margin="10,10,10,10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <GroupBox Margin="0,0,0,0" Style="{StaticResource ObjectEditGroupBox}" Header="Empfänger Adresse">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col1" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col3" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Label Content="Organisation" />
                                <TextBox Margin="3" Grid.Row="0" Grid.Column="1"
                                        Text="{val:ValidationBinding Path=RecipientOrganisation}" Height="23" />
                                <Label Content="Ansprechpartner" Grid.Row="1" Grid.Column="0" />
                                <TextBox Margin="3" Grid.Row="1" Grid.Column="1"
                                        Text="{Binding RecipientContactPerson}"
                                        Height="23" />
                                <Label Content="Abteilung" Grid.Row="2" Grid.Column="0" />
                                <TextBox Margin="3" Grid.Row="2" Grid.Column="1"
                                        Text="{Binding RecipientDivision}"
                                        Height="23" />
                                <Label Content="Strasse" Grid.Row="0" Grid.Column="2" />
                                <TextBox Margin="3" Grid.Row="0" Grid.Column="3"
                                        Text="{val:ValidationBinding Path=RecipientStreet}" Height="23" />
                                <Label Content="Postleitzahl" Grid.Row="1" Grid.Column="2" />
                                <TextBox Margin="3,3,3,0" Grid.Row="1" Grid.Column="3"
                                        Text="{val:ValidationBinding Path=RecipientPostCode}" Height="23" />
                                <Label Content="Ort" Grid.Row="2" Grid.Column="2" />
                                <TextBox Margin="3" Grid.Row="2" Grid.Column="3"
                                        Text="{val:ValidationBinding Path=RecipientTown}" Height="23" />
								<Label Content="Postfach" Grid.Row="3" Grid.Column="2" />
								<TextBox Margin="3" Grid.Row="3" Grid.Column="3"
                                        Text="{Binding Path=RecipientPostBox}" Height="23" />
                            </Grid>
                        </GroupBox>
                        <GroupBox Margin="0 0 0 0" Style="{StaticResource ObjectEditGroupBox}" Grid.Row="1"
                                Header="Absender Ansprechpartner">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col1" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col3" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Label Content="Vorname" />
                                <TextBox Margin="3" Grid.Row="0" Grid.Column="1"
                                        Text="{Binding SenderContactPersonFirstName}" Height="23" />
                                <Label Content="Nachname" Grid.Row="0" Grid.Column="2" />
                                <TextBox Margin="3" Grid.Row="0" Grid.Column="3"
                                        Text="{Binding SenderContactPersonLastName}"
                                        Height="23" />
                                <Label Content="Abteilung" Grid.Row="1" />
                                <TextBox Margin="3" Grid.Row="1" Grid.Column="1"
                                        Text="{Binding SenderContactPersonDivision}"
                                        Height="23" />
                                <Label Content="Email" Grid.Row="2" Grid.Column="0" />
                                <TextBox Margin="3" Grid.Row="2" Grid.Column="1"
                                        Text="{Binding SenderContactPersonMail}"
                                        Height="23" />
                                <Label Content="Telefon" Grid.Row="1" Grid.Column="2" />
                                <TextBox Margin="3" Grid.Row="1" Grid.Column="3"
                                        Text="{Binding SenderContactPersonPhone}"
                                        Height="23" />
                                <Label Content="Fax" Grid.Row="2" Grid.Column="2" />
                                <TextBox Margin="3" Grid.Row="2" Grid.Column="3"
                                        Text="{Binding SenderContactPersonFax}"
                                        Height="23" />
                            </Grid>
                        </GroupBox>
                        <GroupBox Margin="0 0 0 0" Style="{StaticResource ObjectEditGroupBox}" Grid.Row="2" Header="Details">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col1" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" SharedSizeGroup="col3" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Label Content="Ersteller Vorname" Grid.Row="0" />
                                <TextBox Margin="3" Grid.Row="0" Grid.Column="1"
                                        Text="{Binding CreatorFirstName}"
                                        Height="23" />
                                <Label Content="Ersteller Nachname" Grid.Row="0" Grid.Column="2" />
                                <TextBox Margin="3" Height="23" Grid.Row="0" Grid.Column="3"
                                        Text="{Binding CreatorLastName}" />
                                <Label Content="Abrechnungszeitraum von" Grid.Row="1" Grid.Column="0" />
                                <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Height="23"
                                        Margin="3"
                                        Grid.Row="1" Grid.Column="1"
                                        EditValue="{val:ValidationBinding  Path=AccountingPeriodStart, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Abrechnungszeitraum bis" Grid.Row="1" Grid.Column="2" />
                                <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Height="23"
                                        Margin="3"
                                        Grid.Row="1" Grid.Column="3"
                                        EditValue="{val:ValidationBinding Path=AccountingPeriodEnd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Bewilligungsbescheid vom" Grid.Row="2" Grid.Column="0" />
                                <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Margin="3"
                                        Height="23"
                                        Grid.Row="2" Grid.Column="1"
                                        EditValue="{Binding Path=ApprovalNoticeDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Rechnungsnummer" Grid.Row="2" Grid.Column="2" />
                                <TextBox Margin="3" Height="23" Grid.Row="2" Grid.Column="3"
                                        Text="{Binding Path=InvoiceNumber}" />
                                <Label Content="Rechnungsdatum" Grid.Row="3" Grid.Column="0" />
                                <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Margin="3"
                                        Height="23"
                                        Grid.Row="3" Grid.Column="1"
                                        EditValue="{val:ValidationBinding Path=InvoiceDate, Mode=TwoWay}" />
                                <Label Content="Aktenzeichen" Grid.Row="3" Grid.Column="2" />
                                <TextBox Margin="3" Height="23" Grid.Row="3" Grid.Column="3"
                                        Text="{Binding CustomerReferenceNumber}" />
                                <Label Grid.Column="0" Grid.Row="4" Content="anz Mahnungen" />
                                <dxe:SpinEdit MinValue="0" IsFloatValue="False" AllowNullInput="True" VerticalAlignment="Top" EditValue="{Binding Path=DunningLetterCount, Converter={StaticResource Int2DecimalConverter}}"
                                        Height="23" Margin="3" Grid.Row="4"
                                        Grid.Column="1"/>
                                <Label Content="Bemerkung" Grid.Row="4" Grid.Column="2" />
                                <TextBox Grid.Row="4" Grid.Column="3"
                                        Margin="3" AcceptsReturn="True"
                                        TextWrapping="Wrap" Height="60" Text="{Binding Notice}" 
                                        VerticalScrollBarVisibility="Visible" AutoWordSelection="True" Width="240"
                                />
                                                               
                            </Grid>
                        </GroupBox>
                        <GroupBox Margin="0 0 0 0" Style="{StaticResource ObjectEditGroupBox}" Grid.Row="3" Header="Bilanz">
                            <ScrollViewer>
                                <Grid Name="summary_grid" >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <dxg:GridControl Background="Transparent" HorizontalAlignment="Left"
                                            DataSource="{Binding InvoiceItems.VMList}">
                                        <!--<dxg:GridControl.Resources>
                                                <ControlTemplate x:Key="{dxg:TableViewThemeKey ResourceKey=ControlTemplate}">
                                                    <dxg:GridViewScrollViewer x:Name="scr" CanContentScroll="true"
                                                            VerticalScrollBarVisibility="Hidden"
                                                            HorizontalScrollBarVisibility="Auto" Focusable="False"
                                                            Template="{DynamicResource {dxg:TableViewThemeKey ResourceKey=ScrollViewerTemplate}}"></dxg:GridViewScrollViewer>
                                                </ControlTemplate>
                                            </dxg:GridControl.Resources>-->
                                        <dxg:GridControl.Columns>
                                            <dxg:GridColumn x:Name="colItemPeriodStart" FieldName="ItemPeriodStart" Header="Von" EditSettings="{dxe:DateSettings DisplayFormat=d}" Width="80" />
                                            <dxg:GridColumn x:Name="colItemPeriodEnd" FieldName="ItemPeriodEnd" Header="Bis" EditSettings="{dxe:DateSettings DisplayFormat=d}" Width="80" />
                                            <dxg:GridColumn FieldName="ItemDescription" Header="Bezeichnung" Width="150" />
                                            <dxg:GridColumn x:Name="colAmountPerUnit" FieldName="AmountPerUnit" Header="Satz" Width="80">
                                                <dxg:GridColumn.EditSettings>
                                                    <dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric"></dxe:TextEditSettings>
                                                </dxg:GridColumn.EditSettings>
                                            </dxg:GridColumn>
                                            <dxg:GridColumn x:Name="colUnitCount" FieldName="UnitCountUntilMax" Header="Anzahl" Width="80" />
                                            <dxg:GridColumn x:Name="colUnitDescription" FieldName="UnitDescription" Header="Einheit" Width="160" />
                                            <dxg:GridColumn x:Name="colAmountTotal" FieldName="GrossAmountTotalUntilMax" Header="Betrag" Width="80" >
                                                <dxg:GridColumn.CellStyle>
                                                    <Style TargetType="dxg:CellContentPresenter">
                                                        <Setter Property="FontWeight" Value="Bold" />
                                                    </Style>
                                                </dxg:GridColumn.CellStyle>
                                                <dxg:GridColumn.EditSettings>
                                                    <dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric"></dxe:TextEditSettings>
                                                </dxg:GridColumn.EditSettings>
                                            </dxg:GridColumn>
                                        </dxg:GridControl.Columns>
                                        <dxg:GridControl.View>
                                            <dxg:TableView NavigationStyle="None" ShowIndicator="False"
                                                    AllowSorting="False" AllowColumnFiltering="False"
                                                    ShowHorizontalLines="False" ShowVerticalLines="False" AllowResizing="False"
                                                    ShowGroupPanel="False"
                                                        />
                                        </dxg:GridControl.View>
                                    </dxg:GridControl>
                                    <Grid Grid.Row="1" Margin="3 0 3 3">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="467" />
                                            <ColumnDefinition Width="120" />
                                            <ColumnDefinition Width="122" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Label Margin="3"
                                                Content="Gesamtforderung:" VerticalAlignment="Center"
                                                Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" />
                                        <Label Margin="3"
                                                Content="Vorauszahlungen:" VerticalAlignment="Center"
                                                Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right" />
                                        <Label Margin="3"
                                                Content="Eigenanteil:" VerticalAlignment="Center"
                                                Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right" />
                                        <Label Margin="3"
                                                Content="Restforderung:" VerticalAlignment="Center"
                                                FontWeight="Bold" Grid.Column="1" Grid.Row="3"
                                                HorizontalAlignment="Right" />
                                        <dxe:TextEdit IsReadOnly="True"
                                                MaskUseAsDisplayFormat="True"
                                                HorizontalContentAlignment="Right"
                                                Mask="c"
                                                MaskType="Numeric"
                                                Foreground="Black"
                                                Text="{Binding AmountBillableTotalUntilMax, Mode=OneWay}" Margin="0" Padding="0,0,-1,0"
                                                Grid.Column="2"
                                                Grid.Row="0">
                                            <dxe:TextEdit.BorderTemplate>
                                                <ControlTemplate TargetType="{x:Type ContentControl}">
                                                    <Border Background="White" BorderBrush="#6f7074"
                                                            BorderThickness="1 0 1 1">
                                                        <ContentPresenter />
                                                    </Border>
                                                </ControlTemplate>
                                            </dxe:TextEdit.BorderTemplate>
                                        </dxe:TextEdit>
                                        <dxe:TextEdit IsReadOnly="True"
                                                MaskUseAsDisplayFormat="True"
                                                HorizontalContentAlignment="Right"
                                                Mask="c"
                                                MaskType="Numeric"
                                                Foreground="Black"
                                                Text="{Binding AmountAdvancedPayments, Mode=OneWay}" Margin="0" Padding="0,0,-1,0"
                                                Grid.Column="2"
                                                Grid.Row="1">
                                            <dxe:TextEdit.BorderTemplate>
                                                <ControlTemplate TargetType="{x:Type ContentControl}">
                                                    <Border Background="White" BorderBrush="#6f7074"
                                                            BorderThickness="1 0 1 0">
                                                        <ContentPresenter />
                                                    </Border>
                                                </ControlTemplate>
                                            </dxe:TextEdit.BorderTemplate>
                                        </dxe:TextEdit>
                                        <dxe:TextEdit IsReadOnly="True"
                                                MaskUseAsDisplayFormat="True"
                                                HorizontalContentAlignment="Right"
                                                Mask="c"
                                                MaskType="Numeric"
                                                Foreground="Black"
                                                Text="{Binding EquityContribution, Mode=OneWay}" Margin="0" Padding="0,0,-1,0"
                                                Grid.Column="2"
                                                Grid.Row="2">
                                            <dxe:TextEdit.BorderTemplate>
                                                <ControlTemplate TargetType="{x:Type ContentControl}">
                                                    <Border Background="White" BorderBrush="#6f7074"
                                                            BorderThickness="1 0 1 1">
                                                        <ContentPresenter />
                                                    </Border>
                                                </ControlTemplate>
                                            </dxe:TextEdit.BorderTemplate>
                                        </dxe:TextEdit>
                                        <dxe:TextEdit IsReadOnly="True"
                                                FontWeight="Bold" MaskUseAsDisplayFormat="True"
                                                HorizontalContentAlignment="Right"
                                                Mask="c"
                                                MaskType="Numeric"
                                                Foreground="Black"
                                                Text="{Binding Claim, Mode=OneWay}" Margin="0" Padding="0,0,-1,0"
                                                Grid.Column="2"
                                                Grid.Row="3">
                                            <dxe:TextEdit.BorderTemplate>
                                                <ControlTemplate TargetType="{x:Type ContentControl}">
                                                    <Border Background="White" BorderBrush="#6f7074"
                                                            BorderThickness="1 0 1 1">
                                                        <ContentPresenter />
                                                    </Border>
                                                </ControlTemplate>
                                            </dxe:TextEdit.BorderTemplate>
                                        </dxe:TextEdit>
                                    </Grid>
                                </Grid>
                            </ScrollViewer>
                        </GroupBox>
                    </Grid>
                </ScrollViewer>
                <StackPanel Grid.ColumnSpan="2" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center"
                        Height="Auto" Margin="5 0 5 5" HorizontalAlignment="Right">
                    <Button x:Name="btnSave" Content="Rechnung erstellen" Margin="5" Command="ApplicationCommands.Save"
                            Height="25" />
                    <Button x:Name="btnClose" Content="Abbrechen" Margin="5" Command="ApplicationCommands.Close" Height="25" />
                </StackPanel>
            </Grid>
        </GroupBox>
    </Grid>
</localView:BeWoView>