import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/models/lookup.dart';
import 'loan_attachment_model.dart';

class LoanRequestModel {
  String? requestorUserID;
  int? reqNo;
  String? reqCode;
  String? requestorUserName;
  String? requestorUserEmail;
  String? requestorUserIdForDisplay;
  int? requesterUserPositionId;
  String? requesterExtensionNo;
  String? requestorUserMobileNumber;
  int? loanTypeId;
  String? loanTypeName;
  int? siteId;
  String? siteName;
  int? departmentId;
  String? departmentName;
  String? doctorName;
  String? doctorContact;
  String? doctorEmail;
  String? itemDescription;
  String? requestDescription;
  int? assetId;
  String? assetNumber;
  String? assetName;
  String? assetSerialNumber;
  String? model;
  String? manufacturer;
  int? loanPeriodId;
  String? loanPeriodName;
  String? vendorName;
  String? vendorRepName;
  String? vendorContact;
  String? vendorEmail;
  List<GenericAttachmentModel>? loanAttachments;
  int? loanStatusId;
  String? loanStatusName;
  int? loanStatusValue;
  String? installationEDD;
  String? pulloutEDD;
  String? mdUserID;
  User? mdUser;
  String? mesUserID;
  User? mesUser;
  String? assignedFEForInstallationUserID;
  User? assignedFEForInstallationUser;
  String? assignedFEForPulloutUserID;
  User? assignedFEForPulloutUser;
  int? cmwoItemId;
  int? installationWOItemId;
  int? pulloutWOItemId;
  int? id;
  String? installationDate;
  String? startTime;
  String? endTime;
  String? pulloutDate;
  String? createdBy;
  String? createdDate;
  String? modifiedBy;
  String? modifiedDate;

  LoanRequestModel(
      {this.requestorUserID,
      this.reqNo,
      this.reqCode,
      this.requestorUserName,
      this.requestorUserEmail,
      this.requestorUserIdForDisplay,
      this.requesterUserPositionId,
      this.requesterExtensionNo,
      this.requestorUserMobileNumber,
      this.loanTypeId,
      this.loanTypeName,
      this.siteId,
      this.siteName,
      this.departmentId,
      this.departmentName,
      this.doctorName,
      this.doctorContact,
      this.doctorEmail,
      this.itemDescription,
      this.requestDescription,
      this.assetId,
      this.assetNumber,
      this.assetName,
      this.assetSerialNumber,
      this.model,
      this.manufacturer,
      this.loanPeriodId,
      this.loanPeriodName,
      this.vendorName,
      this.vendorRepName,
      this.vendorContact,
      this.vendorEmail,
      this.loanAttachments,
      this.loanStatusId,
      this.loanStatusName,
      this.loanStatusValue,
      this.installationEDD,
      this.pulloutEDD,
      this.mdUserID,
      this.mdUser,
      this.mesUserID,
      this.mesUser,
      this.assignedFEForInstallationUserID,
      this.assignedFEForInstallationUser,
      this.assignedFEForPulloutUserID,
      this.assignedFEForPulloutUser,
      this.cmwoItemId,
      this.installationWOItemId,
      this.pulloutWOItemId,
      this.id,
      this.createdBy,
      this.installationDate,
      this.startTime,
      this.endTime,
      this.pulloutDate,
      this.createdDate,
      this.modifiedBy,
      this.modifiedDate});

