func (VS *Server) confirmDelivery(c *gin.Context) {
	service, b := VS.getOurService(c, "h_deliveries", "confirmDelivery", "service, b := VS.getOurService")
	if !b {
		return
	}

	// Comprobar la checkbox
	QR, b := VS.getIDFromHTMLWithoutChecking(c, "qr")
	if b {
		stock := VS.getStockByID(c, QR, "h_deliveries", "confirmDelivery", "stock := VS.getStockByID")
		stock.IDServiceLocation = service.ID
		audit := VS.getAudit(c, stock, QR, service.ID, Modified)
		VS.checkChange(c, audit.ID, "ServiceLocation", "Delivery", string(service.Type)+": "+service.Name)
		VS.addElementToDatabaseWithRegister(c, stock, stock.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	idDelivery, b := VS.getIDParamFromURL(c, "iddelivery")
	if !b {
		return
	}
	delivery, _ := VS.getDeliveryByID(c, idDelivery, "h_deliveries", "confirmDelivery", "delivery, _ := VS.getDeliveryByID", true)
	if delivery.IsComplete {
		return
	}
	// Check if the action is to close the delivery
	if VS.getCheckBoxFromHTML(c, "confirmed") {
		delivery.IsComplete = true
		VS.addElementToDatabaseWithRegister(c, delivery, delivery.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	itemsReceived, _ := VS.getArrayIDFromHTMLWithoutChecking(c, "item", "Delivery")
	for _, i := range itemsReceived {
		stock := VS.getStockByID(c, i, "h_deliveries", "confirmDelivery", "stock := VS.getStockByID")
		stock.IDServiceLocation = service.ID
		audit := VS.getAudit(c, delivery, QR, service.ID, Modified)
		VS.checkChange(c, audit.ID, "ServiceLocation", "Delivery", string(service.Type)+": "+service.Name)
		VS.addElementToDatabaseWithRegister(c, stock, stock.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	VS.goodFeedback(c, "/delivery/check-delivery/"+idDelivery.Hex())
}
// Mark as received the stock scanned by the QR or by the photo if it does not have QR
Mark as received the stock scanned by the QR or by the photo if it does not have QR
// Mark as received the stock scanned by the QR or by the photo if it does not have QR
func (VS *Server) confirmDelivery(c *gin.Context) {
	service, b := VS.getOurService(c, "h_deliveries", "confirmDelivery", "service, b := VS.getOurService")
	if !b {
		return
	}
	QR, b := VS.getIDFromHTMLWithoutChecking(c, "qr")
	if b {
		stock := VS.getStockByID(c, QR, "h_deliveries", "confirmDelivery", "stock := VS.getStockByID")
		stock.IDServiceLocation = service.ID
		audit := VS.getAudit(c, stock, QR, service.ID, Modified)
		VS.checkChange(c, audit.ID, "ServiceLocation", "Delivery", string(service.Type)+": "+service.Name)
		VS.addElementToDatabaseWithRegister(c, stock, stock.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	idDelivery, b := VS.getIDParamFromURL(c, "iddelivery")
	if !b {
		return
	}
	delivery, _ := VS.getDeliveryByID(c, idDelivery, "h_deliveries", "confirmDelivery", "delivery, _ := VS.getDeliveryByID", true)
	if delivery.IsComplete {
		return
	}
	if VS.getCheckBoxFromHTML(c, "confirmed") {
		delivery.IsComplete = true
		VS.addElementToDatabaseWithRegister(c, delivery, delivery.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	itemsReceived, _ := VS.getArrayIDFromHTMLWithoutChecking(c, "item", "Delivery")
	for _, i := range itemsReceived {
		stock := VS.getStockByID(c, i, "h_deliveries", "confirmDelivery", "stock := VS.getStockByID")
		stock.IDServiceLocation = service.ID
		audit := VS.getAudit(c, delivery, QR, service.ID, Modified)
		VS.checkChange(c, audit.ID, "ServiceLocation", "Delivery", string(service.Type)+": "+service.Name)
		VS.addElementToDatabaseWithRegister(c, stock, stock.ID, service.ID, "h_deliveries", "confirmDelivery", "VS.addElementToDatabaseWithRegister")
	}
	VS.goodFeedback(c, "/delivery/check-delivery/"+idDelivery.Hex())
}
func ( VS * Server ) confirmDelivery ( c * gin . Context ) { service , b := VS . getOurService ( c , " " , " " , " " ) if ! b { return } QR , b := VS . getIDFromHTMLWithoutChecking ( c , " " ) if b { stock := VS . getStockByID ( c , QR , " " , " " , " " ) stock . IDServiceLocation = service . ID audit := VS . getAudit ( c , stock , QR , service . ID , Modified ) VS . checkChange ( c , audit . ID , " " , " " , string ( service . Type ) + " " + service . Name ) VS . addElementToDatabaseWithRegister ( c , stock , stock . ID , service . ID , " " , " " , " " ) } idDelivery , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } delivery , _ := VS . getDeliveryByID ( c , idDelivery , " " , " " , " " , true ) if delivery . IsComplete { return } if VS . getCheckBoxFromHTML ( c , " " ) { delivery . IsComplete = true VS . addElementToDatabaseWithRegister ( c , delivery , delivery . ID , service . ID , " " , " " , " " ) } itemsReceived , _ := VS . getArrayIDFromHTMLWithoutChecking ( c , " " , " " ) for _ , i := range itemsReceived { stock := VS . getStockByID ( c , i , " " , " " , " " ) stock . IDServiceLocation = service . ID audit := VS . getAudit ( c , delivery , QR , service . ID , Modified ) VS . checkChange ( c , audit . ID , " " , " " , string ( service . Type ) + " " + service . Name ) VS . addElementToDatabaseWithRegister ( c , stock , stock . ID , service . ID , " " , " " , " " ) } VS . goodFeedback ( c , " " + idDelivery . Hex ( ) ) }
Mark as received the stock scanned by the QR or by the photo if it does not have QR
Mark as received the stock scanned by the QR or by the photo if it does not have QR
// Comprobar la checkbox // Check if the action is to close the delivery