// const express = require("express");
// const router = express.Router();

// const attendanceController = require("../../controllers/postgre/attendanceManagementController");
// const authenticate = require("../../middlewares/authenticate");

// /**
//  * @swagger
//  * tags:
//  *   name: Attendance Management
//  *   description: Attendance marking, check-in/out, listing, update and deletion APIs
//  */

// /* ===========================
//    ✅ CREATE ATTENDANCE
// =========================== */

// router.post(
//   "/create",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Create attendance record'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.requestBody = {
//         required: true,
//         content: {
//           "application/json": {
//             schema: {
//               type: "object",
//               properties: {
//                 employee_id: { type: "string" },
//                 attendance_date: { type: "string", format: "date" },
//                 check_in_time: { type: "string" },
//                 check_out_time: { type: "string" },
//                 shift_type: { type: "string", enum: ["Shift A", "Shift B", "Shift C", "General"] },
//                 latitude: { type: "number" },
//                 longitude: { type: "number" },
//                 office_location: { type: "string" },
//                 remarks: { type: "string" },
//                 org_id: { type: "string" },
//                 created_by: { type: "string" }
//               },
//               required: ["employee_id", "attendance_date", "org_id"]
//             }
//           }
//         }
//       }
//     */

//     attendanceController.createAttendance(req, res);
//   }
// );

// /* ===========================
//    ✅ CHECK-IN
// =========================== */

// router.post(
//   "/check-in",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Mark check-in for an employee'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.requestBody = {
//         required: true,
//         content: {
//           "application/json": {
//             schema: {
//               type: "object",
//               properties: {
//                 employee_id: { type: "string" },
//                 attendance_date: { type: "string", format: "date" },
//                 check_in_time: { type: "string" },
//                 shift_type: { type: "string", enum: ["Shift A", "Shift B", "Shift C", "General"] },
//                 latitude: { type: "number" },
//                 longitude: { type: "number" },
//                 office_location: { type: "string" },
//                 org_id: { type: "string" },
//                 created_by: { type: "string" }
//               },
//               required: ["employee_id", "attendance_date", "org_id"]
//             }
//           }
//         }
//       }
//     */

//     attendanceController.checkIn(req, res);
//   }
// );

// /* ===========================
//    ✅ CHECK-OUT
// =========================== */

// router.post(
//   "/check-out",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Mark check-out for an employee'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.requestBody = {
//         required: true,
//         content: {
//           "application/json": {
//             schema: {
//               type: "object",
//               properties: {
//                 employee_id: { type: "string" },
//                 attendance_date: { type: "string", format: "date" },
//                 check_out_time: { type: "string" },
//                 org_id: { type: "string" },
//                 updated_by: { type: "string" }
//               },
//               required: ["employee_id", "attendance_date", "org_id"]
//             }
//           }
//         }
//       }
//     */

//     attendanceController.checkOut(req, res);
//   }
// );

// /* ===========================
//    ✅ GET ALL ATTENDANCE RECORDS
// =========================== */

// router.get(
//   "/all",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Get all attendance records with filters'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['page'] = {
//         in: 'query',
//         description: 'Page number',
//         type: 'integer'
//       }
//       #swagger.parameters['limit'] = {
//         in: 'query',
//         description: 'Records per page',
//         type: 'integer'
//       }
//       #swagger.parameters['employee_id'] = {
//         in: 'query',
//         description: 'Filter by employee code',
//         type: 'string'
//       }
//       #swagger.parameters['start_date'] = {
//         in: 'query',
//         description: 'Filter by start date',
//         type: 'string',
//         format: 'date'
//       }
//       #swagger.parameters['end_date'] = {
//         in: 'query',
//         description: 'Filter by end date',
//         type: 'string',
//         format: 'date'
//       }
//       #swagger.parameters['shift_type'] = {
//         in: 'query',
//         description: 'Filter by shift type',
//         type: 'string',
//         enum: ['Shift A', 'Shift B', 'Shift C', 'General']
//       }
//       #swagger.parameters['attendance_status'] = {
//         in: 'query',
//         description: 'Filter by attendance status',
//         type: 'string',
//         enum: ['Present', 'Absent', 'Half Day', 'Late', 'Holiday', 'Leave']
//       }
//       #swagger.parameters['org_id'] = {
//         in: 'query',
//         description: 'Filter by organization ID',
//         type: 'string'
//       }
//     */

