// Author : Eric Kim
// Build Date : 23 Jul 2008  Last Update 02 Aug 2008
// End-Agent for Passcon Multi OS go binding with Windows, MacOS, iOS, and Android
// All rights are reserved.

package locals

import (
	"github.com/go-xorm/xorm"
)

// 0. Controller  /////////////////////////////////////////////////////////////////

type SyncController struct {
	// Ctx            *context.Context
	UpdateFieldList string
	Scb             SyncControllerBase
	Db              *xorm.Engine
}

var GSync SyncController

type SyncControllerBase struct {
	ConnString string
	OfcCode    string
}

// 1. DB /////////////////////////////////////////////////////////////////

type DbCom struct {
	StartTime  int64 `xorm:"created"`
	EndTime    int64
	UpdateTime int64 `xorm:"updated"`
	Ip         string
	Usr        int64
}

// 2. Request  /////////////////////////////////////////////////////////////////

type ListFormBalanceVars struct {
	YyyyMm     string
	SelectedId int
	StartCode  string
	EndCode    string
}

type CompanySearchVars struct {
	CompanyName string
	MainContact string
	MobileNo    string
	TelNo       string
	OrderBy     string
}

type MediaSearchVars struct {
	StartDate    string
	EndDate      string
	SlipNo       string
	MediaName    string
	FileName     string
	LinkLocation string
	Linked       string
	NickName     string
	BranchName   string
	OrderBy      string
}

type ItemSearchVars struct {
	IgroupId int
	ItemCode string
	ItemName string
	SubName  string
	OrderBy  string
}

type SlipSearchVars struct {
	StartDate   string
	EndDate     string
	SlipNo      string
	CompanyName string
	ItemCode    string
	QuerySpeed  string
	OrderBy     string
}

type SlipSearchFields struct {
	SlipDateField string
	SlipNoField   string
}

type SingleVars struct {
	QueryName string
	Id        int
}

type SetupBase struct {
	SetupCode string
	SetupJson string
}

type QueryVars struct {
	QueryName       string
	FilterName      string
	FilterValue     string
	SimpleFilter    string
	SubSimpleFilter string
	IsntPagination  bool
	TestMode        string
}

type SelectType1Vars struct {
	ListToken string
	NameValue string
	// Str            []FilterBase
	// Chk            []OptBase
	// Rng            []RngBase
	// Dec            []RngBase
	// StrItem        []FilterBase
	// ChkItem        []OptBase
	// RngItem        []RngBase
	// DecItem        []RngBase
	Having         SelectFilters
	Where          SelectFilters
	IsDownloadList bool
	Balance        string
	OrderBy        string
}

type SelectFilters struct {
	Prefix string
	Str    []FilterBase
	Chk    []OptBase
	Rng    []RngBase
	Dec    []RngBase
}

type OptBase struct {
	Opt []FilterBase
}

type FilterBase struct {
	FilterValue string
}

type RngBase struct {
	FromValue string
	ToValue   string
}

type PopupList1Vars struct {
	PopupFilterName  string
	PopupFilterValue string
	SumFilterType    string // "" : Body/Sum 동시적용 1: Sum만 적용, 7: Filter OR SumFilter 로 둘다 적용, 8: OR 로 묶어 Sum만 적용
	SumFilterName    string
	SumFilterValue   string
	SumSimpleFilter  string
}

type ListType1Vars struct {
	ListToken string

	FilterDate string
	StartDate  string
	EndDate    string

	FilterFirst string
	StartFirst  string
	EndFirst    string

	FilterSecond string
	StartSecond  string
	EndSecond    string

	FilterThird string
	StartThird  string
	EndThird    string

	FilterFourth string
	StartFourth  string
	EndFourth    string

	IsAddTotalLine   bool
	IsExcelColumn    bool
	IsShowOnlyClosed bool
	IsDownloadList   bool
	IsntPageReturn   bool
	IsTmpSqlUsed     bool
	Balance          string
	OrderBy          string

	ListFilterName   string
	ListFilterValue  string
	ListSimpleFilter string

	// SimpleFilter string

	// SumFilterType   string // "" : Body/Sum 동시적용 1: Sum만 적용, 7: Filter OR SumFilter 로 둘다 적용, 8: OR 로 묶어 Sum만 적용
	// SumFilterName   string
	// SumFilterValue  string
	// SumSimpleFilter string
}

type BodyCopyPageVars struct {
	SlipNoField    string
	SlipNo         string
	ItemCode       string
	CompanyName    string
	ShowOnlyClosed string
	Balance        string
	DaysFromToday  string
	OrderBy        string
}

type PageVars struct {
	MyFilter   string
	QueryCnt   int64
	Query      string
	Fields     string
	Asc        string
	Desc       string
	Limit      int
	Offset     int
	ReturnJson string
}

type InputFieldJson struct {
	StartDate  string
	EndDate    string
	Order      int
	Select     int
	QueryInput string
}

type Login struct {
	UserId   string
	Password string
}

// 3. Answer /////////////////////////////////////////////////////////////////
type AnswerBase struct {
	SvcSts string
	SvcMsg string
}

type ActRowCom struct {
	AnswerBase
	IdBase
}

type ActPageCom struct {
	AnswerBase
	IdPageBase
}

type BodyCopyBase struct {
	BdId int
	Qty  string
}

type IdBase struct {
	Id int
}

type IdPageBase struct {
	Page []IdBase
}

type AbangoApp struct {
	YDB *xorm.Engine
}

type InsertVars struct {
	QueryName       string
	InsertType      string
	ListToken       string
	IsTruncateTable bool
	IsBackupTable   bool
	IsBackupDb      bool
}
