Beispiel #1
0
func (c *Controller) CfCatalog() (string, error) {

	var err error
	log.Debug("CfCatalog")

	categoryId := utils.Int64ToStr(int64(utils.StrToFloat64(c.Parameters["category_id"])))
	log.Debug("categoryId", categoryId)
	var curCategory string
	addSql := ""
	if categoryId != "0" {
		addSql = `AND category_id = ` + categoryId
		curCategory = c.Lang["cf_category_"+categoryId]
	}

	cfUrl := ""

	projects := make(map[string]map[string]string)
	cfProjects, err := c.GetAll(`
			SELECT cf_projects.id, lang_id, blurb_img, country, city, currency_id, end_time, amount
			FROM cf_projects
			LEFT JOIN cf_projects_data ON  cf_projects_data.project_id = cf_projects.id
			WHERE del_block_id = 0 AND
						 end_time > ? AND
						 lang_id = ?
						`+addSql+`
			ORDER BY funders DESC
			LIMIT 100
			`, 100, utils.Time(), c.LangInt)
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	for _, data := range cfProjects {
		CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), cfUrl)
		if err != nil {
			return "", utils.ErrInfo(err)
		}
		for k, v := range CfProjectData {
			data[k] = v
		}
		projects[data["id"]] = data
	}

	cfCategory := utils.MakeCfCategories(c.Lang)

	TemplateStr, err := makeTemplate("cf_catalog", "cfCatalog", &cfCatalogPage{
		Lang:         c.Lang,
		CfCategory:   cfCategory,
		CurrencyList: c.CurrencyList,
		CurCategory:  curCategory,
		Projects:     projects,
		UserId:       c.SessUserId,
		CategoryId:   categoryId,
		CfUrl:        cfUrl})
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return TemplateStr, nil
}
Beispiel #2
0
func (c *Controller) NewCfProject() (string, error) {

	var err error

	txType := "NewCfProject"
	txTypeId := utils.TypeInt(txType)
	timeNow := utils.Time()

	cfCategory := utils.MakeCfCategories(c.Lang)

	latitude := "39.94887"
	longitude := "-75.15005"
	city := "Pennsylvania, USA"
	endTime := utils.Time() + 3600*24*7 + 3600

	var countDaysArr []int
	for i := 7; i < 90; i++ {
		countDaysArr = append(countDaysArr, i)
	}

	TemplateStr, err := makeTemplate("new_cf_project", "newCfProject", &NewCfProjectPage{
		Alert:        c.Alert,
		Lang:         c.Lang,
		CountSignArr: c.CountSignArr,
		ShowSignData: c.ShowSignData,
		UserId:       c.SessUserId,
		TimeNow:      timeNow,
		TxType:       txType,
		TxTypeId:     txTypeId,
		Latitude:     latitude,
		Longitude:    longitude,
		EndTime:      endTime,
		City:         city,
		CfCategory:   cfCategory,
		CountDaysArr: countDaysArr,
		CurrencyList: c.CurrencyList})
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return TemplateStr, nil
}
func (c *Controller) CfProjectChangeCategory() (string, error) {

	var err error

	txType := "CfProjectData"
	txTypeId := utils.TypeInt(txType)
	timeNow := utils.Time()

	projectId := int64(utils.StrToFloat64(c.Parameters["project_id"]))
	data, err := c.OneRow("SELECT category_id, project_currency_name FROM cf_projects WHERE id= ?", projectId).String()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	categoryId := data["category_id"]
	projectCurrencyName := data["project_currency_name"]

	cfCategory := utils.MakeCfCategories(c.Lang)

	TemplateStr, err := makeTemplate("cf_project_change_category", "cfProjectChangeCategory", &cfProjectChangeCategoryPage{
		Alert:               c.Alert,
		Lang:                c.Lang,
		CountSignArr:        c.CountSignArr,
		ShowSignData:        c.ShowSignData,
		SignData:            fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, categoryId),
		UserId:              c.SessUserId,
		TimeNow:             timeNow,
		TxType:              txType,
		TxTypeId:            txTypeId,
		ProjectId:           projectId,
		CategoryId:          categoryId,
		CfCategory:          cfCategory,
		ProjectCurrencyName: projectCurrencyName})
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return TemplateStr, nil
}