374 lines
14 KiB
C#
374 lines
14 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
using BeWo.Controls;
|
|
using BeWo.Core;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.ViewModel;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Xpf.Core;
|
|
using DevExpress.Xpf.Printing;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWo.View.Report.Employee
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EmployeeHourReportView.xaml
|
|
/// </summary>
|
|
public partial class EmployeeHourReportView : BeWoView
|
|
{
|
|
private CompactEmployeeDC _SelectedEmployee;
|
|
|
|
private CompactTeamDC _SelectedTeam;
|
|
|
|
public CompactEmployeeDC Employee { get { return _SelectedEmployee; } set { _SelectedEmployee = value; } }
|
|
|
|
public EmployeeHourReportView()
|
|
{
|
|
InitializeComponent();
|
|
InitDates();
|
|
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll))
|
|
{
|
|
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams))
|
|
{
|
|
checkbox_all.IsEnabled = false;
|
|
checkbox_all.IsChecked = false;
|
|
|
|
popupedit_employee.Text = String.Format("{0}, {1}", BeWoApp.LoggedOnEmployee.LastName,
|
|
BeWoApp.LoggedOnEmployee.FirstName);
|
|
}
|
|
}
|
|
|
|
var str = Translator.Translate("StundenkontoTagesansicht");
|
|
|
|
if (str == "StundenkontoTagesansicht")
|
|
{
|
|
checkbox_tagesansicht.Visibility = Visibility.Collapsed;
|
|
AnsichtPanel.Visibility = Visibility.Visible;
|
|
}
|
|
else
|
|
{
|
|
AnsichtPanel.Visibility = Visibility.Collapsed;
|
|
checkbox_tagesansicht.Visibility = Visibility.Visible;
|
|
checkbox_tagesansicht.Content = str;
|
|
}
|
|
|
|
ChangeReportType();
|
|
|
|
|
|
|
|
ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, Theme.Office2010Black);
|
|
//ThemeManager.SetTheme(docPrevControl, Theme.Office2010Black);
|
|
|
|
Unloaded += delegate
|
|
{
|
|
ThemeManager.SetTheme(BeWoApp.CurrentBeWo.MainWindow, null);
|
|
//docPrevControl.Visibility = Visibility.Collapsed;
|
|
};
|
|
}
|
|
|
|
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (popupedit_employee == null)
|
|
return;
|
|
|
|
popupedit_employee.Text = string.Empty;
|
|
_SelectedEmployee = null;
|
|
|
|
ChangeReportType();
|
|
}
|
|
|
|
private void CheckBoxAllTeams_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (popupedit_team != null)
|
|
{
|
|
popupedit_team.Text = string.Empty;
|
|
_SelectedTeam = null;
|
|
}
|
|
|
|
ChangeReportType();
|
|
}
|
|
|
|
private void EmployeeSearchView_EmployeeSelected(object sender, EventArgs<CompactEmployeeDC> e)
|
|
{
|
|
_SelectedEmployee = e.Data;
|
|
popupedit_employee.Text = _SelectedEmployee.SimpleDescription;
|
|
popup_employee.IsOpen = false;
|
|
}
|
|
|
|
private void TeamSearchView_TeamSelected(object sender, EventArgs<CompactTeamDC> e)
|
|
{
|
|
_SelectedTeam = e.Data;
|
|
popupedit_team.Text = _SelectedTeam.Name;
|
|
popup_team.IsOpen = false;
|
|
}
|
|
|
|
private void InitDates()
|
|
{
|
|
//DateTime start = DateTime.Now.Date.AddMonths(-1);
|
|
//start = new DateTime(start.Year, start.Month, 1);
|
|
//datePickerStartDate.DateTime = start;
|
|
//datePickerEndDate.DateTime = start.AddMonths(1).AddDays(-1);
|
|
|
|
InitDateCombos();
|
|
|
|
}
|
|
|
|
private void InitDateCombos()
|
|
{
|
|
this.combobox_month.ItemsSource = DateTimeFormatInfo.CurrentInfo.MonthNames.Where(s => !string.IsNullOrEmpty(s));
|
|
int monthIdx = DateTime.Now.Month - 1;
|
|
//if (DateTime.Now.Day < 15)
|
|
//{
|
|
monthIdx--;
|
|
if (monthIdx < 0)
|
|
monthIdx = 11;
|
|
//}
|
|
this.combobox_month.SelectedIndex = monthIdx;
|
|
var years = new List<int>();
|
|
for (int i = 0; i <= 10; i++)
|
|
{
|
|
years.Add(DateTime.Now.Year - i);
|
|
}
|
|
|
|
this.combobox_year.ItemsSource = years;
|
|
if (monthIdx == 11)
|
|
{
|
|
this.combobox_year.SelectedItem = DateTime.Now.Year - 1;
|
|
}
|
|
else
|
|
this.combobox_year.SelectedItem = DateTime.Now.Year;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void button_generate_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
long empOid = 0;
|
|
long teamOid = 0;
|
|
|
|
var auswertungNachTeam = radioTeamReport.IsChecked.Value;
|
|
var auswertungNachMa = !auswertungNachTeam;
|
|
|
|
var url = string.Format("{0}/ReportView.aspx?type={1}", BeWoApp.SiteOfOrigin, Utils.EnumName(ReportTypes.EmployeeHourReport));
|
|
|
|
if (auswertungNachMa)
|
|
{
|
|
if (checkbox_all. IsChecked.Value || checkbox_all.Visibility == Visibility.Hidden)
|
|
{
|
|
_SelectedEmployee = null;
|
|
}
|
|
|
|
if (checkbox_all.Visibility == Visibility.Visible && !checkbox_all.IsChecked.Value && _SelectedEmployee == null && BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll))
|
|
{
|
|
MessageBox.Show("Bitte wählen Sie eine/n Mitarbeiter/in aus.", "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
return;
|
|
}
|
|
|
|
if (_SelectedEmployee != null)
|
|
{
|
|
empOid = _SelectedEmployee.EmployeeOid;
|
|
}
|
|
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll))
|
|
{
|
|
empOid = BeWoApp.LoggedOnEmployee.EmployeeOid.Value;
|
|
}
|
|
|
|
if (empOid > 0)
|
|
{
|
|
url += "&eoid=" + empOid;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (checkbox_all_teams.IsChecked.Value || checkbox_all_teams.Visibility == Visibility.Hidden)
|
|
{
|
|
_SelectedTeam = null;
|
|
}
|
|
|
|
if (checkbox_all_teams.Visibility == Visibility.Visible && !checkbox_all_teams.IsChecked.Value && _SelectedTeam == null && (BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll) || BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams)))
|
|
{
|
|
MessageBox.Show("Bitte wählen Sie ein Team aus.", "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
return;
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("&toid=");
|
|
|
|
if (_SelectedTeam != null)
|
|
teamOid = _SelectedTeam.TeamOid;
|
|
|
|
if (teamOid > 0 && !checkbox_all_teams.IsChecked.Value)
|
|
{
|
|
sb.Append(teamOid);
|
|
}
|
|
else if (checkbox_all_teams.IsChecked.Value)
|
|
{
|
|
|
|
var ol = teamsearchview.ObjectList;
|
|
if (ol != null)
|
|
{
|
|
bool first = true;
|
|
foreach (var t in ol)
|
|
{
|
|
if (!first)
|
|
{
|
|
sb.Append(",");
|
|
}
|
|
sb.Append(t.TeamOid);
|
|
first = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
url += sb.ToString();
|
|
}
|
|
|
|
//url += "&sm=" + datePickerStartDate.DateTime.Month + "&sy=" + datePickerStartDate.DateTime.Year + "&sd=" +
|
|
// datePickerStartDate.DateTime.Day;
|
|
//url += "&em=" + datePickerEndDate.DateTime.Month + "&ey=" + datePickerEndDate.DateTime.Year + "&ed=" +
|
|
// datePickerEndDate.DateTime.Day;
|
|
|
|
url += "&m=" + (combobox_month.SelectedIndex + 1) + "&y=" + combobox_year.SelectedItem;
|
|
|
|
if (checkbox_tagesansicht.Visibility == Visibility.Visible && checkbox_tagesansicht.IsChecked.HasValue && checkbox_tagesansicht.IsChecked.Value)
|
|
{
|
|
url += "&ansicht=1";
|
|
}
|
|
else if (AnsichtPanel.Visibility == Visibility.Visible)
|
|
{
|
|
if (radio_tagesansicht.IsChecked.HasValue && radio_tagesansicht.IsChecked.Value)
|
|
{
|
|
url += "&ansicht=1";
|
|
}
|
|
else if (radio_jahresansicht.IsChecked.HasValue && radio_jahresansicht.IsChecked.Value)
|
|
{
|
|
url += "&ansicht=2";
|
|
}
|
|
}
|
|
var tempToken = string.Empty;
|
|
ServiceFacade.DoDownloadServiceSync(s => tempToken = s.CreateTemporaryToken(url, true));
|
|
|
|
url = url + "&token=" + tempToken;
|
|
|
|
|
|
url = BeWoWpfUtils.GetHTMLEncodedURL(url);
|
|
|
|
BeWoUtils.NavigateToReportUriWithDocumentPreviewControl(url, "Mitarbeiterstundenkonto", docPrevControl, null);
|
|
}
|
|
|
|
private void popupedit_employee_PopUpClick(object sender, RoutedEventArgs e)
|
|
{
|
|
popup_employee.IsOpen = true;
|
|
}
|
|
|
|
private void popupedit_team_PopUpClick(object sender, RoutedEventArgs e)
|
|
{
|
|
this.popup_team.IsOpen = true;
|
|
}
|
|
|
|
private void RadioButton_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
ChangeReportType();
|
|
}
|
|
|
|
private void ChangeReportType()
|
|
{
|
|
if (radioTeamReport != null && popupedit_team != null)
|
|
{
|
|
bool isEmployee = true;
|
|
|
|
if (radioTeamReport.IsChecked != null && radioTeamReport.IsChecked.Value)
|
|
{
|
|
isEmployee = false;
|
|
}
|
|
checkbox_all.Visibility = isEmployee ? Visibility.Visible : Visibility.Hidden;
|
|
popupedit_employee.Visibility = isEmployee ? Visibility.Visible : Visibility.Hidden;
|
|
|
|
checkbox_all_teams.Visibility = isEmployee ? Visibility.Hidden : Visibility.Visible;
|
|
popupedit_team.Visibility = isEmployee ? Visibility.Hidden : Visibility.Visible;
|
|
|
|
if (checkbox_all.IsChecked.HasValue && checkbox_all.Visibility == Visibility.Visible)
|
|
{
|
|
popupedit_employee.Visibility = checkbox_all.IsChecked.Value ? Visibility.Hidden : Visibility.Visible;
|
|
}
|
|
|
|
if (checkbox_all_teams.IsChecked.HasValue && checkbox_all_teams.Visibility == Visibility.Visible)
|
|
{
|
|
popupedit_team.Visibility = checkbox_all_teams.IsChecked.Value ? Visibility.Hidden : Visibility.Visible;
|
|
}
|
|
|
|
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewAll))
|
|
{
|
|
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams))
|
|
{
|
|
checkbox_all.IsEnabled = false;
|
|
checkbox_all.IsChecked = false;
|
|
|
|
checkbox_all.Visibility = Visibility.Collapsed;
|
|
popupedit_employee.Visibility = Visibility.Collapsed;
|
|
|
|
checkbox_all_teams.Visibility = Visibility.Collapsed;
|
|
popupedit_team.Visibility = Visibility.Collapsed;
|
|
radioTeamReport.Visibility = Visibility.Collapsed;
|
|
radioEmployeeReport.Visibility = Visibility.Collapsed;
|
|
|
|
//checkbox_showTeamReport.Visibility = Visibility.Collapsed;
|
|
}
|
|
else
|
|
{
|
|
checkbox_all.IsEnabled = false;
|
|
checkbox_all.IsChecked = false;
|
|
|
|
popupedit_employee.IsEnabled = false;
|
|
//checkbox_all.Visibility = Visibility.Collapsed;
|
|
//popupedit_employee.Visibility = Visibility.Collapsed;
|
|
|
|
var ol = teamsearchview.ObjectList;
|
|
if (ol != null)
|
|
{
|
|
List<CompactTeamDC> teams = new List<CompactTeamDC>();
|
|
var emp = BeWoApp.LoggedOnUser.Employee;
|
|
if (emp.LeadingTeamOids != null && emp.LeadingTeamOids.Count > 0)
|
|
{
|
|
foreach (var t in ol)
|
|
{
|
|
if (emp.LeadingTeamOids.Contains(t.TeamOid))
|
|
{
|
|
teams.Add(t);
|
|
}
|
|
}
|
|
}
|
|
|
|
teamsearchview.ObjectList = teams;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//private void popupedit_team_PopUpClick(object sender, RoutedEventArgs e)
|
|
//{
|
|
// popup_team.IsOpen = true;
|
|
//}
|
|
}
|
|
}
|