2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
2017-03-24 10:30:18 +01:00
using System.Text ;
2016-06-27 01:45:38 +02:00
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Navigation ;
using BeWo.Core ;
2017-11-06 10:30:25 +01:00
using BeWo.MultiLanguage ;
2016-06-27 01:45:38 +02:00
using BeWo.ServiceProxy ;
2017-04-25 18:07:24 +02:00
using BeWo.View.Search ;
2016-06-27 01:45:38 +02:00
using BS.Shared ;
using BS.Shared.Core ;
using BS.Shared.DataContracts ;
2017-02-10 11:08:38 +01:00
using BS.Shared.DataContracts.Compact ;
2016-06-27 01:45:38 +02:00
using BS.Shared.Extensions ;
2017-11-06 10:30:25 +01:00
using BS.Shared.Translation ;
2016-06-27 01:45:38 +02:00
namespace BeWo.View.Detail.Report
{
public partial class SupportConceptsAnalysisView : BeWoView
{
private Dictionary < string , List < SupportConceptOverviewDC > > _UnfilteredSupportConcept2Overviews ;
2017-02-10 11:08:38 +01:00
private CompactEmployeeDC _SelectedEmployee ;
private CompactTeamDC _SelectedTeam ;
2016-06-27 01:45:38 +02:00
public SupportConceptsAnalysisView ( Dictionary < string , List < SupportConceptOverviewDC > > pSupportConcept2Overviews )
{
this . InitializeComponent ( ) ;
2022-08-25 12:51:53 +02:00
this . datepicker_startdate . AllowNullInput = true ;
this . datepicker_startdate . EditValue = null ;
2016-06-27 01:45:38 +02:00
this . datepicker_appointeddate . AllowNullInput = true ;
this . datepicker_appointeddate . EditValue = null ;
2017-11-06 10:30:25 +01:00
2017-02-10 11:08:38 +01:00
_SelectedEmployee = BeWoApp . LoggedOnUser . Employee ;
if ( _SelectedEmployee ! = null )
{
popupedit_employee . Text = _SelectedEmployee . ToString ( ) ;
}
2017-11-06 10:30:25 +01:00
2017-03-24 10:30:18 +01:00
if ( ! DarfAlleMitarbeiterSehen )
2016-06-27 01:45:38 +02:00
{
2017-04-25 18:07:24 +02:00
if ( DarfTeamsSehen )
{
employeeSearchView . SearchMode = SearchMode . OnlyTeamMember ;
}
else
{
checkbox_allEmployees . IsEnabled = false ;
checkbox_allEmployees . IsChecked = false ;
2017-02-10 11:08:38 +01:00
2017-04-25 18:07:24 +02:00
popupedit_employee . Text = String . Format ( "{0}, {1}" , BeWoApp . LoggedOnEmployee . LastName ,
2017-11-06 10:30:25 +01:00
BeWoApp . LoggedOnEmployee . FirstName ) ;
2017-04-25 18:07:24 +02:00
}
2017-11-06 10:30:25 +01:00
2017-02-10 11:08:38 +01:00
}
2021-06-20 23:11:01 +02:00
InitServiceCategoryCombo ( ) ;
2017-03-24 10:30:18 +01:00
ChangeReportType ( ) ;
2016-06-27 01:45:38 +02:00
2017-11-06 10:30:25 +01:00
ChkHpDieAuslaufen . Content = Translator . Translate ( "Nur Hilfepläne anzeigen, die innerhalb der nächsten {0} Monate auslaufen" , BeWoApp . AppSettings . HilfeplanAuslaufAuswahl ) ;
2016-06-27 01:45:38 +02:00
// if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_SupportConceptOverview_View))
// {
// Dictionary<string, List<SupportConceptOverviewDC>> filteredList = new Dictionary<string, List<SupportConceptOverviewDC>>();
// foreach (var item in pSupportConcept2Overviews)
// {
// (item.Value[0].
// }
// _UnfilteredSupportConcept2Overviews = filteredList;
// }
// else
// {
this . _UnfilteredSupportConcept2Overviews = pSupportConcept2Overviews ;
// }
this . DataContext = this . _UnfilteredSupportConcept2Overviews ;
this . Loaded + = this . SupportConceptsAnalysisView_Loaded ;
2017-03-24 10:30:18 +01:00
UpdateReportUrl ( ) ;
}
2016-06-27 01:45:38 +02:00
2021-06-20 23:11:01 +02:00
private void InitServiceCategoryCombo ( )
{
ServiceFacade . DoOperationsServiceSync ( s = > ServiceCategoriesComboBox . ItemsSource = s . GetAllServiceCategories ( ) ) ;
ServiceCategoriesComboBox . SelectedIndex = - 1 ;
}
2017-03-24 10:30:18 +01:00
public bool DarfAlleMitarbeiterSehen
{
get
{
return BeWoApp . LoggedOnUser . HasRight ( UserRightType . Analysis_EmployeeOverviewAll_View ) & & BeWoApp . LoggedOnUser . HasRight ( UserRightType . CustomerView_View ) & & BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ViewAllSupportConcepts ) ;
}
2016-06-27 01:45:38 +02:00
}
2017-03-24 10:30:18 +01:00
public bool DarfTeamsSehen
{
get
{
return BeWoApp . LoggedOnUser . HasRight ( UserRightType . Analysis_AllowFLSOverviewForAllTeams ) | | BeWoApp . LoggedOnUser . HasRight ( UserRightType . Analysis_AllowFLSOverviewForTeam ) ;
}
}
2016-06-27 01:45:38 +02:00
private void SupportConceptsAnalysisView_Loaded ( object sender , RoutedEventArgs e )
{
this . textbox_search . Focus ( ) ;
}
private void UpdateReportUrl ( )
{
string url ;
2017-03-24 10:30:18 +01:00
int months = this . ChkHpDieAuslaufen . IsChecked . Value ? BeWoApp . AppSettings . HilfeplanAuslaufAuswahl : 0 ;
2016-06-27 01:45:38 +02:00
long showArchived = this . chkShowArchived . IsChecked . Value ? 1 : 0 ;
2017-02-10 11:08:38 +01:00
long eOid = 0 ;
long tOid = 0 ;
2021-06-22 20:55:30 +02:00
long catOid = 0 ;
2016-06-27 01:45:38 +02:00
2017-02-10 11:08:38 +01:00
if ( _SelectedEmployee ! = null & & checkbox_allEmployees . IsChecked = = false )
{
eOid = _SelectedEmployee . EmployeeOid ;
}
if ( _SelectedTeam ! = null & & checkbox_all_teams . IsChecked = = false )
{
tOid = _SelectedTeam . TeamOid ;
}
2021-06-22 20:55:30 +02:00
if ( ChkFilterServiceCategory . IsChecked . HasValue & & ChkFilterServiceCategory . IsChecked . Value & & ServiceCategoriesComboBox . SelectedItem ! = null )
{
var cat = ServiceCategoriesComboBox . SelectedItem as ServiceCategoryDC ;
catOid = cat . ServiceCategoryOid . Value ;
}
2017-03-24 10:30:18 +01:00
List < SupportConceptOverviewDC > itemList = new List < SupportConceptOverviewDC > ( ) ;
if ( ! String . IsNullOrWhiteSpace ( textbox_search . Text ) )
{
var visibleScItems = listview_list . Items ;
foreach ( var item in visibleScItems )
{
var dcList = ( ( KeyValuePair < string , List < SupportConceptOverviewDC > > ) item ) . Value ;
foreach ( var dc in dcList )
{
itemList . Add ( dc ) ;
}
}
}
if ( itemList ! = null & & itemList . Count > 0 )
{
StringBuilder oidString = new StringBuilder ( ) ;
foreach ( var item in itemList )
{
if ( oidString . Length > 0 )
{
oidString . Append ( "," ) ;
}
oidString . Append ( item . CostBearer2SupportConceptOid ) ;
}
url = BeWoApp . SiteOfOrigin + "/ReportView.aspx"
//+ "?tenant=" + BeWoApp.Tenant
//+ "&username=" + BeWoApp.UserName
//+ "&token=" + BeWoApp.LoggedOnUser.RC2Password
+ "?c2slist=" + oidString . ToString ( )
+ "&type=" + Utils . EnumName ( ReportTypes . SupportConceptReport ) ;
}
else
{
// if (ViewModel != null && ViewModel.ServiceRecordsForSelectedCustomer != null && ViewModel.ServiceRecordsForSelectedCustomer.Count > 0)
// {
url = BeWoApp . SiteOfOrigin + "/ReportView.aspx"
//+ "?tenant=" + BeWoApp.Tenant
//+ "&username=" + BeWoApp.UserName
//+ "&token=" + BeWoApp.LoggedOnUser.RC2Password
+ "?eOid=" + eOid
+ "&tOid=" + tOid
2021-06-22 20:55:30 +02:00
+ "&catOid=" + catOid
2017-03-24 10:30:18 +01:00
+ "&exp=" + months
+ "&arc=" + showArchived
+ "&type=" + Utils . EnumName ( ReportTypes . SupportConceptReport ) ;
}
2016-06-27 01:45:38 +02:00
if ( datepicker_appointeddate . EditValue ! = null )
url + = "&date=" + String . Format ( "{0:d}" , datepicker_appointeddate . DateTime ) ;
2022-08-25 12:51:53 +02:00
if ( datepicker_startdate . EditValue ! = null )
url + = "&start=" + String . Format ( "{0:d}" , datepicker_startdate . DateTime ) ;
2016-06-27 01:45:38 +02:00
url = BeWoWpfUtils . GetHTMLEncodedURL ( url ) ;
this . linkPdfExport . NavigateUri = new Uri ( url ) ;
// }
}
private void buttonRefresh_Click ( object sender , RoutedEventArgs e )
{
2017-03-24 10:30:18 +01:00
//this.UpdateReportUrl();
2022-08-25 12:51:53 +02:00
DateTime ? startdate = null ;
DateTime ? enddate = null ;
2016-06-27 01:45:38 +02:00
if ( this . datepicker_appointeddate . EditValue ! = null )
2022-08-25 12:51:53 +02:00
enddate = this . datepicker_appointeddate . DateTime ;
if ( this . datepicker_startdate . EditValue ! = null )
startdate = this . datepicker_startdate . DateTime ;
2016-06-27 01:45:38 +02:00
2017-03-24 10:30:18 +01:00
int? months = null ;
if ( this . ChkHpDieAuslaufen . IsChecked . Value )
{
months = BeWoApp . AppSettings . HilfeplanAuslaufAuswahl ;
}
bool showArchived = this . chkShowArchived . IsChecked . Value ;
long? eOid = null ;
long? tOid = null ;
2021-06-22 20:55:30 +02:00
long? catOid = null ;
2017-03-24 10:30:18 +01:00
2020-09-02 18:19:15 +02:00
if ( _SelectedEmployee ! = null & & checkbox_allEmployees . IsChecked = = false & & radioEmployeeReport . IsChecked . HasValue & & radioEmployeeReport . IsChecked . Value )
2017-03-24 10:30:18 +01:00
{
eOid = _SelectedEmployee . EmployeeOid ;
}
2020-09-02 18:19:15 +02:00
if ( _SelectedTeam ! = null & & checkbox_all_teams . IsChecked = = false & & radioTeamReport . IsChecked . HasValue & & radioTeamReport . IsChecked . Value )
2017-03-24 10:30:18 +01:00
{
tOid = _SelectedTeam . TeamOid ;
}
2023-04-20 00:53:02 +02:00
if ( ChkFilterServiceCategory . IsChecked . HasValue & & ChkFilterServiceCategory . IsChecked . Value & & ServiceCategoriesComboBox . SelectedItem ! = null )
2021-06-22 20:55:30 +02:00
{
var cat = ServiceCategoriesComboBox . SelectedItem as ServiceCategoryDC ;
catOid = cat . ServiceCategoryOid . Value ;
}
2017-03-24 10:30:18 +01:00
2022-08-25 12:51:53 +02:00
ServiceFacade . DoAnalysisServiceAsync ( s = > s . GetSupportConceptAnalysis4 ( eOid , tOid , catOid , startdate , enddate , months , showArchived ) ,
2016-06-27 01:45:38 +02:00
r = >
{
this . Dispatch (
delegate
{
this . _UnfilteredSupportConcept2Overviews = r . OrderBy ( o = > o . CustomerLastName + ", " + o . CustomerFirstName ) . GroupBy ( so = > so . CustomerLastName + ", " + so . CustomerFirstName ) . ToDictionary ( g = > g . Key , g = > g . ToList ( ) ) ;
this . DataContext = this . _UnfilteredSupportConcept2Overviews ;
} ) ;
} ) ;
}
private void listview_list_SelectionChanged ( object sender , SelectionChangedEventArgs e )
{
if ( this . listview_list . SelectedItem ! = null )
{
( this . listview_list . ItemContainerGenerator . ContainerFromItem ( this . listview_list . SelectedItem ) as ListViewItem ) . IsSelected = false ;
}
}
private void textbox_searchVisible_TextChanged ( object sender , TextChangedEventArgs e )
{
String test = textbox_searchVisible . Text ;
textbox_search . Text = test ;
}
private void LinkPdfExport_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
2017-03-24 10:30:18 +01:00
UpdateReportUrl ( ) ;
2017-12-07 11:14:50 +01:00
BeWoUtils . NavigateToReportUri ( ( sender as System . Windows . Documents . Hyperlink ) . NavigateUri . ToString ( ) , Translator . Translate ( "Hilfeplanübersicht" ) ) ;
2016-06-27 01:45:38 +02:00
//System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString()));
}
2017-02-10 11:08:38 +01:00
private void CheckBoxAllEmployees_Checked ( object sender , RoutedEventArgs e )
{
2017-03-24 10:30:18 +01:00
if ( popupedit_employee = = null )
return ;
popupedit_employee . Text = string . Empty ;
_SelectedEmployee = null ;
ChangeReportType ( ) ;
2017-02-10 11:08:38 +01:00
}
private void popupedit_employee_PopUpClick ( object sender , RoutedEventArgs e )
{
this . popup_employee . IsOpen = true ;
}
private void CheckBoxAllTeams_Checked ( object sender , RoutedEventArgs e )
{
if ( popupedit_team ! = null )
{
popupedit_team . Text = string . Empty ;
_SelectedTeam = null ;
}
2017-03-24 10:30:18 +01:00
ChangeReportType ( ) ;
2017-02-10 11:08:38 +01:00
}
private void popupedit_team_PopUpClick ( object sender , RoutedEventArgs e )
{
this . popup_team . IsOpen = true ;
}
private void EmployeeSearchView_ItemSelected ( object sender , EventArgs < CompactEmployeeDC > e )
{
_SelectedEmployee = e . Data ;
popupedit_employee . Text = _SelectedEmployee . ToString ( ) ;
popup_employee . IsOpen = false ;
}
private void TeamSearchView_ItemSelected ( object sender , EventArgs < CompactTeamDC > e )
{
_SelectedTeam = e . Data ;
popupedit_team . Text = _SelectedTeam . ToString ( ) ;
popup_team . IsOpen = false ;
}
2017-03-24 10:30:18 +01:00
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_allEmployees . 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_allEmployees . IsChecked . HasValue & & checkbox_allEmployees . Visibility = = Visibility . Visible )
{
popupedit_employee . Visibility = checkbox_allEmployees . 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 ( ! DarfAlleMitarbeiterSehen )
{
2023-07-09 23:58:10 +02:00
checkbox_allEmployees . IsEnabled = false ;
checkbox_allEmployees . IsChecked = false ;
popupedit_employee . IsEnabled = false ;
2017-03-24 10:30:18 +01:00
if ( ! DarfTeamsSehen )
{
checkbox_all_teams . IsEnabled = false ;
popupedit_team . IsEnabled = false ;
radioTeamReport . IsEnabled = false ;
radioEmployeeReport . IsEnabled = false ;
//checkbox_showTeamReport.Visibility = Visibility.Collapsed;
}
2024-06-06 10:21:24 +02:00
//else
//{
// //checkbox_all.Visibility = Visibility.Collapsed;
// //popupedit_employee.Visibility = Visibility.Collapsed;
// List<CompactEmployeeDC> mitarbeiterAllerTeams = new List<CompactEmployeeDC>();
// 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;
// //foreach (var t in teams)
// //{
// // var t = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllTeamMember())
// // var emps = t.
// //}
// }
//}
2017-03-24 10:30:18 +01:00
}
//if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.SupportConcept_ViewAllSupportConcepts) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll))
//{
// checkbox_allEmployees.IsEnabled = false;
//}
}
}
2016-06-27 01:45:38 +02:00
}
}