func (VS *Server) newToDo(c *gin.Context) {
	userID, b := VS.getIDFromHTML(c, "workerID", "To do")
	if !b {
		return
	}
	title, b := VS.getStringFromHTML(c, "title", "To do")
	if !b {
		return
	}

	description, b := VS.getStringFromHTML(c, "description", "To do")
	if !b {
		return
	}

	timechecking, b := VS.getStringFromHTML(c, "timechecking", "To do")
	if !b {
		return
	}
	istrackable := VS.getCheckBoxFromHTML(c, "istrackable")
	id := bson.NewObjectId()
	if istrackable {
		id, b = VS.getQRFromHTMLNew(c, Task)
	}
	if !b {
		return
	}

	descriptions := c.PostFormArray("descriptionfield")
	numbers := c.PostFormArray("numbers")
	titlePhotos := c.PostFormArray("phototitle")
	user := VS.getUserByID(c, userID, "h_check-app", "newToDo", "user := VS.getUserByID")
	photos, _ := VS.getArrayPhotosFromHTML(c, "photo", basePath+"/local-resources/users/"+user.Username+"/to-dos/")
	checkboxes := c.PostFormArray("checkboxes")
	villageID := VS.getUserByID(c, userID, "h_check-app", "newToDo", "villageID := VS.getUserByID").IDVillage
	todo := ToDo{
		ID:              id,
		TitleToDo:       title,
		DescriptionToDo: description,
		IDUser:          userID,
		IDVillage:       villageID,
		TimeChecking:    TimecheckingType(timechecking),
		IsTrackable:     istrackable,
	}
	for _, ck := range checkboxes {
		newCheckbox := FieldCheckbox{
			ID:            bson.NewObjectId(),
			IDToDo:        todo.ID,
			TitleCheckbox: ck,
		}
		todo.Checkboxes = append(todo.Checkboxes, newCheckbox)
	}
	for index, p := range titlePhotos {
		newPhoto := FieldPhoto{
			ID:         bson.NewObjectId(),
			IDToDo:     todo.ID,
			TitlePhoto: p,
			Photo:      photos[index],
		}
		todo.Photos = append(todo.Photos, newPhoto)
	}
	for _, n := range numbers {
		newNumber := FieldNumber{
			ID:          bson.NewObjectId(),
			IDToDo:      todo.ID,
			TitleNumber: n,
		}
		todo.Numbers = append(todo.Numbers, newNumber)
	}
	for _, d := range descriptions {
		newDescription := FieldDescription{
			ID:          bson.NewObjectId(),
			IDToDo:      todo.ID,
			Description: d,
		}
		todo.Descriptions = append(todo.Descriptions, newDescription)
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, todo, todo.ID, "h_check-app", "newToDo", "VS.addElementToDatabaseWithRegisterFromCentral")
	VS.goodFeedback(c, "/to-do/what-to-check")
}
// This handler creates a new todo
This handler creates a new todo
// This handler creates a new todo
func (VS *Server) newToDo(c *gin.Context) {
	userID, b := VS.getIDFromHTML(c, "workerID", "To do")
	if !b {
		return
	}
	title, b := VS.getStringFromHTML(c, "title", "To do")
	if !b {
		return
	}
	description, b := VS.getStringFromHTML(c, "description", "To do")
	if !b {
		return
	}
	timechecking, b := VS.getStringFromHTML(c, "timechecking", "To do")
	if !b {
		return
	}
	istrackable := VS.getCheckBoxFromHTML(c, "istrackable")
	id := bson.NewObjectId()
	if istrackable {
		id, b = VS.getQRFromHTMLNew(c, Task)
	}
	if !b {
		return
	}
	descriptions := c.PostFormArray("descriptionfield")
	numbers := c.PostFormArray("numbers")
	titlePhotos := c.PostFormArray("phototitle")
	user := VS.getUserByID(c, userID, "h_check-app", "newToDo", "user := VS.getUserByID")
	photos, _ := VS.getArrayPhotosFromHTML(c, "photo", basePath+"/local-resources/users/"+user.Username+"/to-dos/")
	checkboxes := c.PostFormArray("checkboxes")
	villageID := VS.getUserByID(c, userID, "h_check-app", "newToDo", "villageID := VS.getUserByID").IDVillage
	todo := ToDo{
		ID:              id,
		TitleToDo:       title,
		DescriptionToDo: description,
		IDUser:          userID,
		IDVillage:       villageID,
		TimeChecking:    TimecheckingType(timechecking),
		IsTrackable:     istrackable,
	}
	for _, ck := range checkboxes {
		newCheckbox := FieldCheckbox{
			ID:            bson.NewObjectId(),
			IDToDo:        todo.ID,
			TitleCheckbox: ck,
		}
		todo.Checkboxes = append(todo.Checkboxes, newCheckbox)
	}
	for index, p := range titlePhotos {
		newPhoto := FieldPhoto{
			ID:         bson.NewObjectId(),
			IDToDo:     todo.ID,
			TitlePhoto: p,
			Photo:      photos[index],
		}
		todo.Photos = append(todo.Photos, newPhoto)
	}
	for _, n := range numbers {
		newNumber := FieldNumber{
			ID:          bson.NewObjectId(),
			IDToDo:      todo.ID,
			TitleNumber: n,
		}
		todo.Numbers = append(todo.Numbers, newNumber)
	}
	for _, d := range descriptions {
		newDescription := FieldDescription{
			ID:          bson.NewObjectId(),
			IDToDo:      todo.ID,
			Description: d,
		}
		todo.Descriptions = append(todo.Descriptions, newDescription)
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, todo, todo.ID, "h_check-app", "newToDo", "VS.addElementToDatabaseWithRegisterFromCentral")
	VS.goodFeedback(c, "/to-do/what-to-check")
}
func ( VS * Server ) newToDo ( c * gin . Context ) { userID , b := VS . getIDFromHTML ( c , " " , " " ) if ! b { return } title , b := VS . getStringFromHTML ( c , " " , " " ) if ! b { return } description , b := VS . getStringFromHTML ( c , " " , " " ) if ! b { return } timechecking , b := VS . getStringFromHTML ( c , " " , " " ) if ! b { return } istrackable := VS . getCheckBoxFromHTML ( c , " " ) id := bson . NewObjectId ( ) if istrackable { id , b = VS . getQRFromHTMLNew ( c , Task ) } if ! b { return } descriptions := c . PostFormArray ( " " ) numbers := c . PostFormArray ( " " ) titlePhotos := c . PostFormArray ( " " ) user := VS . getUserByID ( c , userID , " " , " " , " " ) photos , _ := VS . getArrayPhotosFromHTML ( c , " " , basePath + " " + user . Username + " " ) checkboxes := c . PostFormArray ( " " ) villageID := VS . getUserByID ( c , userID , " " , " " , " " ) . IDVillage todo := ToDo { ID : id , TitleToDo : title , DescriptionToDo : description , IDUser : userID , IDVillage : villageID , TimeChecking : TimecheckingType ( timechecking ) , IsTrackable : istrackable , } for _ , ck := range checkboxes { newCheckbox := FieldCheckbox { ID : bson . NewObjectId ( ) , IDToDo : todo . ID , TitleCheckbox : ck , } todo . Checkboxes = append ( todo . Checkboxes , newCheckbox ) } for index , p := range titlePhotos { newPhoto := FieldPhoto { ID : bson . NewObjectId ( ) , IDToDo : todo . ID , TitlePhoto : p , Photo : photos [ index ] , } todo . Photos = append ( todo . Photos , newPhoto ) } for _ , n := range numbers { newNumber := FieldNumber { ID : bson . NewObjectId ( ) , IDToDo : todo . ID , TitleNumber : n , } todo . Numbers = append ( todo . Numbers , newNumber ) } for _ , d := range descriptions { newDescription := FieldDescription { ID : bson . NewObjectId ( ) , IDToDo : todo . ID , Description : d , } todo . Descriptions = append ( todo . Descriptions , newDescription ) } VS . addElementToDatabaseWithRegisterFromCentral ( c , todo , todo . ID , " " , " " , " " ) VS . goodFeedback ( c , " " ) }
This handler creates a new todo
This handler creates a new todo