func (VS *Server) newSale(c *gin.Context) {
	service, b := VS.getOurService(c, "h_worker", "newSale", "service, _ := VS.getOurService")
	if !b {
		return
	}
	// We clean the extra information needed for the slider
	stockID, b := VS.getIDFromHTMLCleaningIt(c, "|", "stock", "Stock")
	if !b {
		return
	}

	fmt.Print("this is the stock id: ")
	fmt.Print(stockID)

	userID, b := VS.getIDFromHTML(c, "workerID", "Sale")
	if !b {
		return
	}
	price := 0.0
	quantity := 1.0
	var oldStock Stock
	// Comprobar la checkbox
	QR, isQR := VS.getIDFromHTMLWithoutChecking(c, "qr")
	if isQR {
		fmt.Print("IS QR")
		stockID = QR
		oldStock = VS.getStockByID(c, stockID, "h_worker", "newSale", "oldStock = VS.getStockByID(")
	} else {
		fmt.Print("NO QR")
		quantity, b = VS.getFloatFromHTMLWithoutChecking(c, "quantity", "Sale")
		if !b {
			quantity = 1.0
		}
		oldStock = VS.getStockByID(c, stockID, "h_worker", "newSale", "oldStock = VS.getStockByID(c")
	}
	newStock := oldStock
	newStock.IDServiceLocation = userID
	VS.editElementInDatabaseWithRegister(c, oldStock, newStock, stockID, service.ID, "h_worker", "newSale", "v.editElementInDatabaseWithRegister")

	sale := Sale{
		ID:        bson.NewObjectId(),
		IDService: service.ID,
		IDStock:   stockID,
		IDWorker:  userID,
		IDManager: VS.getUserFomCookie(c, "h_worker", "newSale", "VS.getUserFomCookie").ID,
		Date:      getTime(),
		Price:     price,
		Quantity:  quantity,
	}

	fmt.Print("This is sale")
	fmt.Print(sale)

	VS.makeSale(c, sale)
	idservicetype, b := VS.getIDParamFromURL(c, "idservicetype")
	if !b {
		return
	}
	VS.addElementToDatabaseWithRegister(c, sale, sale.ID, service.ID, "h_worker", "newSale", "v.addElementToDatabaseWithRegister")
	VS.goodFeedback(c, "records/worker-sales/"+idservicetype.Hex())
	fmt.Print("This is sale")
	fmt.Print(sale)
}
// Stores the new Sale into the DataBase
Stores the new Sale into the DataBase
// Stores the new Sale into the DataBase
func (VS *Server) newSale(c *gin.Context) {
	service, b := VS.getOurService(c, "h_worker", "newSale", "service, _ := VS.getOurService")
	if !b {
		return
	}
	stockID, b := VS.getIDFromHTMLCleaningIt(c, "|", "stock", "Stock")
	if !b {
		return
	}
	fmt.Print("this is the stock id: ")
	fmt.Print(stockID)
	userID, b := VS.getIDFromHTML(c, "workerID", "Sale")
	if !b {
		return
	}
	price := 0.0
	quantity := 1.0
	var oldStock Stock
	QR, isQR := VS.getIDFromHTMLWithoutChecking(c, "qr")
	if isQR {
		fmt.Print("IS QR")
		stockID = QR
		oldStock = VS.getStockByID(c, stockID, "h_worker", "newSale", "oldStock = VS.getStockByID(")
	} else {
		fmt.Print("NO QR")
		quantity, b = VS.getFloatFromHTMLWithoutChecking(c, "quantity", "Sale")
		if !b {
			quantity = 1.0
		}
		oldStock = VS.getStockByID(c, stockID, "h_worker", "newSale", "oldStock = VS.getStockByID(c")
	}
	newStock := oldStock
	newStock.IDServiceLocation = userID
	VS.editElementInDatabaseWithRegister(c, oldStock, newStock, stockID, service.ID, "h_worker", "newSale", "v.editElementInDatabaseWithRegister")
	sale := Sale{
		ID:        bson.NewObjectId(),
		IDService: service.ID,
		IDStock:   stockID,
		IDWorker:  userID,
		IDManager: VS.getUserFomCookie(c, "h_worker", "newSale", "VS.getUserFomCookie").ID,
		Date:      getTime(),
		Price:     price,
		Quantity:  quantity,
	}
	fmt.Print("This is sale")
	fmt.Print(sale)
	VS.makeSale(c, sale)
	idservicetype, b := VS.getIDParamFromURL(c, "idservicetype")
	if !b {
		return
	}
	VS.addElementToDatabaseWithRegister(c, sale, sale.ID, service.ID, "h_worker", "newSale", "v.addElementToDatabaseWithRegister")
	VS.goodFeedback(c, "records/worker-sales/"+idservicetype.Hex())
	fmt.Print("This is sale")
	fmt.Print(sale)
}
func ( VS * Server ) newSale ( c * gin . Context ) { service , b := VS . getOurService ( c , " " , " " , " " ) if ! b { return } stockID , b := VS . getIDFromHTMLCleaningIt ( c , " " , " " , " " ) if ! b { return } fmt . Print ( " " ) fmt . Print ( stockID ) userID , b := VS . getIDFromHTML ( c , " " , " " ) if ! b { return } price := 0.0 quantity := 1.0 var oldStock Stock QR , isQR := VS . getIDFromHTMLWithoutChecking ( c , " " ) if isQR { fmt . Print ( " " ) stockID = QR oldStock = VS . getStockByID ( c , stockID , " " , " " , " " ) } else { fmt . Print ( " " ) quantity , b = VS . getFloatFromHTMLWithoutChecking ( c , " " , " " ) if ! b { quantity = 1.0 } oldStock = VS . getStockByID ( c , stockID , " " , " " , " " ) } newStock := oldStock newStock . IDServiceLocation = userID VS . editElementInDatabaseWithRegister ( c , oldStock , newStock , stockID , service . ID , " " , " " , " " ) sale := Sale { ID : bson . NewObjectId ( ) , IDService : service . ID , IDStock : stockID , IDWorker : userID , IDManager : VS . getUserFomCookie ( c , " " , " " , " " ) . ID , Date : getTime ( ) , Price : price , Quantity : quantity , } fmt . Print ( " " ) fmt . Print ( sale ) VS . makeSale ( c , sale ) idservicetype , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } VS . addElementToDatabaseWithRegister ( c , sale , sale . ID , service . ID , " " , " " , " " ) VS . goodFeedback ( c , " " + idservicetype . Hex ( ) ) fmt . Print ( " " ) fmt . Print ( sale ) }
Stores the new Sale into the DataBase
Stores the new Sale into the DataBase
// We clean the extra information needed for the slider // Comprobar la checkbox