### Install TimeOff.Management Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/README.md Commands to clone the repository and start the application locally. Requires Node.js (>=4.0.0) and SQLite. ```bash git clone https://github.com/timeoff-management/application.git timeoff-management cd timeoff-management npm install npm start ``` -------------------------------- ### GET /integration/v1/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Verifies that the API authentication is functioning correctly. ```APIDOC ## GET /integration/v1/ ### Description Verifies API authentication is working. ### Method GET ### Endpoint /integration/v1/ ### Response #### Success Response (200) - **ok** (boolean) - Indicates successful authentication. ``` -------------------------------- ### Update Existing Instance Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/README.md Commands to pull the latest code and update the database for an existing installation. ```bash git fetch git pull origin master npm install npm run-script db-update npm start ``` -------------------------------- ### Run Application Tests Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/README.md Command to execute the test suite. Requires Chrome and the Chrome driver to be installed. ```bash USE_CHROME=1 npm test ``` -------------------------------- ### GET /users/?as-csv Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Exports the employee list including allowance data as a CSV file. ```APIDOC ## GET /users/?as-csv ### Description Exports employee list with allowance data as CSV. ### Method GET ### Endpoint /users/?as-csv ### Query Parameters - **as-csv** (flag) - Required - Triggers CSV export format ### Response #### Success Response (200) - **Content-Type** (text/csv) - CSV file with headers: email, lastname, name, department, remaining allowance, days used ``` -------------------------------- ### View Leave Requests (GET /requests/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Retrieves the current user's leave requests and any pending approvals for supervisors. Requires prior authentication to establish a session. ```bash // GET /requests/ // Requires authentication curl -X GET http://localhost:3000/requests/ \ -b cookies.txt ``` -------------------------------- ### GET /integration/v1/report/allowance Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Retrieves employee allowance data for a specified date range, with optional department filtering. ```APIDOC ## GET /integration/v1/report/allowance ### Description Returns employee allowance data for a date range, optionally filtered by department. ### Method GET ### Endpoint /integration/v1/report/allowance ### Parameters #### Query Parameters - **start_date** (string) - Required - Start date of the range - **end_date** (string) - Required - End date of the range - **department** (integer) - Optional - Department ID to filter by ``` -------------------------------- ### Application Configuration Files Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Illustrates the structure of application configuration files, including `config/app.json` for general settings like account creation and email transport, and `config/db.json` for database connection details across different environments. ```json // config/app.json { "allow_create_new_accounts": true, "send_emails": true, "email_transporter": { "host": "smtp.example.com", "port": 587, "auth": { "user": "noreply@example.com", "pass": "smtp_password" } }, "application_sender_email": "noreply@timeoff.management", "crypto_secret": "your-secret-key", "locale_code_for_sorting": "en", "is_force_to_explicitly_select_type_when_requesting_new_leave": false } // Database configuration (config/db.json) { "development": { "dialect": "sqlite", "storage": "./db.development.sqlite" }, "production": { "dialect": "mysql", "host": "localhost", "database": "timeoff", "username": "root", "password": "password" } } ``` -------------------------------- ### POST /users/add/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates a new employee account and sends a welcome email. ```APIDOC ## POST /users/add/ ### Description Creates a new employee account. Sends welcome email with login details. ### Method POST ### Endpoint /users/add/ ### Parameters #### Request Body - **name** (string) - Required - Employee first name - **lastname** (string) - Required - Employee last name - **email_address** (string) - Required - Unique email address - **department** (integer) - Required - Department ID - **start_date** (string) - Required - Employment start date - **end_date** (string) - Optional - Employment end date - **password_one** (string) - Required - Initial password - **password_confirm** (string) - Required - Password confirmation - **admin** (boolean) - Required - Admin privileges - **auto_approve** (boolean) - Required - Auto-approve leave requests ``` -------------------------------- ### Add New Employee Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates a new employee account and triggers a welcome email. ```bash // POST /users/add/ curl -X POST http://localhost:3000/users/add/ \ -b cookies.txt \ -d "name=Jane&lastname=Smith&email_address=jane.smith@company.com&department=1&start_date=2024-01-15&password_one=temppass123&password_confirm=temppass123&admin=false&auto_approve=false" // Parameters: // - name, lastname: Employee name // - email_address: Must be unique across system // - department: Department ID // - start_date: Employment start date // - end_date: Optional employment end date // - password_one, password_confirm: Initial password (not required for LDAP) // - admin: Boolean for admin privileges // - auto_approve: Boolean for auto-approval of leave requests ``` -------------------------------- ### POST /settings/departments/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates a new department with allowance settings. ```APIDOC ## POST /settings/departments/ ### Description Creates a new department with allowance settings. ### Method POST ### Endpoint /settings/departments/ ### Request Body - **name__new** (string) - Required - Department name - **allowance__new** (integer) - Optional - Default annual leave days (0-50) - **boss_id__new** (integer) - Optional - User ID of department head - **include_public_holidays__new** (boolean) - Optional - Include bank holidays in allowance - **is_accrued_allowance__new** (boolean) - Optional - Pro-rate allowance based on start date ``` -------------------------------- ### Create New Migration File Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/docs/migrations.txt Use this command to generate a new migration file. Specify the configuration, model path, and a descriptive name for the migration. ```bash ./node_modules/.bin/sequelize migration:create --config=config/db.json --models-path=lib/model/db/ --name="add_default_date_format" ``` -------------------------------- ### POST /users/import/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Bulk imports employees from a CSV file. ```APIDOC ## POST /users/import/ ### Description Imports employees from CSV file (max 200 per import). ### Method POST ### Endpoint /users/import/ ### Parameters #### Request Body - **users_import** (file) - Required - CSV file containing employee data (email, lastname, name, department) ``` -------------------------------- ### User Model Instance Methods Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Provides methods for interacting with user data, including authentication checks, retrieving user information, and managing relationships like supervisors and managed users. Also includes methods for calculating leave allowances. ```javascript // User instance methods const user = await User.find_by_email('john@company.com'); // Check password const isValid = user.is_my_password('plaintext_password'); // Get full name const name = user.full_name(); // "John Doe" // Check if user is active (no end_date or end_date in future) const active = user.is_active(); // Get users this person can manage const managedUsers = await user.promise_users_I_can_manage(); // Get user's supervisors const supervisors = await user.promise_supervisors(); // Calculate allowance const allowance = await user.promise_allowance({ year: moment.utc() }); // Returns: { // total_number_of_days_in_allowance: 25, // number_of_days_taken_from_allowance: 10, // number_of_days_available_in_allowance: 15 // } ``` -------------------------------- ### Company Registration (POST /register) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates a new company account and an administrator user. Requires 'Content-Type: application/x-www-form-urlencoded'. Sends a confirmation email upon successful registration. ```javascript // POST /register // Content-Type: application/x-www-form-urlencoded const registrationData = { email: 'admin@newcompany.com', name: 'John', lastname: 'Doe', company_name: 'New Company Ltd', password: 'securepassword123', password_confirmed: 'securepassword123', country: 'GB', timezone: 'Europe/London' }; ``` ```bash // cURL example curl -X POST http://localhost:3000/register \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "email=admin@newcompany.com&name=John&lastname=Doe&company_name=New%20Company%20Ltd&password=securepassword123&password_confirmed=securepassword123&country=GB&timezone=Europe/London" ``` -------------------------------- ### Run Pending Migrations Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/docs/migrations.txt Execute this command to apply all pending database migrations. Ensure your configuration and model paths are correctly specified. ```bash ./node_modules/.bin/sequelize db:migrate --config=config/db.json --models-path=lib/model/db/ ``` -------------------------------- ### User Authentication API Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Handles user login and session establishment using local credentials or LDAP. ```APIDOC ## POST /login - User Authentication ### Description Authenticates users via local credentials or LDAP and establishes a session. ### Method POST ### Endpoint /login ### Parameters #### Request Body - **username** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```json { "username": "john.doe@company.com", "password": "secretpassword" } ``` ### Response #### Success Response (200) Redirects to the dashboard page (`/`) upon successful authentication. #### Error Response Redirects to `/login` with a flash error message upon failed authentication. ``` -------------------------------- ### POST /settings/company/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Updates company-wide configuration including timezone, date format, and allowance carryover. ```APIDOC ## POST /settings/company/ ### Description Updates company-wide configuration including timezone, date format, and allowance carryover. ### Method POST ### Endpoint /settings/company/ ### Request Body - **name** (string) - Optional - Company name - **country** (string) - Optional - Country code - **date_format** (string) - Optional - Date format (e.g., YYYY-MM-DD) - **timezone** (string) - Optional - Timezone string - **carry_over** (integer) - Optional - Days of unused allowance to carry to next year (0-20, or 1000 for all) - **share_all_absences** (boolean) - Optional - Allow all employees to see company-wide absences - **is_team_view_hidden** (boolean) - Optional - Hide team view from non-admin users ``` -------------------------------- ### Leave Model Constants and Instance Methods Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Defines constants for leave statuses and day parts, and provides instance methods for managing leave requests, including retrieving deducted days, approving/rejecting, revoking, and canceling leave. ```javascript // Leave status constants Leave.status_new(); // 1 - Pending approval Leave.status_approved(); // 2 - Approved Leave.status_rejected(); // 3 - Rejected Leave.status_pended_revoke(); // 4 - Approved but revoke requested Leave.status_canceled(); // 5 - Canceled by requester // Day part constants Leave.leave_day_part_all(); // 1 - Full day Leave.leave_day_part_morning(); // 2 - Morning half Leave.leave_day_part_afternoon(); // 3 - Afternoon half // Instance methods const leave = await Leave.findById(123); // Get number of days deducted from allowance const days = leave.get_deducted_days_number(); // Approve/reject leave await leave.promise_to_approve({ by_user: supervisor }); await leave.promise_to_reject({ by_user: supervisor }); // Revoke approved leave await leave.promise_to_revoke(); // Cancel pending leave await leave.promise_to_cancel(); ``` -------------------------------- ### Create Department Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Create a new department and set its default annual leave allowance, head of department, and whether to include public holidays. ```javascript // POST /settings/departments/ curl -X POST http://localhost:3000/settings/departments/ \ -b cookies.txt \ -d "name__new=Engineering&allowance__new=25&boss_id__new=1&include_public_holidays__new=true&is_accrued_allowance__new=false" // Parameters: // - allowance: Default annual leave days (0-50) // - boss_id: User ID of department head // - include_public_holidays: Include bank holidays in allowance // - is_accrued_allowance: Pro-rate allowance based on start date ``` -------------------------------- ### Apply Outstanding Migrations Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/docs/migrations.txt Run this command to automatically apply any pending database migrations. ```bash npm run-script db-update ``` -------------------------------- ### Company Registration API Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Enables the creation of new company accounts and initial admin user registration. ```APIDOC ## POST /register - Company Registration ### Description Creates a new company account with an admin user. Validates email uniqueness and sends a registration confirmation email. ### Method POST ### Endpoint /register ### Parameters #### Request Body - **email** (string) - Required - The email address for the admin user. - **name** (string) - Required - The first name of the admin user. - **lastname** (string) - Required - The last name of the admin user. - **company_name** (string) - Required - The name of the company. - **password** (string) - Required - The password for the admin user. - **password_confirmed** (string) - Required - Confirmation of the admin user's password. - **country** (string) - Required - The country code (e.g., 'GB'). - **timezone** (string) - Required - The user's timezone (e.g., 'Europe/London'). ### Request Example ```json { "email": "admin@newcompany.com", "name": "John", "lastname": "Doe", "company_name": "New Company Ltd", "password": "securepassword123", "password_confirmed": "securepassword123", "country": "GB", "timezone": "Europe/London" } ``` ### Response #### Success Response (200) Redirects to the dashboard page (`/`) with the session established. Sends a registration confirmation email to the user. ``` -------------------------------- ### POST /settings/schedule/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Sets company-wide or user-specific working days schedule. ```APIDOC ## POST /settings/schedule/ ### Description Sets company-wide or user-specific working days schedule. Values: 1 = working day, 0 = non-working day. ### Method POST ### Endpoint /settings/schedule/ ### Request Body - **user_id** (integer) - Optional - Specific user ID for individual schedule - **monday** (integer) - Optional - 1 or 0 - **tuesday** (integer) - Optional - 1 or 0 - **wednesday** (integer) - Optional - 1 or 0 - **thursday** (integer) - Optional - 1 or 0 - **friday** (integer) - Optional - 1 or 0 - **saturday** (integer) - Optional - 1 or 0 - **sunday** (integer) - Optional - 1 or 0 ``` -------------------------------- ### POST /settings/departments/edit/:department_id/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Updates department settings or manages supervisors. ```APIDOC ## POST /settings/departments/edit/:department_id/ ### Description Updates department settings or manages supervisors. ### Method POST ### Endpoint /settings/departments/edit/:department_id/ ### Parameters #### Path Parameters - **department_id** (integer) - Required - ID of the department to update ### Request Body - **name** (string) - Optional - Department name - **allowance** (integer) - Optional - Default annual leave days - **boss_id** (integer) - Optional - User ID of department head - **do_add_supervisors** (integer) - Optional - Flag to add supervisors - **supervisor_id** (integer) - Optional - Supervisor ID to add - **remove_supervisor_id** (integer) - Optional - Supervisor ID to remove ``` -------------------------------- ### Retrieve Audit Log Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Fetches a list of audit trail entries for company actions. ```bash // GET /integration/v1/audit/ curl -X GET http://localhost:3000/integration/v1/audit/ \ -H "Authorization: Bearer YOUR_API_TOKEN" // Response: JSON array of audit log entries ``` -------------------------------- ### User Authentication (POST /login) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Authenticates users with local credentials or LDAP. Requires 'Content-Type: application/x-www-form-urlencoded'. Use the `-c` flag with curl to save session cookies. ```javascript // POST /login // Content-Type: application/x-www-form-urlencoded const loginData = { username: 'john.doe@company.com', password: 'secretpassword' }; ``` ```bash // cURL example curl -X POST http://localhost:3000/login \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "username=john.doe@company.com&password=secretpassword" \ -c cookies.txt ``` -------------------------------- ### Bulk Import Employees Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Imports multiple employees from a CSV file, with a limit of 200 records per request. ```bash // POST /users/import/ // Content-Type: multipart/form-data curl -X POST http://localhost:3000/users/import/ \ -b cookies.txt \ -F "users_import=@employees.csv" // CSV format: // email,lastname,name,department // jane@company.com,Smith,Jane,Engineering // bob@company.com,Jones,Bob,Sales ``` -------------------------------- ### POST /settings/bankholidays/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates or updates bank holidays for the company. ```APIDOC ## POST /settings/bankholidays/ ### Description Creates or updates bank holidays for the company. ### Method POST ### Endpoint /settings/bankholidays/ ### Request Body - **year** (integer) - Required - Year of the holiday - **name__X** (string) - Optional - Holiday name - **date__X** (string) - Optional - Date in YYYY-MM-DD format ``` -------------------------------- ### Password Reset Request (POST /forgot-password/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Initiates the password reset process by sending a reset link to the user's email. This endpoint is designed for security best practices and always returns a success message. ```bash // POST /forgot-password/ curl -X POST http://localhost:3000/forgot-password/ \ -d "email=user@company.com" ``` -------------------------------- ### POST /settings/bankholidays/import/ Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Imports default bank holidays for the company's country. ```APIDOC ## POST /settings/bankholidays/import/ ### Description Imports default bank holidays for the company's country. Skips dates that already exist. ### Method POST ### Endpoint /settings/bankholidays/import/ ### Request Body - **year** (integer) - Required - Year to import holidays for ``` -------------------------------- ### Reject Leave Request (POST /requests/reject/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Enables supervisors to reject pending leave requests. The request ID is sent as form data. A notification is sent to the employee upon rejection. ```bash // POST /requests/reject/ curl -X POST http://localhost:3000/requests/reject/ \ -b cookies.txt \ -d "request=123" ``` -------------------------------- ### Retrieve Allowance Report Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Fetches employee allowance data for a specific date range, optionally filtered by department ID. ```bash // GET /integration/v1/report/allowance curl -X GET "http://localhost:3000/integration/v1/report/allowance?start_date=2024-01-01&end_date=2024-12-31&department=5" \ -H "Authorization: Bearer YOUR_API_TOKEN" // Response: { "data": [[ { "userId": 1, "userEmail": "john.doe@company.com", "userLastname": "Doe", "userName": "John", "leaveTypeBreakDown": { "Holiday": 5, "Sick Leave": 2 }, "deductedDays": 7 } ]] } ``` -------------------------------- ### Update Company Settings Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Update company-wide settings such as timezone, date format, and allowance carryover. This endpoint requires administrator privileges. ```javascript // POST /settings/company/ curl -X POST http://localhost:3000/settings/company/ \ -b cookies.txt \ -d "name=Acme%20Corp&country=US&date_format=YYYY-MM-DD&timezone=America/New_York&carry_over=5&share_all_absences=true&is_team_view_hidden=false" // Parameters: // - carry_over: Days of unused allowance to carry to next year (0-20, or 1000 for all) // - share_all_absences: Allow all employees to see company-wide absences // - is_team_view_hidden: Hide team view from non-admin users ``` -------------------------------- ### Update Work Schedule Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Set the company-wide or individual user work schedule by defining working days. Use '1' for working days and '0' for non-working days. ```javascript // POST /settings/schedule/ curl -X POST http://localhost:3000/settings/schedule/ \ -b cookies.txt \ -d "monday=1&tuesday=1&wednesday=1&thursday=1&friday=1&saturday=0&sunday=0" // For user-specific schedule, add user_id: curl -X POST http://localhost:3000/settings/schedule/ \ -b cookies.txt \ -d "user_id=5&monday=1&tuesday=1&wednesday=1&thursday=1&friday=0&saturday=0&sunday=0" // Values: 1 = working day, 0 = non-working day ``` -------------------------------- ### Approve Leave Request (POST /requests/approve/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Allows supervisors to approve pending leave requests. Requires 'Content-Type: application/x-www-form-urlencoded' and the leave request ID. Triggers an email notification to the requester. ```bash // POST /requests/approve/ // Content-Type: application/x-www-form-urlencoded curl -X POST http://localhost:3000/requests/approve/ \ -b cookies.txt \ -d "request=123" ``` -------------------------------- ### Manage Leave Types Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Create or update different types of leave, such as 'Holiday' or 'Sick Leave'. You can configure whether they deduct from allowance and if they require approval. ```javascript // POST /settings/leavetypes curl -X POST http://localhost:3000/settings/leavetypes \ -b cookies.txt \ -d "name__new=Working%20From%20Home&color__new=leave_type_color_3&use_allowance__new=false&limit__new=0&auto_approve__new=true" // Parameters per leave type (suffix with ID or 'new'): // - name__X: Leave type name // - color__X: CSS class for calendar color (leave_type_color_1 through leave_type_color_10) // - use_allowance__X: Boolean - deduct from annual allowance // - limit__X: Maximum days per year (0 = unlimited) // - auto_approve__X: Boolean - skip supervisor approval ``` -------------------------------- ### Export Employees as CSV Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Use this endpoint to export a CSV file containing employee list and their allowance data. Ensure you have the necessary cookies for authentication. ```javascript // GET /users/?as-csv curl -X GET "http://localhost:3000/users/?as-csv" \ -b cookies.txt \ -o employees_export.csv // Response: CSV file with headers: // email,lastname,name,department,remaining allowance,days used ``` -------------------------------- ### Generate iCal Calendar Feed Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Provides an iCal feed for external calendar applications using a user-specific token. ```bash // GET /feed/:token/ical.ics // Token is user-specific feed token (no authentication required) curl -X GET "http://localhost:3000/feed/abc123def456/ical.ics" // Response: iCal format calendar // BEGIN:VCALENDAR // VERSION:2.0 // PRODID:-//timeoff.management//ical-generator//EN // NAME:John Doe's team whereabout // ... // BEGIN:VEVENT // DTSTART:20240115T090000Z // DTEND:20240115T170000Z // SUMMARY:John Doe is OOO (out of office) // END:VEVENT // END:VCALENDAR ``` -------------------------------- ### Update Employee Details Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Modifies existing employee information, including department and allowance adjustments. ```bash // POST /users/edit/5/ curl -X POST http://localhost:3000/users/edit/5/ \ -b cookies.txt \ -d "name=Jane&lastname=Smith-Jones&email_address=jane.smith@company.com&department=2&adjustment=2.5&admin=false&auto_approve=true" // adjustment: Days to add/subtract from annual allowance ``` -------------------------------- ### Password Reset API Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Initiates the password reset process by sending a reset link via email. ```APIDOC ## POST /forgot-password/ - Password Reset Request ### Description Initiates the password reset flow by sending a reset link via email. ### Method POST ### Endpoint /forgot-password/ ### Parameters #### Request Body - **email** (string) - Required - The email address of the user requesting a password reset. ### Request Example ```json { "email": "user@company.com" } ``` ### Response #### Success Response (200) Always shows a success message for security best practices. If the email exists in the system, a password reset email with a token link is sent to the user. ``` -------------------------------- ### POST /settings/leavetypes Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Creates or updates leave types such as Holiday or Sick Leave. ```APIDOC ## POST /settings/leavetypes ### Description Creates or updates leave types (Holiday, Sick Leave, etc.). Parameters are suffixed with an ID or 'new'. ### Method POST ### Endpoint /settings/leavetypes ### Request Body - **name__X** (string) - Optional - Leave type name - **color__X** (string) - Optional - CSS class for calendar color (leave_type_color_1 through leave_type_color_10) - **use_allowance__X** (boolean) - Optional - Deduct from annual allowance - **limit__X** (integer) - Optional - Maximum days per year (0 = unlimited) - **auto_approve__X** (boolean) - Optional - Skip supervisor approval ``` -------------------------------- ### Leave Request Management APIs Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt APIs for viewing, approving, rejecting, canceling, and revoking leave requests. ```APIDOC ## GET /requests/ - View Leave Requests ### Description Displays the current user's leave requests and pending approvals for supervisors. ### Method GET ### Endpoint /requests/ ### Response #### Success Response (200) Returns an HTML page containing: - `my_leaves_grouped`: The user's own leave requests, grouped by status. - `to_be_approved_leaves`: Leave requests pending supervisor approval. ``` ```APIDOC ## POST /requests/approve/ - Approve Leave Request ### Description Allows supervisors to approve pending leave requests. Triggers notification emails to the requester. ### Method POST ### Endpoint /requests/approve/ ### Parameters #### Request Body - **request** (integer) - Required - The ID of the leave request to approve. ### Request Example ```json { "request": 123 } ``` ### Response #### Success Response (200) Redirects to the `/requests/` page with a confirmation flash message. Triggers an email notification to the employee. ``` ```APIDOC ## POST /requests/reject/ - Reject Leave Request ### Description Allows supervisors to reject pending leave requests, with a notification sent to the requester. ### Method POST ### Endpoint /requests/reject/ ### Parameters #### Request Body - **request** (integer) - Required - The ID of the leave request to reject. ### Request Example ```json { "request": 123 } ``` ### Response #### Success Response (200) Redirects to the `/requests/` page with a confirmation flash message. ``` ```APIDOC ## POST /requests/cancel/ - Cancel Own Leave Request ### Description Allows employees to cancel their own pending leave requests that have not yet been approved. ### Method POST ### Endpoint /requests/cancel/ ### Parameters #### Request Body - **request** (integer) - Required - The ID of the leave request to cancel. ### Request Example ```json { "request": 123 } ``` ### Response #### Success Response (200) Redirects to the `/requests/` page with a confirmation message. This action is only possible for leave requests in the 'new' status. ``` ```APIDOC ## POST /requests/revoke/ - Revoke Approved Leave ### Description Allows a user to request the revocation of a previously approved leave. This may require supervisor approval. ### Method POST ### Endpoint /requests/revoke/ ### Parameters #### Request Body - **request** (integer) - Required - The ID of the approved leave request to revoke. ### Request Example ```json { "request": 123 } ``` ### Response #### Success Response (200) The leave request status changes to 'pended_revoke'. If the user has the 'auto_approve' flag enabled, the revocation is automatically approved. Notifications are sent to the supervisor and the requester. ``` -------------------------------- ### Retrieve User Notifications Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Fetches pending notifications for the currently authenticated user using session cookies. ```bash // GET /api/v1/notifications/ curl -X GET http://localhost:3000/api/v1/notifications/ \ -b cookies.txt // Response: { "data": [ { "type": "pending_request", "numberOfRequests": 3, "label": "3 leave requests to process", "link": "/requests/" } ] } ``` -------------------------------- ### Update Department Settings Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Modify existing department details, such as name, allowance, or head of department. This endpoint also allows for managing supervisors by adding or removing them. ```javascript // Update department details curl -X POST http://localhost:3000/settings/departments/edit/3/ \ -b cookies.txt \ -d "name=Engineering%20Team&allowance=28&boss_id=2&include_public_holidays=true" // Add secondary supervisors curl -X POST http://localhost:3000/settings/departments/edit/3/ \ -b cookies.txt \ -d "do_add_supervisors=1&supervisor_id=5&supervisor_id=7" // Remove a supervisor curl -X POST http://localhost:3000/settings/departments/edit/3/ \ -b cookies.txt \ -d "remove_supervisor_id=5" ``` -------------------------------- ### Email Notification Methods Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Utilizes the EmailTransport class to send various notification emails, including leave request notifications, approval/rejection decisions, password resets, and new user welcome emails. Requires appropriate objects like leave, user, company, and admin details. ```javascript const EmailTransport = require('./lib/email'); const email = new EmailTransport(); // Send leave request notification await email.promise_leave_request_emails({ leave: leaveObject // Leave with user, approver, and leave_type loaded }); // Send approval/rejection notification await email.promise_leave_request_decision_emails({ leave: leaveObject, action: 'approve', // or 'reject' was_pended_revoke: false }); // Send password reset email await email.promise_forgot_password_email({ user: userObject }); // Send new user welcome email await email.promise_add_new_user_email({ company: companyObject, admin_user: adminObject, new_user: newUserObject }); ``` -------------------------------- ### Add new colour option to picker Source: https://github.com/timeoff-management/timeoff-management-application/blob/master/docs/extend_colors_for_leave_type.md Add a new list item to the colour picker partial, replacing X with the next sequential integer. ```handlebars
  • Color X
  • ``` -------------------------------- ### Verify API Health Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Checks API authentication status using a Bearer token. ```bash // GET /integration/v1/ // Requires Bearer token authentication curl -X GET http://localhost:3000/integration/v1/ \ -H "Authorization: Bearer YOUR_API_TOKEN" // Response: { "ok": true } ``` -------------------------------- ### Manage Bank Holidays Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Add new bank holidays or update existing ones by providing the year, name, and date. Existing holidays can be updated by referencing their ID. ```javascript // POST /settings/bankholidays/ curl -X POST http://localhost:3000/settings/bankholidays/ \ -b cookies.txt \ -d "year=2024&name__new=Company%20Anniversary&date__new=2024-06-15" // Update existing bank holiday (by ID): curl -X POST http://localhost:3000/settings/bankholidays/ \ -b cookies.txt \ -d "name__42=New%20Year%20Day&date__42=2024-01-01" ``` -------------------------------- ### Retrieve Absence Report Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Retrieves detailed absence records for employees within a specified date range. ```bash // GET /integration/v1/report/absence curl -X GET "http://localhost:3000/integration/v1/report/absence?start_date=2024-01-01&end_date=2024-03-31" \ -H "Authorization: Bearer YOUR_API_TOKEN" // Response: JSON with user leave details for the period ``` -------------------------------- ### Cancel Own Leave Request (POST /requests/cancel/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Allows employees to cancel their own leave requests that are in a 'new' status. The request ID is submitted via form data. ```bash // POST /requests/cancel/ curl -X POST http://localhost:3000/requests/cancel/ \ -b cookies.txt \ -d "request=123" ``` -------------------------------- ### Import Country Bank Holidays Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Import default bank holidays for the company's country for a specified year. This operation will skip dates that already exist in the system. ```javascript // POST /settings/bankholidays/import/ curl -X POST http://localhost:3000/settings/bankholidays/import/ \ -b cookies.txt \ -d "year=2024" // Response: Creates bank holidays from country configuration // Skips dates that already exist ``` -------------------------------- ### Revoke Approved Leave (POST /requests/revoke/) Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Initiates the process to revoke an already approved leave request. The request ID is sent as form data. This may require supervisor approval and sends notifications. ```bash // POST /requests/revoke/ curl -X POST http://localhost:3000/requests/revoke/ \ -b cookies.txt \ -d "request=123" ``` -------------------------------- ### Delete Employee Source: https://context7.com/timeoff-management/timeoff-management-application/llms.txt Removes an employee and their associated leave records, excluding admins and supervisors. ```bash // POST /users/delete/5/ curl -X POST http://localhost:3000/users/delete/5/ \ -b cookies.txt // Response: Redirects to /users/ with confirmation // Creates audit trail entry for deletion ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.