Ejemplo n.º 1
0
Archivo: jx.go Proyecto: tangseng/gtt
func (this *JXController) Score() {
	this.info = &map[string]string{
		"admin": "没有权限设置绩效分数",
		"err":   "操作失败",
		"ok":    "操作成功",
	}
	if !this.IsAdmin() {
		this.error("admin")
		return
	}
	id, _ := this.GetInt("id")
	score, _ := this.GetInt8("score")
	dayOption := models.NewDayOption()
	dayWork, err := dayOption.ReadDayWork(id)
	if err != nil {
		this.error("err")
		return
	}
	dayWork.Score = score
	_, err = dayOption.UpdateDayWork(dayWork, "score")
	if err != nil {
		this.error("err")
		return
	}
	this.success("ok")
}
Ejemplo n.º 2
0
Archivo: day.go Proyecto: tangseng/gtt
func (this *DayController) Add() {
	this.info = &map[string]string{
		"post": "所有信息必须填写",
		"day":  "添加今天的工作内容失败(day)",
		"work": "添加今天的工作内容失败(work)",
		"plan": "没有这个工作计划",
		"err":  "操作失败",
		"ok":   "操作成功",
	}
	this.prefixInit()
	content := this.GetString("content")
	startTime, _ := this.GetInt("startTime")
	endTime, _ := this.GetInt("endTime")
	status, _ := this.GetInt8("status")
	planId, _ := this.GetInt("planId")
	appId, _ := this.GetInt("appId")
	if len(content) == 0 || startTime == 0 || endTime == 0 || status == 0 {
		this.error("post")
		return
	}
	if planId != 0 {
		planOption := models.NewPlanOption()
		plan, err := planOption.Read(planId)
		if err != nil {
			this.error("plan")
			return
		}
		plan.Status = status
		if plan.Status == 100 {
			plan.RealTime = this.Today.Unix()
		}
		planOption.Update(plan)
	}
	dayOption := models.NewDayOption()
	day, err := dayOption.ReadDay(this.user.Id, this.Y, this.M, this.D)
	if err != nil {
		day = models.NewDay(this.user.Id, this.Y, this.M, this.D)
		_, err = dayOption.Insert(day)
		if err != nil {
			this.error("day")
			return
		}
	}
	workid, err := dayOption.InsertWork(models.NewDayWork(content, startTime, endTime, status, day, planId))
	if err != nil {
		this.error("work")
		return
	}
	if appId > 0 {
		models.NewAppOption().Insert(models.NewApp(this.user.Id, appId, content))
	}
	this.success(map[string]interface{}{"id": workid})
}
Ejemplo n.º 3
0
Archivo: day.go Proyecto: tangseng/gtt
func (this *DayController) Delete() {
	if !this.prefixCheck() {
		return
	}
	id, _ := this.GetInt("id")
	err := models.NewDayOption().DeleteDayWork(id)
	if err != nil {
		this.error("err")
		return
	}
	this.success("ok")
}
Ejemplo n.º 4
0
Archivo: day.go Proyecto: tangseng/gtt
func (this *DayController) Search() {
	if !this.prefixCheck() {
		return
	}
	id, _ := this.GetInt("id")
	dayWork, err := models.NewDayOption().ReadDayWork(id)
	if err != nil {
		this.error("id")
		return
	}
	this.success(dayWork)
}
Ejemplo n.º 5
0
Archivo: jx.go Proyecto: tangseng/gtt
func (this *JXController) XXs() {
	this.prefixInit()
	cy, cm, cd := this.Y, this.M, this.D
	if y, _ := this.GetInt("y"); y > 0 {
		cy = y
	}
	if m, _ := this.GetInt("m"); m > 0 {
		cm = m
	}
	if d, _ := this.GetInt("d"); d > 0 {
		cd = d
	}
	_, ids := this.allPersons(true)
	days := models.NewDayOption().ReadDayByUids(ids, cy, cm, cd)
	this.success(days)
}
Ejemplo n.º 6
0
Archivo: jx.go Proyecto: tangseng/gtt
func (this *JXController) GetDay() {
	this.info = &map[string]string{
		"post": "所有信息必须填写",
		"end":  "结束时间不能早于开始时间,并且不能早于今天",
	}
	y, _ := this.GetInt("y")
	m, _ := this.GetInt("m")
	d, _ := this.GetInt("d")
	uid := this.user.Id
	admin := this.IsAdmin()
	if admin {
		uid, _ = this.GetInt("uid")
	}
	day, err := models.NewDayOption().ReadDay(uid, y, m, d)
	works := make([]*models.DayWork, 0)
	if err == nil && len(day.Works) > 0 {
		works = day.Works
	}
	this.success(works)
}
Ejemplo n.º 7
0
Archivo: day.go Proyecto: tangseng/gtt
func (this *DayController) Get() {
	this.prefixInit()
	dayOption := models.NewDayOption()
	day, _ := dayOption.ReadDay(this.user.Id, this.Y, this.M, this.D)
	this.Data["PageDay"] = true
	this.Data["Day"] = day
	this.Data["Y"] = this.Y
	this.Data["M"] = this.M
	this.Data["D"] = this.D
	js := []string{"app/app", "app/directives/tip", "app/directives/date", "app/services/time", "app/controllers/day/dayCtrl", "app/controllers/day/planCtrl"}
	if needApp, ok := this.Data["NeedApp"].(bool); ok && needApp {
		js = append(js, "app/controllers/day/appCtrl")
	}
	admin := this.IsAdmin()
	if admin {
		js = append(js, "app/controllers/day/dayAdminCtrl")
	}
	this.Data["Script"] = js
	this.Data["Admin"] = admin
	this.TplNames = "day.html"
}
Ejemplo n.º 8
0
Archivo: day.go Proyecto: tangseng/gtt
func (this *DayController) Update() {
	if !this.prefixCheck() {
		return
	}
	content := this.GetString("content")
	startTime, _ := this.GetInt("startTime")
	endTime, _ := this.GetInt("endTime")
	status, _ := this.GetInt8("status")
	if len(content) == 0 || startTime == 0 || endTime == 0 || status == 0 {
		this.error("post")
		return
	}

	date, _ := this.GetInt64("date")
	timer := time.Unix(date, 0)
	y := timer.Year()
	m := int(timer.Month())
	d := timer.Day()

	dayOption := models.NewDayOption()
	id, _ := this.GetInt("id")
	dayWork, err := dayOption.ReadDayWork(id)
	if err != nil {
		this.error("id")
		return
	}
	planId := dayWork.PlanId
	if planId != 0 {
		planOption := models.NewPlanOption()
		plan, err := planOption.Read(planId)
		if err == nil && plan != nil {
			plan.Status = status
			if plan.Status == 100 {
				plan.RealTime = this.Today.Unix()
			}
			planOption.Update(plan)
		}
	}
	oldDay, _ := dayOption.ReadDayById(dayWork.Day.Id, false)
	day, err := dayOption.ReadDay(oldDay.Uid, y, m, d)
	if err != nil {
		day = models.NewDay(oldDay.Uid, y, m, d)
		_, err = dayOption.Insert(day)
		if err != nil {
			this.error("day")
			return
		}
	}
	dayWork.Content = content
	dayWork.StartTime = startTime
	dayWork.EndTime = endTime
	dayWork.Status = status
	dayWork.Day = day
	dayWork.Time = uint64(date)
	_, err = dayOption.UpdateDayWork(dayWork, "")
	if err != nil {
		this.error("err")
		return
	}
	this.success("ok")
}
Ejemplo n.º 9
0
Archivo: plan.go Proyecto: tangseng/gtt
func (this *PlanController) GetPlan() {
	planId, _ := this.GetInt("id")
	dayWorks := models.NewDayOption().ReadByPlanId(planId)
	this.success(dayWorks)
}