// 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
  Public
      //Company
      COMPANY_ID: integer;
      NAME: string;
      SHORT_NAME: string;
      inQuickBooks: string;

      // 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;



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 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 AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
    function SetStatus(statusOptions: string): string;
  end;

implementation

initialization
  RegisterServiceType(TypeInfo(ILookupService));

end.