  LoanRequestModel.fromJson(Map<String, dynamic> json) {
    requestorUserID = json['requestorUserID'];
    reqNo = json['reqNo'];
    reqCode = json['reqCode'];
    requestorUserName = json['requestorUserName'];
    requestorUserEmail = json['requestorUserEmail'];
    requestorUserIdForDisplay = json['requestorUserIdForDisplay'];
    requesterUserPositionId = json['requesterUserPositionId'];
    requesterExtensionNo = json['requesterExtensionNo'];
    requestorUserMobileNumber = json['requestorUserMobileNumber'];
    loanTypeId = json['loanTypeId'];
    loanTypeName = json['loanTypeName'];
    siteId = json['siteId'];
    siteName = json['siteName'];
    departmentId = json['departmentId'];
    departmentName = json['departmentName'];
    doctorName = json['doctorName'];
    doctorContact = json['doctorContact'];
    doctorEmail = json['doctorEmail'];
    itemDescription = json['itemDescription'];
    requestDescription = json['requestDescription'];
    assetId = json['assetId'];
    assetNumber = json['assetNumber'];
    assetName = json['assetName'];
    assetSerialNumber = json['assetSerialNumber'];
    model = json['model'];
    manufacturer = json['manufacturer'];
    loanPeriodId = json['loanPeriodId'];
    loanPeriodName = json['loanPeriodName'];
    vendorName = json['vendorName'];
    vendorRepName = json['vendorRepName'];
    vendorContact = json['vendorContact'];
    vendorEmail = json['vendorEmail'];
    loanAttachments = <GenericAttachmentModel>[];
    if (json['loanAttachments'] != null) {
      loanAttachments = <GenericAttachmentModel>[];
      json['loanAttachments'].forEach((v) {
        loanAttachments!.add(GenericAttachmentModel.fromLoanDetailJson(v));
      });
    }
    loanStatusId = json['loanStatusId'];
    loanStatusName = json['loanStatusName'];
    loanStatusValue = json['loanStatusValue'];
    installationEDD = json['installationEDD'];
    pulloutEDD = json['pulloutEDD'];
    mdUserID = json['mdUserID'];
    mdUser = json['mdUser'] == null ? null : User.fromJson(json['mdUser']);
    mesUserID = json['mesUserID'];
    mesUser = json['mesUser'] == null ? null : User.fromJson(json['mesUser']);
    assignedFEForInstallationUserID = json['assignedFEForInstallationUserID'];
    assignedFEForInstallationUser = json['assignedFEForInstallationUser'] == null ? null : User.fromJson(json['assignedFEForInstallationUser']);
    assignedFEForPulloutUserID = json['assignedFEForPulloutUserID'];
    assignedFEForPulloutUser = json['assignedFEForPulloutUser'] == null ? null : User.fromJson(json['assignedFEForPulloutUser']);
    cmwoItemId = json['cmwoItemId'];
    installationWOItemId = json['installationWOItemId'];
    pulloutWOItemId = json['pulloutWOItemId'];
    id = json['id'];
    installationDate = json['installationDate'];
    startTime = json['startTime'];
    endTime = json['endTime'];
    pulloutDate = json['pulloutDate'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    modifiedBy = json['modifiedBy'];
    modifiedDate = json['modifiedDate'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['requestorUserID'] = this.requestorUserID;
    data['reqNo'] = this.reqNo;
    data['reqCode'] = this.reqCode;
    data['requestorUserName'] = this.requestorUserName;
    data['requestorUserEmail'] = this.requestorUserEmail;
    data['requestorUserIdForDisplay'] = this.requestorUserIdForDisplay;
    data['requesterUserPositionId'] = this.requesterUserPositionId;
    data['requesterExtensionNo'] = this.requesterExtensionNo;
    data['requestorUserMobileNumber'] = this.requestorUserMobileNumber;
    data['loanTypeId'] = this.loanTypeId;
    data['loanTypeName'] = this.loanTypeName;
    data['siteId'] = this.siteId;
    data['siteName'] = this.siteName;
    data['departmentId'] = this.departmentId;
    data['departmentName'] = this.departmentName;
    data['doctorName'] = this.doctorName;
    data['doctorContact'] = this.doctorContact;
    data['doctorEmail'] = this.doctorEmail;
    data['itemDescription'] = this.itemDescription;
    data['requestDescription'] = this.requestDescription;
    data['assetId'] = this.assetId;
    data['assetNumber'] = this.assetNumber;
    data['assetName'] = this.assetName;
    data['assetSerialNumber'] = this.assetSerialNumber;
    data['model'] = this.model;
    data['manufacturer'] = this.manufacturer;
    data['loanPeriodId'] = this.loanPeriodId;
    data['loanPeriodName'] = this.loanPeriodName;
    data['vendorName'] = this.vendorName;
    data['vendorRepName'] = this.vendorRepName;
    data['vendorContact'] = this.vendorContact;
    data['vendorEmail'] = this.vendorEmail;
    if (loanAttachments != null) {
      data['loanAttachments'] = loanAttachments!.map((v) => v.toLoanDetailJson()).toList();
    }
    data['loanStatusId'] = this.loanStatusId;
    data['loanStatusName'] = this.loanStatusName;
    data['loanStatusValue'] = this.loanStatusValue;
    data['installationEDD'] = this.installationEDD;
    data['pulloutEDD'] = this.pulloutEDD;
    data['mdUserID'] = this.mdUserID;
    data['mdUser'] = this.mdUser?.toJson();
    data['mesUserID'] = this.mesUserID;
    data['mesUser'] = this.mesUser;
    data['assignedFEForInstallationUserID'] = this.assignedFEForInstallationUserID;
    data['assignedFEForInstallationUser'] = this.assignedFEForInstallationUser?.toJson();
    data['assignedFEForPulloutUserID'] = this.assignedFEForPulloutUserID;
    data['assignedFEForPulloutUser'] = this.assignedFEForPulloutUser?.toJson();
    data['cmwoItemId'] = this.cmwoItemId;
    data['installationWOItemId'] = this.installationWOItemId;
    data['pulloutWOItemId'] = this.pulloutWOItemId;
    data['id'] = this.id;
    data['installationDate'] = this.installationDate;
    data['startTime'] = this.startTime;
    data['endTime'] = this.endTime;
    data['pulloutDate'] = this.pulloutDate;
    data['createdBy'] = this.createdBy;
    data['createdDate'] = this.createdDate;
    data['modifiedBy'] = this.modifiedBy;
    data['modifiedDate'] = this.modifiedDate;
    return data;
  }
}
//
// class MdUser {
//   String? id;
//   String? name;
//
//   MdUser({this.id, this.name});
//
//   MdUser.fromJson(dynamic json) {
//     id = json['id'] ?? '';
//     name = json['name'] ?? '';
//   }
//
//   Map<String, dynamic> toJson() {
//     final map = <String, dynamic>{};
//     map['id'] = id;
//     map['name'] = name;
//     return map;
//   }
// }

class User {
  String? id;
  String? name;
  String? email;
  String? employeeId;
  int? languageId;
  String? extensionNo;
  String? phoneNumber;
  String? positionName;
  String? position;
  bool? isActive;

  User({this.id, this.name, this.email, this.employeeId, this.languageId, this.extensionNo, this.phoneNumber, this.positionName, this.position, this.isActive});

  User.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    email = json['email'];
    employeeId = json['employeeId'];
    languageId = json['languageId'];
    extensionNo = json['extensionNo'];
    phoneNumber = json['phoneNumber'];
    positionName = json['positionName'];
    position = json['position'];
    isActive = json['isActive'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['email'] = this.email;
    data['employeeId'] = this.employeeId;
    data['languageId'] = this.languageId;
    data['extensionNo'] = this.extensionNo;
    data['phoneNumber'] = this.phoneNumber;
    data['positionName'] = this.positionName;
    data['position'] = this.position;
    data['isActive'] = this.isActive;
    return data;
  }
}