//     attendanceController.getAttendance(req, res);
//   }
// );

// /* ===========================
//    ✅ GET TODAY'S ATTENDANCE
// =========================== */

// router.get(
//   "/today",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Get today\'s attendance records'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['org_id'] = {
//         in: 'query',
//         description: 'Organization ID',
//         type: 'string'
//       }
//     */

//     attendanceController.getTodayAttendance(req, res);
//   }
// );

// /* ===========================
//    ✅ GET ATTENDANCE SUMMARY
// =========================== */

// router.get(
//   "/summary",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Get attendance summary by employee'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['employee_code'] = {
//         in: 'query',
//         description: 'Employee code',
//         type: 'string'
//       }
//       #swagger.parameters['year'] = {
//         in: 'query',
//         description: 'Filter by year',
//         type: 'integer'
//       }
//       #swagger.parameters['month'] = {
//         in: 'query',
//         description: 'Filter by month',
//         type: 'integer'
//       }
//       #swagger.parameters['org_id'] = {
//         in: 'query',
//         description: 'Organization ID',
//         type: 'string'
//       }
//     */

//     attendanceController.getAttendanceSummary(req, res);
//   }
// );

// /* ===========================
//    ✅ GET LATE ATTENDANCE REPORT
// =========================== */

// router.get(
//   "/late-report",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Get late attendance report'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['start_date'] = {
//         in: 'query',
//         description: 'Start date',
//         type: 'string',
//         format: 'date'
//       }
//       #swagger.parameters['end_date'] = {
//         in: 'query',
//         description: 'End date',
//         type: 'string',
//         format: 'date'
//       }
//       #swagger.parameters['org_id'] = {
//         in: 'query',
//         description: 'Organization ID',
//         type: 'string'
//       }
//     */

//     attendanceController.getLateAttendanceReport(req, res);
//   }
// );

// /* ===========================
//    ✅ GET ATTENDANCE BY ID
// =========================== */

// router.get(
//   "/:id",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Get attendance record by ID'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['id'] = {
//         in: 'path',
//         description: 'Attendance ID',
//         required: true,
//         type: 'integer'
//       }
//     */

//     attendanceController.getAttendanceById(req, res);
//   }
// );

// /* ===========================
//    ✅ UPDATE ATTENDANCE
// =========================== */

// router.put(
//   "/:id",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Update attendance record by ID'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['id'] = {
//         in: 'path',
//         description: 'Attendance ID',
//         required: true,
//         type: 'integer'
//       }
//       #swagger.requestBody = {
//         required: true,
//         content: {
//           "application/json": {
//             schema: {
//               type: "object",
//               properties: {
//                 check_in_time: { type: "string" },
//                 check_out_time: { type: "string" },
//                 shift_type: { type: "string", enum: ["Shift A", "Shift B", "Shift C", "General"] },
//                 latitude: { type: "number" },
//                 longitude: { type: "number" },
//                 office_location: { type: "string" },
//                 remarks: { type: "string" },
//                 updated_by: { type: "string" }
//               }
//             }
//           }
//         }
//       }
//     */

//     attendanceController.updateAttendance(req, res);
//   }
// );

// /* ===========================
//    ✅ DELETE ATTENDANCE
// =========================== */

// router.delete(
//   "/:id",
//   authenticate,
//   (req, res) => {
//     /*
//       #swagger.tags = ['Attendance Management']
//       #swagger.summary = 'Delete attendance record (soft delete)'
//       #swagger.security = [{ "bearerAuth": [] }]
//       #swagger.parameters['id'] = {
//         in: 'path',
//         description: 'Attendance ID',
//         required: true,
//         type: 'integer'
//       }
//       #swagger.requestBody = {
//         required: false,
//         content: {
//           "application/json": {
//             schema: {
//               type: "object",
//               properties: {
//                 updated_by: { type: "string" }
//               }
//             }
//           }
//         }
//       }
//     */

