package modules import ( "html" "net/http" "strings" "time" "golang-fave/engine/assets" "golang-fave/engine/basket" "golang-fave/engine/builder" "golang-fave/engine/consts" "golang-fave/engine/fetdata" "golang-fave/engine/sqlw" "golang-fave/engine/utils" "golang-fave/engine/wrapper" ) func (this *Modules) shop_GetCurrencySelectOptions(wrap *wrapper.Wrapper, id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, code FROM fave_shop_currencies ORDER BY id ASC ;`, ) if err == nil { defer rows.Close() values := make([]string, 2) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } idStr := utils.IntToStr(id) for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { selected := "" if string(values[0]) == idStr { selected = " selected" } result += `` } } } return result } func (this *Modules) shop_GetProductValuesInputs(wrap *wrapper.Wrapper, product_id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT fave_shop_filters.id, fave_shop_filters.name, fave_shop_filters_values.id, fave_shop_filters_values.name, IF(fave_shop_filter_product_values.filter_value_id > 0, 1, 0) as selected FROM fave_shop_filters_values LEFT JOIN fave_shop_filters ON fave_shop_filters.id = fave_shop_filters_values.filter_id LEFT JOIN fave_shop_filter_product_values ON fave_shop_filter_product_values.filter_value_id = fave_shop_filters_values.id AND fave_shop_filter_product_values.product_id = `+utils.IntToStr(product_id)+` LEFT JOIN ( SELECT fave_shop_filters_values.filter_id, fave_shop_filter_product_values.product_id FROM fave_shop_filter_product_values LEFT JOIN fave_shop_filters_values ON fave_shop_filters_values.id = fave_shop_filter_product_values.filter_value_id WHERE fave_shop_filter_product_values.product_id = `+utils.IntToStr(product_id)+` GROUP BY fave_shop_filters_values.filter_id ) as filter_used ON filter_used.filter_id = fave_shop_filters.id WHERE filter_used.filter_id IS NOT NULL ORDER BY fave_shop_filters.name ASC, fave_shop_filters_values.name ASC ;`, ) filter_ids := []int{} filter_names := map[int]string{} filter_values := map[int][]string{} if err == nil { defer rows.Close() values := make([]string, 5) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { filter_id := utils.StrToInt(string(values[0])) if !utils.InArrayInt(filter_ids, filter_id) { filter_ids = append(filter_ids, filter_id) } filter_names[filter_id] = html.EscapeString(string(values[1])) selected := `` if utils.StrToInt(string(values[4])) == 1 { selected = ` selected` } filter_values[filter_id] = append(filter_values[filter_id], ``) } } } for _, filter_id := range filter_ids { result += `
` + `
` + filter_names[filter_id] + `
` + `
` + `` + `` + `
` + `
` } return result } func (this *Modules) shop_GetFilterValuesInputs(wrap *wrapper.Wrapper, filter_id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, name FROM fave_shop_filters_values WHERE filter_id = ? ORDER BY name ASC ;`, filter_id, ) if err == nil { defer rows.Close() values := make([]string, 2) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result += `
` } } } return result } func (this *Modules) shop_GetAllAttributesSelectOptions(wrap *wrapper.Wrapper) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, name, filter FROM fave_shop_filters ORDER BY name ASC ;`, ) result += `` if err == nil { defer rows.Close() values := make([]string, 3) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result += `` } } } return result } func (this *Modules) shop_GetAllCurrencies(wrap *wrapper.Wrapper) map[int]string { result := map[int]string{} rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, code FROM fave_shop_currencies ORDER BY id ASC ;`, ) if err == nil { defer rows.Close() values := make([]string, 2) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result[utils.StrToInt(string(values[0]))] = html.EscapeString(string(values[1])) } } } return result } func (this *Modules) shop_GetAllProductImages(wrap *wrapper.Wrapper, product_id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, product_id, filename FROM fave_shop_product_images WHERE product_id = ? ORDER BY ord ASC ;`, product_id, ) if err == nil { defer rows.Close() values := make([]string, 3) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result += `
` } } } return result } func (this *Modules) shop_GetSubProducts(wrap *wrapper.Wrapper, id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, name FROM fave_shop_products WHERE parent_id = ? ORDER BY id DESC ;`, id, ) if err == nil { defer rows.Close() values := make([]string, 2) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result += `
` + html.EscapeString(string(values[1])) + ` ` + html.EscapeString(string(values[0])) + `
` } } } return result } func (this *Modules) shop_GetParentProduct(wrap *wrapper.Wrapper, id int) string { result := `` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT id, name FROM fave_shop_products WHERE id = ? ;`, id, ) if err == nil { defer rows.Close() values := make([]string, 2) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { result += `
` + html.EscapeString(string(values[1])) + ` ` + html.EscapeString(string(values[0])) + `
` } } } return result } func (this *Modules) shop_GetOrderStatus(status int) string { if status == 0 { return `New` } else if status == 1 { return `Confirmed` } else if status == 2 { return `In progress` } else if status == 3 { return `Canceled` } else if status == 4 { return `Completed` } return "Unknown" } func (this *Modules) RegisterModule_Shop() *Module { return this.newModule(MInfo{ Mount: "shop", Name: "Shop", Order: 2, System: false, Icon: assets.SysSvgIconShop, Sub: &[]MISub{ {Mount: "default", Name: "List of products", Show: true, Icon: assets.SysSvgIconList}, {Mount: "add", Name: "Add new product", Show: true, Icon: assets.SysSvgIconPlus}, {Mount: "modify", Name: "Modify product", Show: false}, {Sep: true, Show: true}, {Mount: "categories", Name: "List of categories", Show: true, Icon: assets.SysSvgIconList}, {Mount: "categories-add", Name: "Add new category", Show: true, Icon: assets.SysSvgIconPlus}, {Mount: "categories-modify", Name: "Modify category", Show: false}, {Sep: true, Show: true}, {Mount: "attributes", Name: "List of attributes", Show: true, Icon: assets.SysSvgIconList}, {Mount: "attributes-add", Name: "Add new attribute", Show: true, Icon: assets.SysSvgIconPlus}, {Mount: "attributes-modify", Name: "Modify attribute", Show: false}, {Sep: true, Show: true}, {Mount: "currencies", Name: "List of currencies", Show: true, Icon: assets.SysSvgIconList}, {Mount: "currencies-add", Name: "Add new currency", Show: true, Icon: assets.SysSvgIconPlus}, {Mount: "currencies-modify", Name: "Modify currency", Show: false}, {Sep: true, Show: true}, {Mount: "orders", Name: "List of orders", Show: true, Icon: assets.SysSvgIconList}, {Mount: "orders-modify", Name: "Viewing order", Show: false}, }, }, func(wrap *wrapper.Wrapper) { if len(wrap.UrlArgs) == 3 && wrap.UrlArgs[0] == "shop" && wrap.UrlArgs[1] == "category" && wrap.UrlArgs[2] != "" { // Shop category row := &utils.MySql_shop_category{} rou := &utils.MySql_user{} err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT main.id, main.user, main.name, main.alias, main.lft, main.rgt, main.depth, parent.id AS parent_id, fave_users.id, fave_users.first_name, fave_users.last_name, fave_users.email, fave_users.admin, fave_users.active FROM ( SELECT node.id, node.user, node.name, node.alias, node.lft, node.rgt, (COUNT(parent.id) - 1) AS depth FROM fave_shop_cats AS node, fave_shop_cats AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.id ORDER BY node.lft ASC ) AS main LEFT JOIN ( SELECT node.id, node.user, node.name, node.alias, node.lft, node.rgt, (COUNT(parent.id) - 0) AS depth FROM fave_shop_cats AS node, fave_shop_cats AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.id ORDER BY node.lft ASC ) AS parent ON parent.depth = main.depth AND main.lft > parent.lft AND main.rgt < parent.rgt LEFT JOIN fave_users ON fave_users.id = main.user WHERE main.id > 1 AND main.alias = ? ORDER BY main.lft ASC ;`, wrap.UrlArgs[2], ).Scan( &row.A_id, &row.A_user, &row.A_name, &row.A_alias, &row.A_lft, &row.A_rgt, &row.A_depth, &row.A_parent, &rou.A_id, &rou.A_first_name, &rou.A_last_name, &rou.A_email, &rou.A_admin, &rou.A_active, ) if err != nil && err != wrapper.ErrNoRows { // System error 500 wrap.LogCpError(&err) utils.SystemErrorPageEngine(wrap.W, err) return } else if err == wrapper.ErrNoRows { // User error 404 page wrap.RenderFrontEnd("404", fetdata.New(wrap, true, nil, nil), http.StatusNotFound) return } // Fix url if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' { http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301) return } // Render template wrap.RenderFrontEnd("shop-category", fetdata.New(wrap, false, row, rou), http.StatusOK) return } else if len(wrap.UrlArgs) >= 3 && wrap.UrlArgs[0] == "shop" && wrap.UrlArgs[1] == "basket" && (wrap.UrlArgs[2] == "info" || wrap.UrlArgs[2] == "plus" || wrap.UrlArgs[2] == "minus" || wrap.UrlArgs[2] == "remove" || wrap.UrlArgs[2] == "currency") { SBParam := basket.SBParam{ R: wrap.R, DB: wrap.DB, Host: wrap.CurrHost, Config: wrap.Config, SessionId: wrap.GetSessionId(), } if wrap.UrlArgs[2] == "info" { wrap.W.WriteHeader(http.StatusOK) wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") wrap.W.Header().Set("Content-Type", "application/json; charset=utf-8") wrap.W.Write([]byte(wrap.ShopBasket.Info(&SBParam))) wrap.S.SetString("LastBasketAction", wrap.UrlArgs[2]) return } else if wrap.UrlArgs[2] == "plus" && len(wrap.UrlArgs) == 4 && utils.IsNumeric(wrap.UrlArgs[3]) { wrap.W.WriteHeader(http.StatusOK) wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") wrap.W.Header().Set("Content-Type", "application/json; charset=utf-8") wrap.W.Write([]byte(wrap.ShopBasket.Plus(&SBParam, utils.StrToInt(wrap.UrlArgs[3])))) wrap.S.SetString("LastBasketAction", wrap.UrlArgs[2]) return } else if wrap.UrlArgs[2] == "minus" && len(wrap.UrlArgs) == 4 && utils.IsNumeric(wrap.UrlArgs[3]) { wrap.W.WriteHeader(http.StatusOK) wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") wrap.W.Header().Set("Content-Type", "application/json; charset=utf-8") wrap.W.Write([]byte(wrap.ShopBasket.Minus(&SBParam, utils.StrToInt(wrap.UrlArgs[3])))) wrap.S.SetString("LastBasketAction", wrap.UrlArgs[2]) return } else if wrap.UrlArgs[2] == "remove" && len(wrap.UrlArgs) == 4 && utils.IsNumeric(wrap.UrlArgs[3]) { wrap.W.WriteHeader(http.StatusOK) wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") wrap.W.Header().Set("Content-Type", "application/json; charset=utf-8") wrap.W.Write([]byte(wrap.ShopBasket.Remove(&SBParam, utils.StrToInt(wrap.UrlArgs[3])))) wrap.S.SetString("LastBasketAction", wrap.UrlArgs[2]) return } else if wrap.UrlArgs[2] == "currency" && len(wrap.UrlArgs) == 4 && utils.IsNumeric(wrap.UrlArgs[3]) { http.SetCookie(wrap.W, &http.Cookie{ Name: "currency", Value: wrap.UrlArgs[3], Path: "/", Expires: time.Now().Add(7 * 24 * time.Hour), HttpOnly: true, }) redirectUrl := wrap.R.Referer() if redirectUrl == "" { redirectUrl = "/" } http.Redirect(wrap.W, wrap.R, redirectUrl, 302) wrap.S.SetString("LastBasketAction", wrap.UrlArgs[2]) return } } else if len(wrap.UrlArgs) == 2 && wrap.UrlArgs[0] == "shop" && wrap.UrlArgs[1] != "" { // Shop product row := &utils.MySql_shop_product{} rou := &utils.MySql_user{} err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT fave_shop_products.id, fave_shop_products.parent_id, fave_shop_products.user, fave_shop_products.currency, fave_shop_products.price, fave_shop_products.price_old, fave_shop_products.name, fave_shop_products.alias, fave_shop_products.vendor, fave_shop_products.quantity, fave_shop_products.category, fave_shop_products.briefly, fave_shop_products.content, UNIX_TIMESTAMP(fave_shop_products.datetime) as datetime, fave_shop_products.active, fave_users.id, fave_users.first_name, fave_users.last_name, fave_users.email, fave_users.admin, fave_users.active FROM fave_shop_products LEFT JOIN fave_users ON fave_users.id = fave_shop_products.user WHERE fave_shop_products.active = 1 and fave_shop_products.alias = ? LIMIT 1;`, wrap.UrlArgs[1], ).Scan( &row.A_id, &row.A_parent, &row.A_user, &row.A_currency, &row.A_price, &row.A_price_old, &row.A_name, &row.A_alias, &row.A_vendor, &row.A_quantity, &row.A_category, &row.A_briefly, &row.A_content, &row.A_datetime, &row.A_active, &rou.A_id, &rou.A_first_name, &rou.A_last_name, &rou.A_email, &rou.A_admin, &rou.A_active, ) if err != nil && err != wrapper.ErrNoRows { // System error 500 wrap.LogCpError(&err) utils.SystemErrorPageEngine(wrap.W, err) return } else if err == wrapper.ErrNoRows { // User error 404 page wrap.RenderFrontEnd("404", fetdata.New(wrap, true, nil, nil), http.StatusNotFound) return } // Fix url if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' { http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301) return } // Render template wrap.RenderFrontEnd("shop-product", fetdata.New(wrap, false, row, rou), http.StatusOK) return } else if len(wrap.UrlArgs) == 1 && wrap.UrlArgs[0] == "shop" { // Shop // Fix url if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' { http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301) return } // Render template wrap.RenderFrontEnd("shop", fetdata.New(wrap, false, nil, nil), http.StatusOK) return } else if (*wrap.Config).Engine.MainModule == 2 { // Render template wrap.RenderFrontEnd("shop", fetdata.New(wrap, false, nil, nil), http.StatusOK) return } // User error 404 page wrap.RenderFrontEnd("404", fetdata.New(wrap, true, nil, nil), http.StatusNotFound) }, func(wrap *wrapper.Wrapper) (string, string, string) { content := "" sidebar := "" if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "List of products"}, }) // Load currencies currencies := this.shop_GetAllCurrencies(wrap) content += builder.DataTable( wrap, "fave_shop_products", "id", "DESC", &[]builder.DataTableRow{ { DBField: "id", }, { DBField: "name", NameInTable: "Product / URL", CallBack: func(values *[]string) string { name := `` + html.EscapeString((*values)[1]) + ` ` + html.EscapeString((*values)[0]) + `` alias := html.EscapeString((*values)[2]) parent := `` outofstock := `` if (*values)[7] != "" { parent = `
` + html.EscapeString((*values)[8]) + ` ` + (*values)[7] + `
` } if utils.StrToInt((*values)[10]) <= 0 { outofstock = `
Out of stock
` } return `
` + name + `
/shop/` + alias + `/
` + parent + outofstock }, }, { DBField: "alias", }, { DBField: "currency", }, { DBField: "price", NameInTable: "Price", Classes: "d-none d-md-table-cell", CallBack: func(values *[]string) string { price_old := "" price_promo := "" price_styles := "" if utils.StrToFloat64((*values)[9]) > 0 { price_old = `
` + utils.Float64ToStr(utils.StrToFloat64((*values)[9])) + `
` price_styles = ` style="color:#fb3f4c;"` } if utils.StrToFloat64((*values)[11]) > 0 { price_promo = `
` + utils.Float64ToStr(utils.StrToFloat64((*values)[11])) + `
` } return price_promo + price_old + `` + utils.Float64ToStr(utils.StrToFloat64((*values)[4])) + `` + `
` + currencies[utils.StrToInt((*values)[3])] + `
` }, }, { DBField: "datetime", DBExp: "UNIX_TIMESTAMP(`datetime`)", NameInTable: "Date / Time", Classes: "d-none d-lg-table-cell", CallBack: func(values *[]string) string { t := int64(utils.StrToInt((*values)[5])) return `
` + utils.UnixTimestampToFormat(t, "02.01.2006") + `
` + `
` + utils.UnixTimestampToFormat(t, "15:04:05") + `
` }, }, { DBField: "active", NameInTable: "Active", Classes: "d-none d-sm-table-cell", CallBack: func(values *[]string) string { return builder.CheckBox(utils.StrToInt((*values)[6])) }, }, { DBField: "parent_id", }, { DBField: "pname", DBExp: "spp.name", }, { DBField: "price_old", }, { DBField: "quantity", }, { DBField: "price_promo", }, }, func(values *[]string) string { return builder.DataTableAction(&[]builder.DataTableActionRow{ { Icon: assets.SysSvgIconView, Href: `/shop/` + (*values)[2] + `/`, Hint: "View", Target: "_blank", }, { Icon: assets.SysSvgIconEdit, Href: "/cp/" + wrap.CurrModule + "/modify/" + (*values)[0] + "/", Hint: "Edit", }, { Icon: assets.SysSvgIconRemove, Href: "javascript:fave.ActionDataTableDelete(this,'shop-delete','" + (*values)[0] + "','Are you sure want to delete product?');", Hint: "Delete", Classes: "delete", }, }) }, "/cp/"+wrap.CurrModule+"/", func() (int, error) { var count int return count, wrap.DB.QueryRow( wrap.R.Context(), "SELECT COUNT(*) FROM `fave_shop_products`;", ).Scan(&count) }, func(limit_offset int, pear_page int) (*sqlw.Rows, error) { return wrap.DB.Query( wrap.R.Context(), `SELECT fave_shop_products.id, fave_shop_products.name, fave_shop_products.alias, fave_shop_products.currency, fave_shop_products.price, UNIX_TIMESTAMP(`+"`fave_shop_products`.`datetime`"+`) AS datetime, fave_shop_products.active, fave_shop_products.parent_id, spp.name AS pname, fave_shop_products.price_old, fave_shop_products.quantity, fave_shop_products.price_promo FROM fave_shop_products LEFT JOIN fave_shop_products AS spp ON spp.id = fave_shop_products.parent_id ORDER BY fave_shop_products.id DESC LIMIT ?, ?;`, limit_offset, pear_page, ) }, true, ) } else if wrap.CurrSubModule == "categories" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"}, {Name: "List of categories"}, }) content += builder.DataTable( wrap, "fave_shop_cats", "id", "ASC", &[]builder.DataTableRow{ { DBField: "id", }, { DBField: "user", }, { DBField: "name", NameInTable: "Category", CallBack: func(values *[]string) string { depth := utils.StrToInt((*values)[4]) - 1 if depth < 0 { depth = 0 } sub := strings.Repeat("— ", depth) name := `` + sub + html.EscapeString((*values)[2]) + `` return `
` + name + `
` }, }, { DBField: "alias", }, { DBField: "depth", }, }, func(values *[]string) string { return builder.DataTableAction(&[]builder.DataTableActionRow{ { Icon: assets.SysSvgIconView, Href: `/shop/category/` + (*values)[3] + `/`, Hint: "View", Target: "_blank", }, { Icon: assets.SysSvgIconEdit, Href: "/cp/" + wrap.CurrModule + "/categories-modify/" + (*values)[0] + "/", Hint: "Edit", }, { Icon: assets.SysSvgIconRemove, Href: "javascript:fave.ActionDataTableDelete(this,'shop-categories-delete','" + (*values)[0] + "','Are you sure want to delete category?');", Hint: "Delete", Classes: "delete", }, }) }, "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/", nil, func(limit_offset int, pear_page int) (*sqlw.Rows, error) { return wrap.DB.Query( wrap.R.Context(), `SELECT node.id, node.user, node.name, node.alias, (COUNT(parent.id) - 1) AS depth FROM fave_shop_cats AS node, fave_shop_cats AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.id > 1 GROUP BY node.id ORDER BY node.lft ASC ;`, ) }, false, ) } else if wrap.CurrSubModule == "attributes" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"}, {Name: "List of attributes"}, }) content += builder.DataTable( wrap, "fave_shop_filters", "id", "DESC", &[]builder.DataTableRow{ { DBField: "id", }, { DBField: "name", NameInTable: "Name", CallBack: func(values *[]string) string { name := `` + html.EscapeString((*values)[1]) + `` return `
` + name + `
` + html.EscapeString((*values)[2]) + `
` }, }, { DBField: "filter", }, }, func(values *[]string) string { return builder.DataTableAction(&[]builder.DataTableActionRow{ { Icon: assets.SysSvgIconEdit, Href: "/cp/" + wrap.CurrModule + "/attributes-modify/" + (*values)[0] + "/", Hint: "Edit", }, { Icon: assets.SysSvgIconRemove, Href: "javascript:fave.ActionDataTableDelete(this,'shop-attributes-delete','" + (*values)[0] + "','Are you sure want to delete attribute?');", Hint: "Delete", Classes: "delete", }, }) }, "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/", nil, nil, true, ) } else if wrap.CurrSubModule == "currencies" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"}, {Name: "List of currencies"}, }) content += builder.DataTable( wrap, "fave_shop_currencies", "id", "DESC", &[]builder.DataTableRow{ { DBField: "id", }, { DBField: "name", NameInTable: "Name", CallBack: func(values *[]string) string { name := `` + html.EscapeString((*values)[1]) + ` (` + (*values)[3] + `, ` + (*values)[4] + `)` return `
` + name + `
` }, }, { DBField: "coefficient", NameInTable: "Coefficient", Classes: "d-none d-md-table-cell", CallBack: func(values *[]string) string { return utils.Float64ToStrF(utils.StrToFloat64((*values)[2]), "%.4f") }, }, { DBField: "code", }, { DBField: "symbol", }, }, func(values *[]string) string { return builder.DataTableAction(&[]builder.DataTableActionRow{ { Icon: assets.SysSvgIconEdit, Href: "/cp/" + wrap.CurrModule + "/currencies-modify/" + (*values)[0] + "/", Hint: "Edit", }, { Icon: assets.SysSvgIconRemove, Href: "javascript:fave.ActionDataTableDelete(this,'shop-currencies-delete','" + (*values)[0] + "','Are you sure want to delete currency?');", Hint: "Delete", Classes: "delete", }, }) }, "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/", nil, nil, true, ) } else if wrap.CurrSubModule == "orders" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Orders", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"}, {Name: "List of orders"}, }) content += builder.DataTable( wrap, "fave_shop_orders", "id", "DESC", &[]builder.DataTableRow{ { DBField: "id", NameInTable: "Order #", Classes: "d-none d-lg-table-cell", }, { DBField: "client_phone", }, { DBField: "update_datetime", }, { DBField: "currency_id", }, { DBField: "currency_name", }, { DBField: "currency_coefficient", }, { DBField: "currency_code", }, { DBField: "currency_symbol", }, { DBField: "client_last_name", NameInTable: "Client / Contact", CallBack: func(values *[]string) string { link := "/cp/" + wrap.CurrModule + "/orders-modify/" + (*values)[0] + "/" last_name := html.EscapeString((*values)[8]) first_name := html.EscapeString((*values)[9]) middle_name := html.EscapeString((*values)[10]) phone := html.EscapeString((*values)[1]) email := html.EscapeString((*values)[12]) order_id := `#` + (*values)[0] + `. ` name := "" if last_name != "" { name += " " + last_name } if first_name != "" { name += " " + first_name } if middle_name != "" { name += " " + middle_name } name = `` + order_id + utils.Trim(name) + `` contact := "" if email != "" { contact += " " + email } if phone != "" { contact += " (" + phone + ")" } contact = `` + utils.Trim(contact) + `` return `
` + name + `
` + contact + `
` }, }, { DBField: "client_first_name", }, { DBField: "client_middle_name", }, { DBField: "create_datetime", DBExp: "UNIX_TIMESTAMP(`create_datetime`)", NameInTable: "Date / Time", Classes: "d-none d-lg-table-cell", CallBack: func(values *[]string) string { t := int64(utils.StrToInt((*values)[11])) return `
` + utils.UnixTimestampToFormat(t, "02.01.2006") + `
` + `
` + utils.UnixTimestampToFormat(t, "15:04:05") + `
` }, }, { DBField: "client_email", NameInTable: "Status / Total", CallBack: func(values *[]string) string { status := this.shop_GetOrderStatus(utils.StrToInt((*values)[15])) total := utils.Float64ToStr(utils.StrToFloat64((*values)[16])) + " " + html.EscapeString((*values)[6]) return `
` + status + `
` + total + `
` }, }, { DBField: "client_delivery_comment", }, { DBField: "client_order_comment", }, { DBField: "status", }, { DBField: "total", }, }, nil, "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/", nil, func(limit_offset int, pear_page int) (*sqlw.Rows, error) { return wrap.DB.Query( wrap.R.Context(), `SELECT fave_shop_orders.id, fave_shop_orders.client_phone, fave_shop_orders.update_datetime, fave_shop_orders.currency_id, fave_shop_orders.currency_name, fave_shop_orders.currency_coefficient, fave_shop_orders.currency_code, fave_shop_orders.currency_symbol, fave_shop_orders.client_last_name, fave_shop_orders.client_first_name, fave_shop_orders.client_middle_name, UNIX_TIMESTAMP(fave_shop_orders.create_datetime) as create_datetime, fave_shop_orders.client_email, fave_shop_orders.client_delivery_comment, fave_shop_orders.client_order_comment, fave_shop_orders.status, shop_order_total.total FROM fave_shop_orders LEFT JOIN ( SELECT order_id, SUM(price * quantity) as total FROM fave_shop_order_products GROUP BY order_id ) as shop_order_total ON shop_order_total.order_id = fave_shop_orders.id ORDER BY fave_shop_orders.status ASC, fave_shop_orders.id DESC LIMIT ?, ?;`, limit_offset, pear_page, ) }, true, ) } else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" { if wrap.CurrSubModule == "add" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Add new product"}, }) } else { if len(wrap.UrlArgs) >= 3 && utils.IsNumeric(wrap.UrlArgs[2]) { content += `
` + assets.SysSvgIconCopy + `
` content += `
` + assets.SysSvgIconPlus + `
` } content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Modify product"}, }) } data := utils.MySql_shop_product{ A_id: 0, A_user: 0, A_currency: 0, A_price: 0, A_price_old: 0, A_gname: "", A_name: "", A_alias: "", A_vendor: "", A_quantity: 0, A_category: 0, A_briefly: "", A_content: "", A_datetime: 0, A_active: 0, A_custom1: "", A_custom2: "", } if wrap.CurrSubModule == "modify" { if len(wrap.UrlArgs) != 3 { return "", "", "" } if !utils.IsNumeric(wrap.UrlArgs[2]) { return "", "", "" } err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT id, parent_id, user, currency, price, price_old, price_promo, gname, name, alias, vendor, quantity, category, briefly, content, active, custom1, custom2 FROM fave_shop_products WHERE id = ? LIMIT 1;`, utils.StrToInt(wrap.UrlArgs[2]), ).Scan( &data.A_id, &data.A_parent, &data.A_user, &data.A_currency, &data.A_price, &data.A_price_old, &data.A_price_promo, &data.A_gname, &data.A_name, &data.A_alias, &data.A_vendor, &data.A_quantity, &data.A_category, &data.A_briefly, &data.A_content, &data.A_active, &data.A_custom1, &data.A_custom2, ) if *wrap.LogCpError(&err) != nil { return "", "", "" } } if data.A_parent_id() > 0 { content += `` } // All product current categories var selids []int if data.A_id > 0 { rows, err := wrap.DB.Query(wrap.R.Context(), "SELECT category_id FROM fave_shop_cat_product_rel WHERE product_id = ?;", data.A_id) if err == nil { defer rows.Close() values := make([]int, 1) scan := make([]interface{}, len(values)) for i := range values { scan[i] = &values[i] } for rows.Next() { err = rows.Scan(scan...) if *wrap.LogCpError(&err) == nil { selids = append(selids, int(values[0])) } } } } // Sub products sub_products := `` if data.A_id >= 1 && data.A_parent_id() <= 0 { sub_products = this.shop_GetSubProducts(wrap, data.A_id) } btn_caption := "Add" if wrap.CurrSubModule == "modify" { btn_caption = "Save" } content += builder.DataForm(wrap, []builder.DataFormField{ { Kind: builder.DFKHidden, Name: "action", Value: "shop-modify", }, { Kind: builder.DFKHidden, Name: "id", Value: utils.IntToStr(data.A_id), }, { Kind: builder.DFKText, CallBack: func(field *builder.DataFormField) string { if data.A_id >= 1 && data.A_parent_id() <= 0 { return `
` + `
` + `
` + `` + `
` + `
` + `
` + sub_products + `` + `
` + `
` + `
` + `
` } return "" }, }, { Kind: builder.DFKText, CallBack: func(field *builder.DataFormField) string { if data.A_id >= 1 && data.A_parent_id() != 0 { return `
` + `
` + `
` + `` + `
` + `
` + `
` + this.shop_GetParentProduct(wrap, data.A_parent_id()) + `
` + `
` + `
` + `
` } return "" }, }, { Kind: builder.DFKText, CallBack: func(field *builder.DataFormField) string { if data.A_id >= 1 && data.A_parent_id() <= 0 && sub_products != "" { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` } return "" }, }, { Kind: builder.DFKText, Caption: "Product name", Name: "name", Value: data.A_name, Required: true, Min: "1", Max: "255", }, { Kind: builder.DFKText, Caption: "Product price", Name: "price", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Old/Promo price", Name: "price_old", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Product alias", Name: "alias", Value: data.A_alias, Hint: "Example: mobile-phone", Max: "255", }, { Kind: builder.DFKText, Caption: "Vendor/Count", Name: "vendor", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Category", Name: "category", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Categories", Name: "cats", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Attributes", Name: "", Value: "", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + this.shop_GetProductValuesInputs(wrap, data.A_id) + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKTextArea, Caption: "Briefly", Name: "briefly", Value: data.A_briefly, Classes: "briefly wysiwyg", }, { Kind: builder.DFKTextArea, Caption: "Product content", Name: "content", Value: data.A_content, Classes: "wysiwyg", }, { Kind: builder.DFKText, Caption: "Product images", Name: "", Value: "", CallBack: func(field *builder.DataFormField) string { if data.A_id == 0 { return `` } return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + this.shop_GetAllProductImages(wrap, data.A_id) + `
` + `
` + `
Uploading...
` + `` + `
` + `
` + `
` + `
` + `
` + `` }, }, { Kind: builder.DFKText, Caption: "Custom field 1", Name: "", Value: "", CallBack: func(field *builder.DataFormField) string { if (*wrap.Config).Shop.CustomFields.Field1.Enabled <= 0 { return `` } return `
` }, }, { Kind: builder.DFKText, Caption: "Custom field 2", Name: "", Value: "", CallBack: func(field *builder.DataFormField) string { if (*wrap.Config).Shop.CustomFields.Field2.Enabled <= 0 { return `` } return `
` }, }, { Kind: builder.DFKCheckBox, Caption: "Active", Name: "active", Value: utils.IntToStr(data.A_active), }, { Kind: builder.DFKSubmit, Value: btn_caption, Target: "add-edit-button", }, }) if wrap.CurrSubModule == "add" { sidebar += `` } else { sidebar += `` } } else if wrap.CurrSubModule == "categories-add" || wrap.CurrSubModule == "categories-modify" { if wrap.CurrSubModule == "categories-add" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/categories/"}, {Name: "Add new category"}, }) } else { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/categories/"}, {Name: "Modify category"}, }) } data := utils.MySql_shop_category{ A_id: 0, A_user: 0, A_name: "", A_alias: "", A_lft: 0, A_rgt: 0, } if wrap.CurrSubModule == "categories-modify" { if len(wrap.UrlArgs) != 3 { return "", "", "" } if !utils.IsNumeric(wrap.UrlArgs[2]) { return "", "", "" } err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT id, user, name, alias, lft, rgt FROM fave_shop_cats WHERE id = ? LIMIT 1;`, utils.StrToInt(wrap.UrlArgs[2]), ).Scan( &data.A_id, &data.A_user, &data.A_name, &data.A_alias, &data.A_lft, &data.A_rgt, ) if *wrap.LogCpError(&err) != nil { return "", "", "" } } btn_caption := "Add" if wrap.CurrSubModule == "categories-modify" { btn_caption = "Save" } parentId := 0 if wrap.CurrSubModule == "categories-modify" { parentId = this.shop_GetCategoryParentId(wrap, data.A_id) } content += builder.DataForm(wrap, []builder.DataFormField{ { Kind: builder.DFKHidden, Name: "action", Value: "shop-categories-modify", }, { Kind: builder.DFKHidden, Name: "id", Value: utils.IntToStr(data.A_id), }, { Kind: builder.DFKText, Caption: "Parent", Name: "parent", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Name", Name: "name", Value: data.A_name, Required: true, Min: "1", Max: "255", }, { Kind: builder.DFKText, Caption: "Alias", Name: "alias", Value: data.A_alias, Hint: "Example: popular-products", Max: "255", }, { Kind: builder.DFKSubmit, Value: btn_caption, Target: "add-edit-button", }, }) if wrap.CurrSubModule == "categories-add" { sidebar += `` } else { sidebar += `` } } else if wrap.CurrSubModule == "attributes-add" || wrap.CurrSubModule == "attributes-modify" { if wrap.CurrSubModule == "attributes-add" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/attributes/"}, {Name: "Add new attribute"}, }) } else { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/attributes/"}, {Name: "Modify attribute"}, }) } data := utils.MySql_shop_filter{ A_id: 0, A_name: "", A_filter: "", } if wrap.CurrSubModule == "attributes-modify" { if len(wrap.UrlArgs) != 3 { return "", "", "" } if !utils.IsNumeric(wrap.UrlArgs[2]) { return "", "", "" } err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT id, name, filter FROM fave_shop_filters WHERE id = ? LIMIT 1;`, utils.StrToInt(wrap.UrlArgs[2]), ).Scan( &data.A_id, &data.A_name, &data.A_filter, ) if *wrap.LogCpError(&err) != nil { return "", "", "" } } btn_caption := "Add" if wrap.CurrSubModule == "attributes-modify" { btn_caption = "Save" } content += builder.DataForm(wrap, []builder.DataFormField{ { Kind: builder.DFKHidden, Name: "action", Value: "shop-attributes-modify", }, { Kind: builder.DFKHidden, Name: "id", Value: utils.IntToStr(data.A_id), }, { Kind: builder.DFKText, Caption: "Attribute name", Name: "name", Value: data.A_name, Required: true, Min: "1", Max: "255", }, { Kind: builder.DFKText, Caption: "Attribute in filter", Name: "filter", Value: data.A_filter, Required: true, Min: "1", Max: "255", }, { Kind: builder.DFKText, Caption: "Attribute values", Name: "", Value: "", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + this.shop_GetFilterValuesInputs(wrap, data.A_id) + `
` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKSubmit, Value: btn_caption, Target: "add-edit-button", }, }) if wrap.CurrSubModule == "attributes-add" { sidebar += `` } else { sidebar += `` } } else if wrap.CurrSubModule == "currencies-add" || wrap.CurrSubModule == "currencies-modify" { if wrap.CurrSubModule == "currencies-add" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/currencies/"}, {Name: "Add new currency"}, }) } else { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/currencies/"}, {Name: "Modify currency"}, }) } data := utils.MySql_shop_currency{ A_id: 0, A_name: "", A_coefficient: 0, A_code: "", A_symbol: "", } if wrap.CurrSubModule == "currencies-modify" { if len(wrap.UrlArgs) != 3 { return "", "", "" } if !utils.IsNumeric(wrap.UrlArgs[2]) { return "", "", "" } err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT id, name, coefficient, code, symbol FROM fave_shop_currencies WHERE id = ? LIMIT 1;`, utils.StrToInt(wrap.UrlArgs[2]), ).Scan( &data.A_id, &data.A_name, &data.A_coefficient, &data.A_code, &data.A_symbol, ) if *wrap.LogCpError(&err) != nil { return "", "", "" } } btn_caption := "Add" if wrap.CurrSubModule == "currencies-modify" { btn_caption = "Save" } content += builder.DataForm(wrap, []builder.DataFormField{ { Kind: builder.DFKHidden, Name: "action", Value: "shop-currencies-modify", }, { Kind: builder.DFKHidden, Name: "id", Value: utils.IntToStr(data.A_id), }, { Kind: builder.DFKText, Caption: "Currency name", Name: "name", Value: data.A_name, Required: true, Min: "1", Max: "255", }, { Kind: builder.DFKText, Caption: "Currency coefficient", Name: "coefficient", Value: "0", CallBack: func(field *builder.DataFormField) string { return `
` + `
` + `
` + `` + `
` + `
` + `
` + `
` + `
` + `
` }, }, { Kind: builder.DFKText, Caption: "Currency code", Name: "code", Value: data.A_code, Required: true, Min: "1", Max: "10", }, { Kind: builder.DFKText, Caption: "Currency symbol", Name: "symbol", Value: data.A_symbol, Required: true, Min: "1", Max: "5", }, { Kind: builder.DFKSubmit, Value: btn_caption, Target: "add-edit-button", }, }) if wrap.CurrSubModule == "currencies-add" { sidebar += `` } else { sidebar += `` } } else if wrap.CurrSubModule == "orders-modify" { content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{ {Name: "Orders", Link: "/cp/" + wrap.CurrModule + "/orders/"}, {Name: "Modify order"}, }) if len(wrap.UrlArgs) != 3 { return "", "", "" } if !utils.IsNumeric(wrap.UrlArgs[2]) { return "", "", "" } var curr_order_id int var curr_order_client_phone string var curr_order_update_datetime string var curr_order_currency_id int var curr_order_currency_name string var curr_order_currency_coefficient float64 var curr_order_currency_code string var curr_order_currency_symbol string var curr_order_client_last_name string var curr_order_client_first_name string var curr_order_client_middle_name string var curr_order_create_datetime int var curr_order_client_email string var curr_order_client_delivery_comment string var curr_order_client_order_comment string var curr_order_status int var curr_order_total float64 err := wrap.DB.QueryRow( wrap.R.Context(), `SELECT fave_shop_orders.id, fave_shop_orders.client_phone, fave_shop_orders.update_datetime, fave_shop_orders.currency_id, fave_shop_orders.currency_name, fave_shop_orders.currency_coefficient, fave_shop_orders.currency_code, fave_shop_orders.currency_symbol, fave_shop_orders.client_last_name, fave_shop_orders.client_first_name, fave_shop_orders.client_middle_name, UNIX_TIMESTAMP(fave_shop_orders.create_datetime) as create_datetime, fave_shop_orders.client_email, fave_shop_orders.client_delivery_comment, fave_shop_orders.client_order_comment, fave_shop_orders.status, shop_order_total.total FROM fave_shop_orders LEFT JOIN ( SELECT order_id, SUM(price * quantity) as total FROM fave_shop_order_products GROUP BY order_id ) as shop_order_total ON shop_order_total.order_id = fave_shop_orders.id WHERE fave_shop_orders.id = ? LIMIT 1;`, utils.StrToInt(wrap.UrlArgs[2]), ).Scan( &curr_order_id, &curr_order_client_phone, &curr_order_update_datetime, &curr_order_currency_id, &curr_order_currency_name, &curr_order_currency_coefficient, &curr_order_currency_code, &curr_order_currency_symbol, &curr_order_client_last_name, &curr_order_client_first_name, &curr_order_client_middle_name, &curr_order_create_datetime, &curr_order_client_email, &curr_order_client_delivery_comment, &curr_order_client_order_comment, &curr_order_status, &curr_order_total, ) if *wrap.LogCpError(&err) != nil { return "", "", "" } last_name := html.EscapeString(curr_order_client_last_name) first_name := html.EscapeString(curr_order_client_first_name) middle_name := html.EscapeString(curr_order_client_middle_name) phone := html.EscapeString(curr_order_client_phone) email := html.EscapeString(curr_order_client_email) order_id := `#` + utils.IntToStr(curr_order_id) + `. ` name := "" if last_name != "" { name += " " + last_name } if first_name != "" { name += " " + first_name } if middle_name != "" { name += " " + middle_name } name = order_id + utils.Trim(name) contact := "" if email != "" { contact += " " + email } if phone != "" { contact += " (" + phone + ")" } contact = utils.Trim(contact) content += `
Order # Client / Contact Date / Time Status / Total
` + utils.IntToStr(curr_order_id) + `
` + name + `
` + contact + `
` + utils.UnixTimestampToFormat(int64(curr_order_create_datetime), "02.01.2006") + `
` + utils.UnixTimestampToFormat(int64(curr_order_create_datetime), "15:04:05") + `
` + this.shop_GetOrderStatus(curr_order_status) + `
` + utils.Float64ToStr(curr_order_total) + " " + html.EscapeString(curr_order_currency_code) + `
` content += ` ` rows, err := wrap.DB.Query( wrap.R.Context(), `SELECT fave_shop_order_products.product_id, fave_shop_products.name, fave_shop_products.alias, fave_shop_order_products.price, fave_shop_order_products.quantity, (fave_shop_order_products.price * fave_shop_order_products.quantity) as total FROM fave_shop_order_products LEFT JOIN fave_shop_products ON fave_shop_products.id = fave_shop_order_products.product_id WHERE fave_shop_order_products.order_id = ? ;`, curr_order_id, ) if err == nil { defer rows.Close() var curr_product_id int var curr_product_name string var curr_product_alias string var curr_product_price float64 var curr_product_quantity int var curr_product_total float64 for rows.Next() { err = rows.Scan( &curr_product_id, &curr_product_name, &curr_product_alias, &curr_product_price, &curr_product_quantity, &curr_product_total, ) if *wrap.LogCpError(&err) == nil { content += `` } } } content += `
Product Price Quantity Total
` + utils.Float64ToStr(curr_product_price) + `
` + html.EscapeString(curr_order_currency_code) + `
` + utils.IntToStr(curr_product_quantity) + `
` + utils.Float64ToStr(curr_product_total) + `
` + html.EscapeString(curr_order_currency_code) + `
` // Delivery content += `
Delivery
` // Comment content += `
Comment
` } return this.getSidebarModules(wrap), content, sidebar }) }