Development & Utilities

This page documents the development tools, utility functions, file management, and form handling systems that support the Hotelaro platform. It is intended for developers and technical maintainers who need to understand the shared infrastructure and helper mechanisms that underpin the main application modules.

Scope:

For information about the main booking system, see Core Booking System. For system configuration, see Setup & Configuration. For frontend website customization, see Website Builder.

System Overview Diagram

Diagram: "Development & Utilities System Overview"

Form Handling

File Management

JS Utilities

PHP Helpers

Used by

Used by

Handles

Uploads to

Reads

Notification

Notification

app/Helpers/Common_helper.php

app/Views/common_script/formsubmit.php

app/Views/common_script/multifileuploader.php

inc/themes/backend/Admin/Views/toster.php

uploads/

assets/countries_states_cities.json

inc/themes/backend/Admin/Views/submitit.php
    

1. Common Helper Functions

The file app/Helpers/Common_helper.php contains a large set of global helper functions used throughout the application. These functions provide:

Example: Permission Checking

The function permissionvaluecheck($permissionname, $permissiontype) checks if the current user session has a specific permission, based on their role and the permissions stored in the database.

Example: Form Opening with CSRF

The function form_open($action, $attributes, $hidden) generates a form opening tag with CSRF protection automatically included if enabled in the configuration.

Table: Selected Helper Functions

Function Name Purpose Source Line(s)
getInfoById Fetch value by ID from a table 6-16
getInfoByUid Fetch value by admin_uid from a table 19-29
getOrdinalSuffix Get ordinal suffix for a number 32-43
form_open Generate form tag with CSRF 258-313
permissionvaluecheck Check user permission 417-450
emailtemplate Send email with template and placeholders 505-556
tz_list List all timezones with UTC offsets 453-470

Diagram: "Helper Function Usage Mapping"

app/Helpers/Common_helper.php

getInfoById()

getInfoByUid()

form_open()

permissionvaluecheck()

emailtemplate()

tz_list()
    

2. File and Asset Management

2.1 Multi-File Uploader

The JavaScript in app/Views/common_script/multifileuploader.php provides a client-side interface for uploading multiple files (typically images) with preview and removal capabilities. It enforces file count limits and uses AJAX to upload files to the server.

2.2 Asset Storage

Uploaded files are stored in the uploads/ directory. The system expects file metadata (such as file path and ID) to be managed in the database and referenced in the UI.

2.3 Country/State/City Data

The file assets/countries_states_cities.json provides a static dataset for populating country, state, and city dropdowns, used in forms for property setup and guest information.

3. Form Handling and AJAX Submission

3.1 AJAX Form Submission

The script in app/Views/common_script/formsubmit.php enables AJAX-based form submission with CSRF token handling and dynamic feedback using toastr notifications.

3.2 Backend Form Submission Handler

inc/themes/backend/Admin/Views/submitit.php provides a similar AJAX form submission handler for backend forms, with additional UI feedback and error handling.

3.3 CSRF Protection

CSRF tokens are managed via the form_open helper and are included in AJAX requests. The backend validates these tokens on each request.

3.4 Notification System

The notification system uses Toastify.js, as configured in inc/themes/backend/Admin/Views/toster.php, to display success, error, warning, and info messages in a consistent style.

Table: Form Handling Components

Component/File Purpose
formsubmit.php AJAX form submission (frontend)
submitit.php AJAX form submission (backend)
toster.php Toast notification configuration
form_open (helper) Form tag generation with CSRF

Diagram: "Form Handling and Notification Flow"

"toster.php"
"Backend (PHP)"
"formsubmit.php/submitit.php"
"User"
"toster.php"
"Backend (PHP)"
"formsubmit.php/submitit.php"
"User"
alt
[Success]
[Error]
Fill and submit form
Prevent default, append CSRF
AJAX POST (with CSRF)
JSON response (status, message, new CSRF)
toastr.success(message)
Redirect or update UI
toastr.error(message)
Show error, reset button
    

4. Country/State/City Dynamic Dropdowns

The script in app/Views/common_script/allCountryStateCity.php dynamically populates country, state, and city dropdowns using the static JSON file. It supports:

5. Integration with Setup and Configuration

The utilities described here are heavily used in the setup and configuration modules, such as in inc/setup/Basicsetup/Views/content.php, where forms for language, currency, and timezone selection are rendered and submitted using the above helpers and scripts.

Summary

The development and utilities layer in Hotelaro provides a robust foundation for rapid development and consistent user experience across modules. By centralizing helper functions, file management, and form handling, the system ensures maintainability and security.

Key Takeaways: