func (VS *Server) makeToDo(c *gin.Context) {
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	todo := VS.getTodoByID(c, id, "h_check-app", "makeToDo", "todo := VS.getTodoByID")
	user := VS.getUserByID(c, todo.IDUser, "h_check-app", "makeToDo", "user := VS.getUserByID")

	descriptions := c.PostFormArray("descriptions")
	numbers := c.PostFormArray("numbers")
	photos, _ := VS.getArrayPhotosFromHTML(c, "photo", basePath+"/local-resources/users/"+user.Username+"/to-dos/checked/")
	// checkboxes := VS.getArrayCheckBoxesFromHTML(c, "checkboxes")
	checked := ToDoChecked{
		ID:     bson.NewObjectId(),
		Date:   getTime(),
		IDToDo: todo.ID,
	}

	if todo.IsTrackable {
		qr, b := VS.getQRFromHTML(c)
		if !b {
			VS.wrongFeedback(c, "It has been a problem with the QR code")
			return
		}
		if qr != todo.ID {
			VS.wrongFeedback(c, "The QR code scan is not the QR of this task")
			return
		}
	}

	for index, ck := range todo.Checkboxes {
		newCheckbox := FieldCheckbox{
			ID:            bson.NewObjectId(),
			IDToDo:        checked.ID,
			TitleCheckbox: todo.Checkboxes[index].TitleCheckbox,
			Checkbox:      VS.getCheckBoxFromHTML(c, hex.EncodeToString([]byte(ck.ID))),
		}
		checked.Checkboxes = append(checked.Checkboxes, newCheckbox)
	}
	for index, p := range photos {
		fmt.Print("photo made: " + strconv.Itoa(index))

		newPhoto := FieldPhoto{
			ID:         bson.NewObjectId(),
			IDToDo:     checked.ID,
			TitlePhoto: p,
			Photo:      photos[index],
		}
		checked.Photos = append(checked.Photos, newPhoto)
	}
	for index, n := range numbers {
		fmt.Print("number made: " + strconv.Itoa(index))

		numb, _ := strconv.Atoi(n)
		newNumber := FieldNumber{
			ID:          bson.NewObjectId(),
			IDToDo:      checked.ID,
			TitleNumber: todo.Numbers[index].TitleNumber,
			Number:      numb,
		}
		checked.Numbers = append(checked.Numbers, newNumber)
	}
	for index, d := range descriptions {
		fmt.Print("description made: " + strconv.Itoa(index))
		newDescription := FieldDescription{
			ID:          bson.NewObjectId(),
			IDToDo:      checked.ID,
			Description: d,
		}
		checked.Descriptions = append(checked.Descriptions, newDescription)
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, checked, checked.ID, "h_check-app", "makeToDo", "VS.addElementToDatabaseWithRegisterFromCentral")
	VS.goodFeedback(c, "to-do/to-dos-user")
}
// This handler shows the items that we can make for the user or manager to check, is from the DASHBOARD
This handler shows the items that we can make for the user or manager to check, is from the DASHBOARD
// This handler shows the items that we can make for the user or manager to check is from the DASHBOARD
func (VS *Server) makeToDo(c *gin.Context) {
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	todo := VS.getTodoByID(c, id, "h_check-app", "makeToDo", "todo := VS.getTodoByID")
	user := VS.getUserByID(c, todo.IDUser, "h_check-app", "makeToDo", "user := VS.getUserByID")
	descriptions := c.PostFormArray("descriptions")
	numbers := c.PostFormArray("numbers")
	photos, _ := VS.getArrayPhotosFromHTML(c, "photo", basePath+"/local-resources/users/"+user.Username+"/to-dos/checked/")
	checked := ToDoChecked{
		ID:     bson.NewObjectId(),
		Date:   getTime(),
		IDToDo: todo.ID,
	}
	if todo.IsTrackable {
		qr, b := VS.getQRFromHTML(c)
		if !b {
			VS.wrongFeedback(c, "It has been a problem with the QR code")
			return
		}
		if qr != todo.ID {
			VS.wrongFeedback(c, "The QR code scan is not the QR of this task")
			return
		}
	}
	for index, ck := range todo.Checkboxes {
		newCheckbox := FieldCheckbox{
			ID:            bson.NewObjectId(),
			IDToDo:        checked.ID,
			TitleCheckbox: todo.Checkboxes[index].TitleCheckbox,
			Checkbox:      VS.getCheckBoxFromHTML(c, hex.EncodeToString([]byte(ck.ID))),
		}
		checked.Checkboxes = append(checked.Checkboxes, newCheckbox)
	}
	for index, p := range photos {
		fmt.Print("photo made: " + strconv.Itoa(index))
		newPhoto := FieldPhoto{
			ID:         bson.NewObjectId(),
			IDToDo:     checked.ID,
			TitlePhoto: p,
			Photo:      photos[index],
		}
		checked.Photos = append(checked.Photos, newPhoto)
	}
	for index, n := range numbers {
		fmt.Print("number made: " + strconv.Itoa(index))
		numb, _ := strconv.Atoi(n)
		newNumber := FieldNumber{
			ID:          bson.NewObjectId(),
			IDToDo:      checked.ID,
			TitleNumber: todo.Numbers[index].TitleNumber,
			Number:      numb,
		}
		checked.Numbers = append(checked.Numbers, newNumber)
	}
	for index, d := range descriptions {
		fmt.Print("description made: " + strconv.Itoa(index))
		newDescription := FieldDescription{
			ID:          bson.NewObjectId(),
			IDToDo:      checked.ID,
			Description: d,
		}
		checked.Descriptions = append(checked.Descriptions, newDescription)
	}
	VS.addElementToDatabaseWithRegisterFromCentral(c, checked, checked.ID, "h_check-app", "makeToDo", "VS.addElementToDatabaseWithRegisterFromCentral")
	VS.goodFeedback(c, "to-do/to-dos-user")
}
func ( VS * Server ) makeToDo ( c * gin . Context ) { id , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } todo := VS . getTodoByID ( c , id , " " , " " , " " ) user := VS . getUserByID ( c , todo . IDUser , " " , " " , " " ) descriptions := c . PostFormArray ( " " ) numbers := c . PostFormArray ( " " ) photos , _ := VS . getArrayPhotosFromHTML ( c , " " , basePath + " " + user . Username + " " ) checked := ToDoChecked { ID : bson . NewObjectId ( ) , Date : getTime ( ) , IDToDo : todo . ID , } if todo . IsTrackable { qr , b := VS . getQRFromHTML ( c ) if ! b { VS . wrongFeedback ( c , " " ) return } if qr != todo . ID { VS . wrongFeedback ( c , " " ) return } } for index , ck := range todo . Checkboxes { newCheckbox := FieldCheckbox { ID : bson . NewObjectId ( ) , IDToDo : checked . ID , TitleCheckbox : todo . Checkboxes [ index ] . TitleCheckbox , Checkbox : VS . getCheckBoxFromHTML ( c , hex . EncodeToString ( [ ] byte ( ck . ID ) ) ) , } checked . Checkboxes = append ( checked . Checkboxes , newCheckbox ) } for index , p := range photos { fmt . Print ( " " + strconv . Itoa ( index ) ) newPhoto := FieldPhoto { ID : bson . NewObjectId ( ) , IDToDo : checked . ID , TitlePhoto : p , Photo : photos [ index ] , } checked . Photos = append ( checked . Photos , newPhoto ) } for index , n := range numbers { fmt . Print ( " " + strconv . Itoa ( index ) ) numb , _ := strconv . Atoi ( n ) newNumber := FieldNumber { ID : bson . NewObjectId ( ) , IDToDo : checked . ID , TitleNumber : todo . Numbers [ index ] . TitleNumber , Number : numb , } checked . Numbers = append ( checked . Numbers , newNumber ) } for index , d := range descriptions { fmt . Print ( " " + strconv . Itoa ( index ) ) newDescription := FieldDescription { ID : bson . NewObjectId ( ) , IDToDo : checked . ID , Description : d , } checked . Descriptions = append ( checked . Descriptions , newDescription ) } VS . addElementToDatabaseWithRegisterFromCentral ( c , checked , checked . ID , " " , " " , " " ) VS . goodFeedback ( c , " " ) }
This handler shows the items that we can make for the user or manager to check, is from the DASHBOARD
This handler shows the items that we can make for the user or manager to check is from the DASHBOARD
// checkboxes := VS.getArrayCheckBoxesFromHTML(c, "checkboxes")