func (VS *Server) toViewWorkshopOrder(c *gin.Context, workshopOrders []ServiceOrder) []ServiceOrderHTML {
	var prodOrdersHTML []ServiceOrderHTML
	var prodOHTML ServiceOrderHTML
	for i := 0; i < len(workshopOrders); i++ {
		prodOHTML.ID = workshopOrders[i].ID
		prodOHTML.Assigned = workshopOrders[i].Assigned
		// We add the Product Name, get the Product from DataBase
		temProd, _ := VS.getVideoCourseByID(c, workshopOrders[i].IDVideoCourse, "h_view", "toViewWorkshopOrder", "temProd, _ := VS.getVideoCourseByID", true)
		prodOHTML.ProductName = temProd.Name
		prodOHTML.Photo = temProd.Photo
		// We add the Workshop name
		wk := VS.getServiceByID(c, workshopOrders[i].IDService, "h_view", "toViewWorkshopOrder", "wk := VS.getServiceByID", true)
		prodOHTML.Village = VS.getVillageByID(c, wk.IDVillage, "h_view", "toViewWorkshopOrder", "prodOHTML.Village = VS.getVillageByID").Name
		prodOHTML.WorkshopName = wk.Name
		// We add the Date
		prodOHTML.Deadline = strconv.Itoa(time.Unix(workshopOrders[i].Deadline, 0).Day()) + " / " + time.Unix(workshopOrders[i].Deadline, 0).Month().String()
		// We add the Quantity
		prodOHTML.Quantity = workshopOrders[i].Quantity
		switch workshopOrders[i].WindowPeriod {
		case 3:
			prodOHTML.Window = "3 Days"
			break

		case 7:
			prodOHTML.Window = "1 Week"
			break

		case 10:
			prodOHTML.Window = "10 Days"
			break

		case 14:
			prodOHTML.Window = "2 Weeks"
			break

		case 30:
			prodOHTML.Window = "1 Month"
			break

		default:
			prodOHTML.Window = "Error in input Window Period"
		}

		// We add the Already Made
		prodOHTML.AlreadyMade = workshopOrders[i].AlreadyMade

		if workshopOrders[i].Quantity != 0 {
			prodOHTML.Status = strconv.Itoa((100*workshopOrders[i].AlreadyMade)/workshopOrders[i].Quantity) + " %"
		} else {
			prodOHTML.Status = "You assigned Quantity = 0 "
		}
		prodOrdersHTML = append(prodOrdersHTML, prodOHTML)
	}
	return prodOrdersHTML
}
// This method takes an array of ServiceOrder and returns an array of ServiceOrdersHTML
This method takes an array of ServiceOrder and returns an array of ServiceOrdersHTML
// This method takes an array of ServiceOrder and returns an array of ServiceOrdersHTML
func (VS *Server) toViewWorkshopOrder(c *gin.Context, workshopOrders []ServiceOrder) []ServiceOrderHTML {
	var prodOrdersHTML []ServiceOrderHTML
	var prodOHTML ServiceOrderHTML
	for i := 0; i < len(workshopOrders); i++ {
		prodOHTML.ID = workshopOrders[i].ID
		prodOHTML.Assigned = workshopOrders[i].Assigned
		temProd, _ := VS.getVideoCourseByID(c, workshopOrders[i].IDVideoCourse, "h_view", "toViewWorkshopOrder", "temProd, _ := VS.getVideoCourseByID", true)
		prodOHTML.ProductName = temProd.Name
		prodOHTML.Photo = temProd.Photo
		wk := VS.getServiceByID(c, workshopOrders[i].IDService, "h_view", "toViewWorkshopOrder", "wk := VS.getServiceByID", true)
		prodOHTML.Village = VS.getVillageByID(c, wk.IDVillage, "h_view", "toViewWorkshopOrder", "prodOHTML.Village = VS.getVillageByID").Name
		prodOHTML.WorkshopName = wk.Name
		prodOHTML.Deadline = strconv.Itoa(time.Unix(workshopOrders[i].Deadline, 0).Day()) + " / " + time.Unix(workshopOrders[i].Deadline, 0).Month().String()
		prodOHTML.Quantity = workshopOrders[i].Quantity
		switch workshopOrders[i].WindowPeriod {
		case 3:
			prodOHTML.Window = "3 Days"
			break
		case 7:
			prodOHTML.Window = "1 Week"
			break
		case 10:
			prodOHTML.Window = "10 Days"
			break
		case 14:
			prodOHTML.Window = "2 Weeks"
			break
		case 30:
			prodOHTML.Window = "1 Month"
			break
		default:
			prodOHTML.Window = "Error in input Window Period"
		}
		prodOHTML.AlreadyMade = workshopOrders[i].AlreadyMade
		if workshopOrders[i].Quantity != 0 {
			prodOHTML.Status = strconv.Itoa((100*workshopOrders[i].AlreadyMade)/workshopOrders[i].Quantity) + " %"
		} else {
			prodOHTML.Status = "You assigned Quantity = 0 "
		}
		prodOrdersHTML = append(prodOrdersHTML, prodOHTML)
	}
	return prodOrdersHTML
}
func ( VS * Server ) toViewWorkshopOrder ( c * gin . Context , workshopOrders [ ] ServiceOrder ) [ ] ServiceOrderHTML { var prodOrdersHTML [ ] ServiceOrderHTML var prodOHTML ServiceOrderHTML for i := 0 ; i < len ( workshopOrders ) ; i ++ { prodOHTML . ID = workshopOrders [ i ] . ID prodOHTML . Assigned = workshopOrders [ i ] . Assigned temProd , _ := VS . getVideoCourseByID ( c , workshopOrders [ i ] . IDVideoCourse , " " , " " , " " , true ) prodOHTML . ProductName = temProd . Name prodOHTML . Photo = temProd . Photo wk := VS . getServiceByID ( c , workshopOrders [ i ] . IDService , " " , " " , " " , true ) prodOHTML . Village = VS . getVillageByID ( c , wk . IDVillage , " " , " " , " " ) . Name prodOHTML . WorkshopName = wk . Name prodOHTML . Deadline = strconv . Itoa ( time . Unix ( workshopOrders [ i ] . Deadline , 0 ) . Day ( ) ) + " " + time . Unix ( workshopOrders [ i ] . Deadline , 0 ) . Month ( ) . String ( ) prodOHTML . Quantity = workshopOrders [ i ] . Quantity switch workshopOrders [ i ] . WindowPeriod { case 3 : prodOHTML . Window = " " break case 7 : prodOHTML . Window = " " break case 10 : prodOHTML . Window = " " break case 14 : prodOHTML . Window = " " break case 30 : prodOHTML . Window = " " break default : prodOHTML . Window = " " } prodOHTML . AlreadyMade = workshopOrders [ i ] . AlreadyMade if workshopOrders [ i ] . Quantity != 0 { prodOHTML . Status = strconv . Itoa ( ( 100 * workshopOrders [ i ] . AlreadyMade ) / workshopOrders [ i ] . Quantity ) + " " } else { prodOHTML . Status = " " } prodOrdersHTML = append ( prodOrdersHTML , prodOHTML ) } return prodOrdersHTML }
This method takes an array of ServiceOrder and returns an array of ServiceOrdersHTML
This method takes an array of ServiceOrder and returns an array of ServiceOrdersHTML
// We add the Product Name, get the Product from DataBase // We add the Workshop name // We add the Date // We add the Quantity // We add the Already Made