//     attendanceController.deleteAttendance(req, res);
//   }
// );

// module.exports = router;


 const express = require("express");
const router = express.Router();

const attendanceController = require("../../controllers/postgre/attendanceManagementController");
const authenticate = require("../../middlewares/authenticate");

/**
 * @swagger
 * tags:
 *   name: Attendance
 *   description: Attendance management — daily reset, check-in/out, status updates, reports
 */

/* ===========================
   ✅ CREATE ATTENDANCE
=========================== */
router.post("/create", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Create a new attendance record'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["employee_id", "attendance_date", "org_id"],
            properties: {
              employee_id:          { type: "string",  description: "Employee code" },
              attendance_date:      { type: "string",  format: "date" },
              check_in_time:        { type: "string",  example: "09:00:00" },
              check_out_time:       { type: "string",  example: "18:00:00" },
              attendance_status:    { type: "string",  enum: ["Present","Absent","Late","Half Day","Cross Shift","Shift Swap","Double Shift","Holiday","Leave"] },
              original_shift_id:    { type: "integer", description: "Employee home shift" },
              actual_shift_id:      { type: "integer", description: "Shift they actually worked (Cross Shift)" },
              swap_with_employee_id:{ type: "integer", description: "Other employee in Shift Swap" },
              is_double_shift:      { type: "boolean" },
              second_shift_id:      { type: "integer" },
              remarks:              { type: "string" },
              org_id:               { type: "integer" },
              created_by:           { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[201] = { description: "Attendance created" }
    #swagger.responses[409] = { description: "Already exists for this date" }
  */
  attendanceController.createAttendance(req, res);
});

/* ===========================
   ✅ CHECK-IN
=========================== */
router.post("/check-in", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Mark check-in for an employee'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["employee_id", "attendance_date", "org_id"],
            properties: {
              employee_id:     { type: "string",  description: "Employee code" },
              attendance_date: { type: "string",  format: "date" },
              check_in_time:   { type: "string",  example: "09:05:00", description: "Defaults to current server time" },
              latitude:        { type: "number" },
              longitude:       { type: "number" },
              office_location: { type: "string" },
              org_id:          { type: "integer" },
              created_by:      { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Check-in updated on existing record" }
    #swagger.responses[201] = { description: "Check-in created new record" }
    #swagger.responses[409] = { description: "Already checked in today" }
  */
  attendanceController.checkIn(req, res);
});

/* ===========================
   ✅ CHECK-OUT (by employee code)
=========================== */
router.post("/check-out", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Mark check-out for an employee (manager triggered)'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["employee_id", "attendance_date", "org_id"],
            properties: {
              employee_id:     { type: "string",  description: "Employee code" },
              attendance_date: { type: "string",  format: "date" },
              check_out_time:  { type: "string",  example: "18:00:00", description: "Defaults to current server time" },
              org_id:          { type: "integer" },
              updated_by:      { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Checked out, work_hours and overtime calculated" }
    #swagger.responses[409] = { description: "Already checked out" }
  */
  attendanceController.checkOut(req, res);
});

/* ===========================
   ✅ UPDATE ATTENDANCE
=========================== */
router.put("/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Update an attendance record by ID'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            properties: {
              attendance_status:     { type: "string" },
              check_in_time:         { type: "string" },
              check_out_time:        { type: "string" },
              shift_type:            { type: "string" },
              work_hours:            { type: "number" },
              is_late:               { type: "boolean" },
              late_minutes:          { type: "integer" },
              original_shift_id:     { type: "integer" },
              actual_shift_id:       { type: "integer" },
              swap_with_employee_id: { type: "integer" },
              is_double_shift:       { type: "boolean" },
              second_shift_id:       { type: "integer" },
              latitude:              { type: "number" },
              longitude:             { type: "number" },
              office_location:       { type: "string" },
              remarks:               { type: "string" },
              updated_by:            { type: "integer" }
            }
          }
        }
      }
    }
  */
  attendanceController.updateAttendance(req, res);
});


