Example #1
0
func (cp *ComplaintCreator) CreateComplian(mapComplain map[string]interface{}, user *models.User) (complainId, jobId uint, err error) {
	defer func() {
		if err != nil {
			utils.GetLog().Error("services.complain.Create : error : %s, ", err.Error())
		} else {
			utils.GetLog().Debug("services.complain.Create : debug : mapComplain=%s", utils.Sdump(mapComplain))
		}
	}()

	var complian models.JobComplaint
	pid, _ := mapComplain["JobId"].(string)

	filter := make(map[string]interface{})
	filter["id"] = pid

	var job *models.Job
	job, err = GetOneJob(filter)
	complian.Job = &models.Job{Id: job.Id}
	complian.Project = &models.Project{Id: job.Project.Id}

	if mapComplain["employee_id"] != nil {
		employId, _ := strconv.Atoi(mapComplain["employee_id"].(string))
		complian.Employee = &models.User{Id: uint(employId)}
	}
	complian.Complain = mapComplain["Complain"].(string)
	complian.Source = mapComplain["source"].(string)
	complian.Type = mapComplain["Type"].(string)
	response, _ := mapComplain["response"].(int)
	complian.Response = uint(response)
	if mapComplain["editstatus"] != nil {
		editStatus, _ := strconv.Atoi(mapComplain["editstatus"].(string))
		complian.EditStatus = uint(editStatus)
	}

	complian.User = user

	//cp.compliant = complian
	var insertId int64
	insertId, err = models.GetDB().Insert(&complian)
	if err != nil {
		utils.GetLog().Debug("services.complian.Create : debug : job=%s", utils.Sdump(complian))
		return
	}
	complainId = uint(insertId)
	jobId = uint(job.Id)
	return

}
Example #2
0
func CreateComlian(mapComplain map[string]interface{}, user *models.User) (complainId uint, err error) {
	defer func() {
		if err != nil {
			utils.GetLog().Error("services.complain.Create : error : %s, ", err.Error())
		} else {
			utils.GetLog().Debug("services.complain.Create : debug : mapComplain=%s", utils.Sdump(mapComplain))
		}
	}()

	var complian models.JobComplaint
	pid, _ := mapComplain["Jobcode"].(string)

	filter := make(map[string]interface{})
	filter["code"] = pid

	var job *models.Job
	job, err = GetOneJob(filter)
	complian.Job = &models.Job{Id: job.Id}
	complian.Project = &models.Project{Id: job.Project.Id}
	complian.Employee = &models.User{Id: job.Employee.Id}

	complian.Complain = mapComplain["Complain"].(string)
	complian.Type = mapComplain["Type"].(string)
	response, _ := mapComplain["response"].(int)
	complian.Response = uint(response)

	complian.User = user

	var insertId int64
	insertId, err = models.GetDB().Insert(&complian)
	if err != nil {
		utils.GetLog().Debug("services.complian.Create : debug : job=%s", utils.Sdump(complian))
		return
	}
	complainId = uint(insertId)
	return

}
Example #3
0
func (cp ComplaintCreator) GetTableName() string {
	j := models.JobComplaint{}
	return j.TableName()
}