import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assigned_employee.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';

class ActivityMaintenanceHelperModel {
  int? id;
  int? workOrderId;
  int? lastSituationId;
  Lookup? lastSituation;
  Lookup? activityStatus;
   DateTime? startTime;
   DateTime? endTime;
  num? workingHour;
  num? travelHours;
  Lookup? repairLocation;
  SupplierDetails? supplier;
  String? assignedEmployeeId;
  String? technicalComment;
  int? supplierId;
  int? supplierEngineerId;
  DateTime? supplierStartTime;
  DateTime? supplierEndTime;
  num? supplierWorkingHour;
  // AssignedEmployee? assignedEmployee;
  WorkOrderAssignedEmployee? assignedEmployee;
  SuppEngineerWorkOrders? supEngineer;
  ActivityMaintenanceAssistantEmployees? modelAssistantEmployees;
  List<AssistantEmployees>? assistantEmployees;

  ActivityMaintenanceHelperModel(
      {this.id,
        this.workOrderId,
        this.lastSituationId,
        this.lastSituation,
        this.activityStatus,
        this.startTime,
        this.supplier,
        this.endTime,
        this.workingHour,
        this.travelHours,
        this.repairLocation,
        this.assignedEmployeeId,
        this.technicalComment,
        this.supplierId,
        this.supplierEngineerId,
        this.supplierStartTime,
        this.supplierEndTime,
        this.supplierWorkingHour,
        this.assistantEmployees,
        this.supEngineer,
        this.assignedEmployee,
        this.modelAssistantEmployees});


  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['workOrderId'] = workOrderId;

    data['activityStatusId'] = activityStatus?.id;
    data['startTime'] = startTime?.toIso8601String();
    data['endTime'] = endTime?.toIso8601String();
    data['workingHour'] = workingHour;
    data['travelHours'] = travelHours;
    data['repairLocationId'] = repairLocation?.id;
    data['assignedEmployeeId'] = assignedEmployee?.userId;
    data['technicalComment'] = technicalComment;
    data['supplierId'] = supplier?.id;
    data['supplierEngineerId'] = supEngineer?.id;
    data['supplierStartTime'] = supplierStartTime?.toIso8601String();
    data['supplierEndTime'] = supplierEndTime?.toIso8601String();
    data['supplierWorkingHour'] = supplierWorkingHour;
    if(lastSituation!=null){
      data['lastSituationId'] = lastSituation?.id;
    }
    if (assistantEmployees != null&&assistantEmployees!.isNotEmpty) {
      data['assistantEmployees'] =  [modelAssistantEmployees?.toJson()];
    }
    else{
      data['assistantEmployees']=[];
    }
    return data;
  }
}