/* ===========================
   ✅ UPDATE INDIVIDUAL STATUS
=========================== */
router.put("/individual/:id/status", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Update attendance status for a single employee'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer', description: 'Attendance record ID' }
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["attendance_status"],
            properties: {
              attendance_status:     { type: "string", enum: ["Present","Absent","Late","Half Day","Cross Shift","Shift Swap","Double Shift","Holiday","Leave"] },
              late_minutes:          { type: "integer", description: "Required when status = Late" },
              original_shift_id:     { type: "integer", description: "Required for Cross Shift" },
              actual_shift_id:       { type: "integer", description: "Required for Cross Shift" },
              swap_with_employee_id: { type: "integer", description: "Required for Shift Swap" },
              is_double_shift:       { type: "boolean", description: "Set true for Double Shift" },
              second_shift_id:       { type: "integer", description: "Second shift in Double Shift" },
              remarks:               { type: "string" },
              updated_by:            { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Status updated" }
  */
  attendanceController.updateIndividualStatus(req, res);
});


/* ===========================
   ✅ INDIVIDUAL CHECKOUT (by attendance ID)
=========================== */
router.put("/individual/:id/checkout", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Checkout a single employee by attendance record ID'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer', description: 'Attendance record ID' }
    #swagger.requestBody = {
      required: false,
      content: {
        "application/json": {
          schema: {
            type: "object",
            properties: {
              check_out_time: { type: "string", example: "18:00:00" },
              updated_by:     { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Checked out, work_hours and overtime calculated" }
    #swagger.responses[409] = { description: "Already checked out" }
  */
  attendanceController.individualCheckout(req, res);
});



/* ===========================
   ✅ BULK MARK ATTENDANCE
=========================== */
router.post("/bulk/mark", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Bulk mark attendance status for multiple employees'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["employee_ids", "status", "date", "org_id"],
            properties: {
              employee_ids: { type: "array", items: { type: "string" }, description: "Array of employee codes" },
              status:       { type: "string", enum: ["Present","Absent","Late","Half Day","Leave","Cross Shift","Double Shift","Shift Swap"] },
              date:         { type: "string", format: "date" },
              org_id:       { type: "integer" },
              updated_by:   { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Bulk mark result with success/fail counts" }
  */
  attendanceController.bulkMarkAttendance(req, res);
});

/* ===========================
   ✅ BULK CHECKOUT
=========================== */
router.post("/bulk/checkout", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Bulk checkout multiple employees'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["employee_ids", "date", "org_id"],
            properties: {
              employee_ids:   { type: "array", items: { type: "string" }, description: "Array of employee codes" },
              date:           { type: "string", format: "date" },
              checkout_time:  { type: "string", example: "18:00:00", description: "Defaults to current server time" },
              org_id:         { type: "integer" },
              updated_by:     { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Bulk checkout result with work_hours calculated" }
  */
  attendanceController.bulkCheckout(req, res);
});

/* ===========================
   ✅ DAILY RESET
=========================== */
router.post("/daily-reset", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Daily reset — creates Present records for all employees (checks holidays first)'
    #swagger.description = 'Only inserts NEW records for today. Never overwrites existing records. Checks holidays table before setting status.'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.requestBody = {
      required: true,
      content: {
        "application/json": {
          schema: {
            type: "object",
            required: ["org_id"],
            properties: {
              org_id: { type: "integer" }
            }
          }
        }
      }
    }
    #swagger.responses[200] = { description: "Reset result with created/skipped counts" }
  */
  attendanceController.dailyReset(req, res);
});

/* ===========================
   ✅ GET TODAY'S ATTENDANCE
=========================== */
router.get("/today", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = "Get today's attendance grouped by Present / Late / Absent"
    #swagger.description = 'Returns three buckets. Cross Shift, Double Shift, Half Day appear in Present with a badge field. Holiday and Leave appear in other bucket.'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['org_id']   = { in: 'query', required: true,  type: 'integer', description: 'Organization ID' }
    #swagger.parameters['shift_id'] = { in: 'query', required: false, type: 'integer', description: 'Filter by shift (manager shift view)' }
    #swagger.responses[200] = {
      description: "Today attendance bucketed",
      schema: {
        success: true,
        data: {
          present: [],
          late: [],
          absent: [],
          other: [],
          total_employees: 0,
          date: "2024-01-15",
          counts: { present: 0, late: 0, absent: 0, other: 0 }
        }
      }
    }
  */
  attendanceController.getTodayAttendance(req, res);
});

/* ===========================
   ✅ GET ALL ATTENDANCE
=========================== */
router.get("/all", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get all attendance records with filters and pagination'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['page']              = { in: 'query', type: 'integer', default: 1 }
    #swagger.parameters['limit']             = { in: 'query', type: 'integer', default: 10 }
    #swagger.parameters['employee_id']       = { in: 'query', type: 'string',  description: 'Employee code' }
    #swagger.parameters['start_date']        = { in: 'query', type: 'string',  format: 'date' }
    #swagger.parameters['end_date']          = { in: 'query', type: 'string',  format: 'date' }
    #swagger.parameters['shift_type']        = { in: 'query', type: 'string' }
    #swagger.parameters['attendance_status'] = { in: 'query', type: 'string',  enum: ["Present","Absent","Late","Half Day","Cross Shift","Shift Swap","Double Shift","Holiday","Leave"] }
    #swagger.parameters['org_id']            = { in: 'query', type: 'integer' }
  */
  attendanceController.getAttendance(req, res);
});

