|
@@ -2,11 +2,13 @@
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
+using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using Comal.Classes;
|
|
|
using FastReport.DataVisualization.Charting;
|
|
|
+using InABox.Clients;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
@@ -19,6 +21,8 @@ namespace PRSDesktop
|
|
|
{
|
|
|
private bool ShowAll;
|
|
|
|
|
|
+ private Button SendFormButton = null!;
|
|
|
+
|
|
|
public EmployeeGrid()
|
|
|
{
|
|
|
}
|
|
@@ -48,36 +52,88 @@ namespace PRSDesktop
|
|
|
//HiddenColumns.Add(x => x.InOut);
|
|
|
|
|
|
AddButton("Show All", PRSDesktop.Resources.anonymous.AsBitmapImage(Color.White), ToggleFinishedEmployees);
|
|
|
+
|
|
|
+ SendFormButton = AddButton("Send Form", PRSDesktop.Resources.kanban.AsBitmapImage(Color.White), CreateEmployeeForms);
|
|
|
}
|
|
|
|
|
|
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
+ protected override void SelectItems(CoreRow[]? rows)
|
|
|
{
|
|
|
- base.DoReconfigure(options);
|
|
|
- options.AddRange(
|
|
|
- DynamicGridOption.FilterRows,
|
|
|
- DynamicGridOption.SelectColumns,
|
|
|
- DynamicGridOption.MultiSelect
|
|
|
- );
|
|
|
+ base.SelectItems(rows);
|
|
|
+
|
|
|
+ SendFormButton.IsEnabled = rows is not null && rows.Length > 0;
|
|
|
}
|
|
|
|
|
|
- private bool SelectRoster(Employee[] employees)
|
|
|
+ private bool CreateEmployeeForms(Button button, CoreRow[] rows)
|
|
|
{
|
|
|
+ if(rows.Length == 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Please select at least one row.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var select = new MultiSelectDialog<DigitalForm>(
|
|
|
+ LookupFactory.DefineFilter<EmployeeForm, DigitalForm>(Array.Empty<EmployeeForm>()),
|
|
|
+ LookupFactory.DefineColumns<DigitalForm>()
|
|
|
+ .Add(x => x.ID)
|
|
|
+ .Add(x => x.Description),
|
|
|
+ false);
|
|
|
+ if (select.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ var digitalForm = select.Data().Rows.FirstOrDefault()?.ToObject<DigitalForm>();
|
|
|
+
|
|
|
+ if (digitalForm is not null)
|
|
|
+ {
|
|
|
+ var employees = Client.Query(
|
|
|
+ new Filter<EmployeeDigitalForm>(x => x.Form.ID).IsEqualTo(digitalForm.ID),
|
|
|
+ new Columns<EmployeeDigitalForm>(x => x.Employee.ID))
|
|
|
+ .Rows.Select(x => x.Get<EmployeeDigitalForm, Guid>(x => x.Employee.ID))
|
|
|
+ .ToArray();
|
|
|
+ var selectedEmployees = rows.Select(x => x.ToObject<Employee>()).ToArray();
|
|
|
+ var warningEmployees = selectedEmployees.Where(x => !employees.Contains(x.ID));
|
|
|
+ if (warningEmployees.Any())
|
|
|
+ {
|
|
|
+ var result = MessageBox.Show($"The selected form is not usually available for {string.Join(',', warningEmployees.Select(x => x.Code))}, since it has not been assigned to their role; do you still wish to send this form?", "Confirm", MessageBoxButton.YesNo);
|
|
|
+ if(result != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Sending form cancelled.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var employeeForms = new List<EmployeeForm>(rows.Length);
|
|
|
+ foreach(var employee in selectedEmployees)
|
|
|
+ {
|
|
|
+ var employeeForm = new EmployeeForm();
|
|
|
+ employeeForm.Form.ID = digitalForm.ID;
|
|
|
+ employeeForm.Description = digitalForm.Description;
|
|
|
+ employeeForm.Parent.ID = employee.ID;
|
|
|
+ employeeForms.Add(employeeForm);
|
|
|
+ }
|
|
|
+ Client.Save(employeeForms, "Assigned to employee by user");
|
|
|
+ MessageBox.Show("Form sent.");
|
|
|
+ }
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private bool SelectRosterStart(Employee[] employees)
|
|
|
+ protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
{
|
|
|
- return false;
|
|
|
+ base.DoReconfigure(options);
|
|
|
+ options.AddRange(
|
|
|
+ DynamicGridOption.FilterRows,
|
|
|
+ DynamicGridOption.SelectColumns,
|
|
|
+ DynamicGridOption.MultiSelect
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
private void MenuBuild(DynamicMenuColumn column, CoreRow? row)
|
|
|
{
|
|
|
- if (row == null) return;
|
|
|
+ if (row is null) return;
|
|
|
var newItem = column.AddItem("Digital Forms", null, null);
|
|
|
DynamicGridUtils.PopulateFormMenu<EmployeeForm, Employee, EmployeeLink>(
|
|
|
newItem,
|
|
|
row.Get<Employee, Guid>(x => x.ID),
|
|
|
- () => row.ToObject<Employee>());
|
|
|
+ row.ToObject<Employee>);
|
|
|
|
|
|
column.AddSeparator();
|
|
|
|
|
@@ -85,13 +141,17 @@ namespace PRSDesktop
|
|
|
column.AddItem("Available Forms", PRSDesktop.Resources.kanban, ShowRoleFormsWindow);
|
|
|
}
|
|
|
|
|
|
- private void ShowActivitiesWindow(CoreRow row)
|
|
|
+ private void ShowActivitiesWindow(CoreRow? row)
|
|
|
{
|
|
|
+ if (row is null) return;
|
|
|
+
|
|
|
DynamicGridUtils.CreateGridWindow("Employee Activities",
|
|
|
new EmployeeActivityGrid() { Left = row.ToObject<Employee>() }).ShowDialog();
|
|
|
}
|
|
|
- private void ShowRoleFormsWindow(CoreRow row)
|
|
|
+ private void ShowRoleFormsWindow(CoreRow? row)
|
|
|
{
|
|
|
+ if (row is null) return;
|
|
|
+
|
|
|
DynamicGridUtils.CreateGridWindow("Employee Role Forms",
|
|
|
new EmployeeRoleFormGrid() { Left = row.ToObject<Employee>() }).ShowDialog();
|
|
|
}
|