// Lookup Service interface which retrieves information from the database
// which is then sent to the client.
// Authors:
// Cameron Hayes
// Mac ...
// Elias Sarraf

unit Lookup.Service;

interface

uses
  XData.Service.Common,
  Aurelius.Mapping.Attributes,
  System.JSON,
  System.Generics.Collections,
  System.Classes;

const
  API_MODEL = 'Api';

type

  TUserItem = class
  public
    userID: string;
    username: string;
    password: string;
    full_name: string;
    status: string;
    email_address: string;
    Atype: string;
    rights: integer;
    perspectiveID: string;
    QBID: string;
  end;

  TUserList = class
  public
    count: integer;
    data: TList<TUserItem>;
  end;

  TItemItem = class
  public
    ID: string;
    name: string;
    description: string;
    status: string;
  end;

  TItemList = class
  public
    count: integer;
    data: TList<TItemItem>;
  end;

  TOrderItem = class
  public
    ID,
    companyName,
    jobName,
    orderDate,
    proofDue,
    proofDone,
    artDue,
    artDone,
    plateDue,
    plateDone,
    mountDue,
    mountDone,
    shipDue,
    shipDone,
    price,
    qbRefNum,
    orderType,
    colors: string;

  end;

  TStatusSearchInfo = class
  Public
    startDate,
    endDate,
    filterType,
    statusType,
    statusSuffix,
    statusTableShort,
    statusTableLong,
    altStatusTableShort,
    altStatusTableLong: string;
    null: boolean;
  end;


  TSQLQuery = class
  Public
    SQL,
    whereSQL: string;
  end;

  TOrderList = class
  Public
    count: integer;
    data: TList<TOrderItem>;
  end;

  TAddressItem = class
  Public
    ADDRESS: string;
  end;

  TCustomerItem = class
  Public
    NAME: string;
    ID: integer;
    SHORT_NAME: string;
    staff_fields_invoice_to: string;
    ADDRESS_LIST: TList<TAddressItem>;
  end;

  TCustomerList = class
  Public
    count: integer;
    data: TList<TCustomerItem>;
  end;

  TFullOrder = class //TODO change name to TCorrugatedOrder
  Public
      //Company
      COMPANY_ID: integer;
      NAME: string;
      SHORT_NAME: string;
      inQuickBooks: string;
      ADDRESS_LIST: TList<TAddressItem>;
      ITEMS: TItemList;

      // Staff Fields:
      staff_fields_order_date: string;
      staff_fields_proof_date: string;
      staff_fields_ship_date: string;
      staff_fields_ship_via: string;
      staff_fields_quantity: string;
      staff_fields_price: string;
      staff_fields_invoice_to: string;
      staff_fields_ship_to: string;
      staff_fields_po_number: string;
      staff_fields_job_name: string;
      staff_fields_quickbooks_item: string;
      staff_fields_art_due: string;
      staff_fields_plate_due: string;
      staff_fields_mount_due: string;
      staff_fields_art_location: string;

      // Supplied by Customer:
      supplied_by_customer_b_w_copy: boolean;
      supplied_by_customer_color_copy: boolean;
      supplied_by_customer_plates: boolean;
      supplied_by_customer_sample_ca: boolean;
      supplied_by_customer_dimension: string;
      supplied_by_customer_disk_or_cd: boolean;
      supplied_by_customer_e_mail: string;
      supplied_by_customer_ftp: string;
      supplied_by_customer_other: string;
      supplied_by_customer_existing_: string;
      supplied_by_customer_ref_art_p: string;
      supplied_by_customer_ref_art_a: string;

      // Layout
      layout_rsc_l: string;

      //Typos to match database typos
      layout_rcs_w: string;
      layout_rcs_d: string;

      layout_die_cut_no: string;
      layout_accross_no: string;
      layout_around_no: string;
      layout_cad_file: string;
      layout_excalibur_die: boolean;
      layout_rsc_style: string;

      // Mounting
      mounting_loose: string;
      mounting_sticky_bak: boolean;
      mounting_full_mount: boolean;
      mounting_strip_mount: string;
      mounting_standard_setup: string;
      mounting_custom_backing: string;
      mounting_custom_adhesive: string;

       // Colors
       colors_cylinder_size: string;
       colors_machine_ident: string;
       colors_cross_hairs: string;
       colors_clemson: string;
       colors_colors: string;

       // Proofing
       proofing_fax: string;
       proofing_fax_attn: string;
       proofing_e_mail: string;
       proofing_e_mail_attn: string;
       proofing_ship_to: string;
       proofing_full_size_panel: boolean;
       proofing_print_card: boolean;
       proofing_wide_format: boolean;
       proofing_pdf_file: boolean;
       proofing_other: string;
       proofing_art_approved_as_is: boolean;
       proofing_approved_date: string;

       // Plates
       plates_thickness: string;
       plates_plate_material: string;
       plates_job_number: string;

       // General
       general_special_instructions: string;
  end;

  TWebOrder = class
  Public
      //Company
      COMPANY_ID: integer;
      NAME: string;
      SHORT_NAME: string;
      inQuickBooks: string;
      ADDRESS_LIST: TList<TAddressItem>;
      ITEMS: TItemList;

      // Staff Fields:
      staff_fields_order_date: string;
      staff_fields_proof_date: string;
      staff_fields_ship_date: string;
      staff_fields_ship_via: string;
      staff_fields_quantity: string;
      staff_fields_price: string;
      staff_fields_invoice_to: string;
      staff_fields_ship_to: string;
      staff_fields_po_number: string;
      staff_fields_job_name: string;
      staff_fields_quickbooks_item: string;
      staff_fields_art_due: string;
      staff_fields_plate_due: string;
      staff_fields_mount_due: string;
      staff_fields_art_location: string;

      // Supplied by Customer:
      supplied_by_customer_b_w_or_co: string;
      supplied_by_customer_plates: string;
      supplied_by_customer_sample: string;
      supplied_by_customer_dimension: string;
      supplied_by_customer_other: string;
      supplied_by_customer_disk: string;
      supplied_by_customer_e_mail: string;
      supplied_by_customer_ftp: string;
      supplied_by_customer_total_inc: string;
      supplied_by_customer_sheets_us: string;
      supplied_by_customer_initials: string;

      // Proofing
      proofing_pdf: boolean;
      proofing_pdf_to: string;
      proofing_pdf_date_1: string;
      proofing_pdf_date_2: string;
      proofing_pdf_date_3: string;
      proofing_full_size_ink_jet_for: boolean;
      proofing_ink_jet_to: string;
      proofing_ink_jet_to_2: string;
      proofing_ink_jet_date_1: string;
      proofing_ink_jet_date_2: string;
      proofing_color_contract: string;
      proofing_color_contrac_to: string;
      proofing_color_contrac_date_1: string;
      proofing_color_contrac_date_2: string;
      proofing_digital_color_key: string;
      proofing_digital_color_to: string;
      proofing_digital_color_date_1: string;

      // Print Orientation
      print_orientation_print_orient: string;

      // Plate
      plates_plate_material: string;
      plates_thickness: string;
      plates_job_number: string;

      // Quantity and Color
      quantity_and_colors_press_name: string;
      quantity_and_colors_anilox_info: string;
      quantity_and_colors_qty_colors: string;

      // Plate Marks

      plate_marks_microdots: string;
      plate_marks_microdots_comments: string;
      plate_marks_crosshairs: string;
      plate_marks_crosshairs_comments: string;
      plate_marks_color_bars: string;
      plate_marks_color_bars_comments: string;
      plate_marks_other: string;
      plate_marks_other_comments: string;

      // Layout
      layout_around: string;
      layout_accross: string;
      layout_surface_print: string;

      layout_reverse_print: string;
      layout_cylinder_repeat: string;
      layout_cutoff_dimension: string;
      layout_pitch: string;
      layout_teeth: string;
      layout_bleed: string;
      layout_cutback: string;
      layout_minimum_trap_dim: string;
      layout_maximum_trap_dim: string;

       // UPC
       upc_size: string;
       upc_bar_width_reduction: string;
       upc_distortion_percent: string;
       upc_distortion_amount: string;

       // General
       general_comments: string;
  end;


type
  [ServiceContract, Model(API_MODEL)]
  ILookupService = interface(IInvokable)
    ['{F24E1468-5279-401F-A877-CD48B44F4416}']
    [HttpGet] function GetUsers(searchOptions: string): TUserList;
    [HttpGet] function GetItems(searchOptions: string): TItemList;
    [HttpGet] function GetOrders(searchOptions: string): TOrderList;
    [HttpGet] function GetOrder(orderInfo: string): TFullOrder;
    [HttpGet] function GetWebOrder(orderInfo: string): TWebOrder;
    [HttpGet] function GetCustomers(): TCustomerList;
    [HttpGet] function GetCustomer(ID: string): TCustomerItem;
    [HttpGet] function GenerateReportPDF(searchOptions: string): string;


    function AddUser(userInfo: string): string;
    function AddItem(itemInfo: string): string;
    function DelUser(username: string): string;
    function EditUser(const editOptions: string): string;
    function AddCorrugatedOrder(orderInfo: string): TJSONObject;
    function AddWebOrder(orderInfo: string): TJSONObject;
    function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
    function SetStatus(statusOptions: string): string;
  end;

implementation

initialization
  RegisterServiceType(TypeInfo(ILookupService));

end.