/* ===========================
   ✅ GET ATTENDANCE SUMMARY
=========================== */
router.get("/summary", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get attendance summary per employee (present/absent/late counts)'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['employee_code'] = { in: 'query', type: 'string' }
    #swagger.parameters['month']         = { in: 'query', type: 'integer', description: '1-12' }
    #swagger.parameters['year']          = { in: 'query', type: 'integer' }
    #swagger.parameters['org_id']        = { in: 'query', type: 'integer' }
  */
  attendanceController.getAttendanceSummary(req, res);
});

/* ===========================
   ✅ GET LATE ATTENDANCE REPORT
=========================== */
router.get("/late-report", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get late attendance report for a date range'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['start_date'] = { in: 'query', type: 'string', format: 'date' }
    #swagger.parameters['end_date']   = { in: 'query', type: 'string', format: 'date' }
    #swagger.parameters['org_id']     = { in: 'query', type: 'integer' }
  */
  attendanceController.getLateAttendanceReport(req, res);
});

/* ===========================
   ✅ GET EMPLOYEES BY SHIFT
=========================== */
router.get("/employees/by-shift", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get all employees in a shift with their attendance status for a date'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['shift_id'] = { in: 'query', required: true,  type: 'integer' }
    #swagger.parameters['org_id']   = { in: 'query', required: true,  type: 'integer' }
    #swagger.parameters['date']     = { in: 'query', required: false, type: 'string', format: 'date', description: 'Defaults to today' }
  */
  attendanceController.getEmployeesByShift(req, res);
});

/* ===========================
   ✅ GET SHIFTS
=========================== */
router.get("/shifts/all", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get all active shifts for an org'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['org_id'] = { in: 'query', required: true, type: 'integer' }
  */
  attendanceController.getShifts(req, res);
});

/* ===========================
   ✅ GET ATTENDANCE BY ID
=========================== */
router.get("/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Get attendance record by ID with full joins'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
  */
  attendanceController.getAttendanceById(req, res);
});



/* ===========================
   ✅ DELETE ATTENDANCE
=========================== */
router.delete("/:id", authenticate, (req, res) => {
  /*
    #swagger.tags = ['Attendance']
    #swagger.summary = 'Soft delete an attendance record'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { in: 'path', required: true, type: 'integer' }
    #swagger.requestBody = {
      required: false,
      content: {
        "application/json": {
          schema: { type: "object", properties: { updated_by: { type: "integer" } } }
        }
      }
    }
  */
  attendanceController.deleteAttendance(req, res);
});


// Add route for debugging
router.get("/debug/shift-assignments", authenticate, attendanceController.debugShiftAssignments);


module.exports = router; 