pos login edited with phone number

This commit is contained in:
2026-08-11 11:08:43 +05:30
parent 3531c656d4
commit d35caf34d3
12 changed files with 768 additions and 25 deletions

View File

@@ -886,3 +886,76 @@ func (ctl *PosController) WebPosRoles(c *fiber.Ctx) error {
},
})
}
// ─────────────────────────────────────────────────────────── Staff shifts
//
// Working windows for till staff, managed from the console. Same scoping rule
// as the till-user routes above: the outlet is asserted by the caller and
// checked against the tenant before anything is written.
// WebListStaffShifts returns an outlet's shifts, for a picker.
func (ctl *PosController) WebListStaffShifts(c *fiber.Ctx) error {
tenantID, _ := strconv.Atoi(strings.TrimSpace(c.Query("tenantid")))
locationID, _ := strconv.Atoi(strings.TrimSpace(c.Query("locationid")))
if err := ctl.posWebScope(tenantID, locationID); err != nil {
return posBadRequest(c, err)
}
shifts, err := ctl.posService.ListStaffShifts(tenantID, locationID,
strings.EqualFold(c.Query("include_inactive"), "true"))
if err != nil {
return posServerError(c, "WebListStaffShifts", err)
}
return c.JSON(fiber.Map{
"code": http.StatusOK, "status": true,
"details": fiber.Map{"location_id": locationID, "shifts": shifts},
})
}
// WebCreateStaffShift adds a working window at one outlet.
func (ctl *PosController) WebCreateStaffShift(c *fiber.Ctx) error {
var req models.StaffShifts
if err := c.BodyParser(&req); err != nil {
return posBadRequest(c, fmt.Errorf("invalid request body"))
}
if err := ctl.posWebScope(req.Tenantid, req.Locationid); err != nil {
return posBadRequest(c, err)
}
shift, err := ctl.posService.CreateStaffShift(req.Tenantid, req.Locationid, req)
if err != nil {
return posBadRequest(c, err)
}
return c.Status(http.StatusCreated).JSON(fiber.Map{
"code": http.StatusCreated, "status": true,
"message": "Shift created", "details": shift,
})
}
// WebUpdateStaffShift edits a window. Deactivate by sending status "Inactive" —
// shifts are not deleted, because a person may still be assigned to one and an
// orphaned shiftid reads as a shift that never existed.
func (ctl *PosController) WebUpdateStaffShift(c *fiber.Ctx) error {
var req models.StaffShifts
if err := c.BodyParser(&req); err != nil {
return posBadRequest(c, fmt.Errorf("invalid request body"))
}
if err := ctl.posWebScope(req.Tenantid, req.Locationid); err != nil {
return posBadRequest(c, err)
}
shift, err := ctl.posService.UpdateStaffShift(req.Tenantid, req.Locationid, req)
if err != nil {
return posBadRequest(c, err)
}
return c.JSON(fiber.Map{
"code": http.StatusOK, "status": true,
"message": "Shift updated", "details": shift,
})
}