Ejemplo n.º 1
0
func (p *InventoryEdit) OnSuccessFromInventoryForm() *exit.Exit {

	invs, err := p.unmarshalInventories(p.InventoriesJson)
	if err != nil {
		panic(err)
	}
	p.InventoryGroup.Inventories = invs

	if p.GroupId == nil { // if create
		// Auto add 2 days to ReceiveTime.
		p.InventoryGroup.ReceiveTime = p.InventoryGroup.SendTime.AddDate(0, 0, 2)
	} else { // if edit
		// TODO...
	}

	p.InventoryGroup.Type = guessTypeByCreateType(p.CreateType)
	p.InventoryGroup.CreateTime = time.Now() // update create time

	nig, err := service.InventoryGroup.SaveInventoryGroupByNGLIST(p.InventoryGroup)
	if err != nil {
		panic(err)
	}

	// return to refer first
	return exit.RedirectFirstValid(
		p.Referer,
		"/product/list",
		fmt.Sprintf("/inventory/edit/%d", nig.Id),
	)
}
Ejemplo n.º 2
0
// ________________________________________________________________________________
// Events
//
func (p *PlaceOrderList) OnDelete(id int64) *exit.Exit {
	// TODO delete inventories
	// TODO delete inventory groups.
	// if _, err := service.Inventory.DeleteInventory(id); err != nil {
	// 	panic(err)				//
	// }							//
	return exit.RedirectFirstValid(p.Referer, "/inventory")
}
Ejemplo n.º 3
0
// ________________________________________________________________________________
// Events
//
func (p *InventoryProductSelector) Ondelete(id int64, tab string) interface{} {
	if _, err := service.Inventory.DeleteInventory(id); err != nil {
		panic(err)
	}
	return exit.RedirectFirstValid(p.Referer, "/inventory")
}