Esempio n. 1
0
func AdminDriverDocumentAdd(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	driver := service.FindOneDriver(c.GetPathVar("driverId"))
	docIds := util.SliceString(r.FormValue("docIds"), ',')
	for _, id := range docIds {
		document := service.Document{
			Id:         util.UUID4(),
			Name:       "dqf-" + id,
			DocumentId: id,
			Complete:   false,
			CompanyId:  driver.CompanyId,
			DriverId:   driver.Id,
		}
		service.SaveDocument(document)
	}
	c.SetFlash("alertSuccess", "Successfully added documents")
	http.Redirect(w, r, "/admin/driver/"+c.GetPathVar("driverId")+"/document", 303)

}
Esempio n. 2
0
func formatDate(date string) string {
	ds := util.SliceString(date, '-')
	return fmt.Sprintf("%s/%s/%s", ds[1], ds[2], ds[0])
}