diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..87643113d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,225 @@ +# AGENTS.md + +## Project Overview + +QloApps is an open-source hotel reservation and property management platform. It enables hotels to manage rooms, bookings, guests, and payments through a web-based system. + +## Purpose of this File + +This document provides guidance for AI coding agents contributing to the QloApps project. It defines conventions, safety rules, and workflows to ensure consistent and secure code generation. + +## Technology Stack + +- **Language:** PHP 8.1–8.4 (backend), Smarty 3.x (templates), JavaScript/jQuery (frontend) +- **Database:** MySQL 5.7, 8.0+; MariaDB 10.5, 10.6, 10.11, 11.0, 11.2, 11.4 +- **Architecture:** MVC with hook-based module system +- **License:** OSL-3.0 (core), AFL-3.0 (modules) +- **Required PHP Extensions:** PDO_MySQL, cURL, OpenSSL, SOAP, GD, SimpleXML, DOM, Zip, Phar + +## Environment Setup + +Install dependencies: +```bash +composer install +``` + +Clear caches: +```bash +rm -rf cache/smarty/compile/* cache/smarty/cache/* +rm -f cache/class_index.php +``` + +Clear class cache after adding or modifying overrides. + +## Project Structure + +``` +. +├── classes/ # Core models extending ObjectModel +├── controllers/ # Front and admin controllers +│ ├── admin/ +│ └── front/ +├── modules/ # Feature modules with isolated functionality +├── override/ # Core class and controller overrides +├── themes/ # Smarty templates (.tpl files) +├── config/ # Configuration files (settings.inc.php contains secrets) +├── cache/ # Generated cache files +├── tests/ # PHPUnit test suite +``` + +**QloApps Agent Skills:** Install reusable development skills using: +```bash +npx skills add Qloapps/agent-skills +``` +Available skills: module-development, payment-module-development, stats-module-development. Check installed skills before implementing new functionality. + +## Architecture Overview + +**MVC Pattern** +- Models: classes/ extending ObjectModel +- Controllers: FrontController or AdminController +- Views: Smarty templates (.tpl) + +**Modules** +- Located in modules// +- Provide isolated functionality +- Integrate using hooks + +**Overrides** +- Located in override/ +- Extend core classes using the Core suffix +- Clear class cache after creating overrides + +**Context** +- Access runtime objects using Context::getContext() + +## Core vs Module Development Rules + +**When working on a module:** +1. Never modify core files directly +2. Use **hooks** to integrate module functionality into core features +3. If no suitable hook exists, create a **custom hook** — but only if the hook placement is generic and useful for other modules too +4. Use **overrides** only as a last resort — overrides can conflict with other module override files and require manual resolution + +**When working on a core feature:** +- Make changes directly in core files +- Do not use hooks or overrides for core-to-core changes + +## Coding Conventions + +**Classes:** PascalCase — `HotelBookingData` +**Methods:** camelCase — `getBookingDetails()` +**Variables:** camelCase — `$hotelId` +**Constants:** UPPER_SNAKE_CASE — `BOOKING_STATUS_CONFIRMED` +**Database Tables:** _DB_PREFIX_ + lowercase_snake — `qlo_hotel_booking` +**Config Keys:** MODULENAME_SETTING — `HOTELRESERVATION_ENABLED` +**Files:** One class per file, filename matches class name +**Templates:** lowercase-hyphens.tpl — `booking-form.tpl` + +Add PHPDoc blocks to all classes and methods. + +## Translation + +Never hardcode user-facing English strings — always wrap them in the appropriate translation method. + +| Context | Method | +|---------|--------| +| Module main file | `$this->l('string')` | +| Module admin controller | `$this->l('string')` | +| Module front controller | `$this->module->l('string', 'controllerName')` | +| Module classes | `$objModule->l('string', 'ClassName')` | +| Core admin controller | `$this->l('string')` | +| Core front controller | `Tools::displayError('string')` | +| Smarty template (core) | `{l s='string'}` | +| Smarty template (module) | `{l s='string' mod='modulename'}` | + +## Multi-language + +- Always include `id_lang` in queries that return translatable content +- Use `Context::getContext()->language->id` for the current language + +## Module Development Guidelines + +**Module Location:** modules// + +**Required Files:** +- .php — Main class extending Module +- config.xml — Module metadata + +**Optional Directories:** +- classes/ — Module-specific models +- controllers/ — Module controllers +- views/templates/ — Smarty templates +- upgrade/ — Version migration scripts + +**Hook Integration:** +- Register hooks in install() method +- Unregister hooks in uninstall() method +- Keep hook handlers lightweight + +**Configuration:** +- Store settings using Configuration::updateValue() +- Retrieve settings using Configuration::get() +- Prefix config keys with module name + +## Database Rules + +**Table Prefix:** Always use _DB_PREFIX_ constant instead of hardcoding the table prefix + +**Escaping:** +- Strings: pSQL($value) +- Integers: (int)$value +- Table/column names: bqSQL($name) + +**Preferred Access:** Use ObjectModel for CRUD operations instead of raw SQL queries + +**Prohibited:** Never concatenate raw user input into SQL queries. + +## Security Guidelines + +**Input Handling** +- Use Tools::getValue() for request parameters +- Cast numeric values to (int) +- Escape strings using pSQL() +- Validate input using Validate class methods + +**Output Escaping** +- Use Tools::safeOutput() in PHP +- Use Smarty escape modifiers in templates + +**Sensitive Data** +- Never expose config/settings.inc.php +- Never commit API keys, passwords, or tokens + +**Authorization** +- Verify permissions before performing admin operations + +## Testing + +Testing infrastructure is being configured. Check tests/ directory for available tests before running. + +## AI Agent Workflow + +1. Check installed agent skills before implementing new functionality +2. Search codebase for similar implementations before creating new code +3. Extend existing classes rather than duplicating functionality +4. Follow patterns established in surrounding code +5. Reuse existing utilities: Tools, Validate, Db, Configuration classes +6. Prioritize consistency with existing codebase over new approaches + +After making changes: +- Clear caches if modifying templates or overrides +- Add PHPDoc to new methods + +## Safety Rules + +**Agents must not:** +- Delete files unless explicitly instructed +- Run git commands automatically +- Modify composer.json without approval +- Modify config/settings.inc.php +- Execute DROP, TRUNCATE, or destructive SQL +- Modify core files directly when working on a module (use hooks or override system) + +**Agents must:** +- Use pSQL() for strings and (int) for IDs in SQL +- Use Tools::getValue() for request parameters +- Escape all output +- Check installed agent skills before implementing new functionality +- Follow project naming conventions +- Validate inputs before processing + +**Agents should ask before:** +- Deleting any files +- Running git commands +- Changing dependencies +- Modifying database schema +- Altering payment or booking logic + +--- + +**Resources:** +- Documentation: https://docs.qloapps.com +- Forum: https://forums.qloapps.com +- GitHub: https://github.com/Qloapps/QloApps +- Security Issues: support@qloapps.com diff --git a/admin/themes/default/sass/partials/_date-picker.sass b/admin/themes/default/sass/partials/_date-picker.sass index e864cf8e9..dd235e7ad 100644 --- a/admin/themes/default/sass/partials/_date-picker.sass +++ b/admin/themes/default/sass/partials/_date-picker.sass @@ -30,324 +30,330 @@ $color-calendar-range: lighten($color-calendar,10%) $color-calendar-range-compare: lighten($color-calendar-compare,10%) .datepicker2 - background: #fff - position: absolute - z-index: 599 - right: -10rem - .daterangepicker - border-radius: 5px 5px 0 0 !important + background: #fff + position: absolute + z-index: 599 + right: -10rem + .daterangepicker + border-radius: 5px 5px 0 0 !important .bootstrap - #datepicker - .daterangepicker - position: relative - width: 100% - font-family: Verdana, Arial, sans-serif - font-size: 13px - box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.26) - margin-bottom: 8px - padding: 12px - border-bottom-left-radius: 0 - border-bottom-right-radius: 0 - table - width: 100% - margin: 0 - border-spacing: 1px - thead - tr th - text-transform: uppercase - text-align: center - font-weight: bold - border: 0 - background-color: #fff !important - color: #777 !important - font-size: 14px - tr:first-child th - padding-bottom: 10px - text-transform: capitalize - .icon-angle-left - font-weight: bold - padding-left: 6px - &:after - content: '' - position: absolute - top: -5px - left: -2px - width: 24px - height: 24px - background-color: #f0f0f0 - z-index: -1 - border-radius: 50% - .icon-angle-right - font-weight: bold - padding-right: 6px - &:after - content: '' - position: absolute - top: -5px - right: -2px - width: 24px - height: 24px - background-color: #f0f0f0 - z-index: -1 - border-radius: 50% - td, th - text-align: center - padding: 0 - position: relative - tr - border-bottom: solid 1px white - td - color: #555 - font-size: 14px - line-height: 25px - padding: 5px 10px - &.day:after - content: "" - position: absolute - display: block - top: 0 - width: 100% - z-index: 0 - background-color: transparent - @include left(0) - &.day:hover - cursor: pointer - color: #212121 - &.day.disabled - color: $color-calendar-outrange - &.old, &.new - color: $color-calendar-outrange - &.start-selected:not(.old):not(.new):not(.end-selected) - color: $color-bright - background-color: #1292ff - //@extend .chevron-left - &.range-compare - background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) - @include border-left-radius(0) - &.end-selected-compare, &.start-selected-compare - background-color: mix($color-calendar-day-selected,$color-calendar-day-selected-compare,70%) - &.end-selected-compare - @include border-radius(0) - &.end-selected:not(.old):not(.new):not(.start-selected) - color: $color-bright - background-color: #1292ff - //@extend .chevron-right - &.range-compare - background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) - @include border-right-radius(0) - &.end-selected-compare, &.start-selected-compare - background-color: mix($color-calendar-day-selected,$color-calendar-day-selected-compare,70%) - &.start-selected-compare - @include border-radius(0) - &.start-selected-compare:not(.old):not(.new):not(.end-selected-compare) - color: $color-bright - font-weight: 700 - background-color: $color-calendar-day-selected-compare - @include border-left-radius(15px) - &.range - background-color: #f2f2f2 - @include border-left-radius(0) - &.end-selected-compare:not(.old):not(.new):not(.start-selected-compare) - color: $color-bright - font-weight: 700 - background-color: $color-calendar-day-selected-compare - @include border-right-radius(15px) - &.range - background-color: #f2f2f2 - @include border-right-radius(0) - &.end-selected.start-selected - color: $color-bright - font-weight: 700 - background-color: $color-calendar-day-selected - &.range-compare - background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) - @include border-radius(0) - &.end-selected-compare.start-selected-compare - color: $color-bright - @include border-radius(15px) - font-weight: 700 - background-color: $color-calendar-day-selected-compare - &.range - background-color: mix($color-calendar-day-selected-compare,$color-calendar-range,70%) - @include border-radius(0) - &.range - color: #333 - background-color: #f2f2f2 - &.range-compare - background-color: mix($color-calendar-range,$color-calendar-range-compare,50%) - &.range-compare - color: lighten($color-calendar-range-compare,35%) - background-color: $color-calendar-range-compare - &.range - background-color: mix($color-calendar-range,$color-calendar-range-compare,50%) - &.today - background-color: $color-bright - span - padding: 0 - display: block - width: 33.333% - height: 3em - line-height: 3em - font-weight: 400 - float: left - text-transform: uppercase - cursor: pointer - &:hover - color: white - background-color: $color-calendar-day-selected - &.active - background-color: $color-calendar-day-selected - color: #fff - &.old - color: $color-calendar-outrange - th - &.next - @include text-align(right) - &.prev - @include text-align(left) - &.next, &.prev, &.month-switch - font-size: 16px !important - font-weight: normal - color: #333 !important - &:hover - opacity: 0.8 - thead tr:first-child th - cursor: pointer + #datepicker + .daterangepicker + position: relative + width: 100% + font-family: Verdana, Arial, sans-serif + font-size: 13px + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.26) + margin-bottom: 8px + padding: 12px + border-bottom-left-radius: 0 + border-bottom-right-radius: 0 + table + width: 100% + margin: 0 + border-spacing: 1px + thead + tr th + text-transform: uppercase + text-align: center + font-weight: bold + border: 0 + background-color: #fff !important + color: #777 !important + font-size: 14px + tr:first-child th + padding-bottom: 10px + text-transform: capitalize + .icon-angle-left + font-weight: bold + padding-left: 6px + &:after + content: '' + position: absolute + top: -5px + left: -2px + width: 24px + height: 24px + background-color: #f0f0f0 + z-index: -1 + border-radius: 50% + .icon-angle-right + font-weight: bold + padding-right: 6px + &:after + content: '' + position: absolute + top: -5px + right: -2px + width: 24px + height: 24px + background-color: #f0f0f0 + z-index: -1 + border-radius: 50% + td, th + text-align: center + padding: 0 + position: relative + tr + border-bottom: solid 1px white + td + color: #555 + font-size: 14px + line-height: 25px + padding: 5px 10px + &.day:after + content: "" + position: absolute + display: block + top: 0 + width: 100% + z-index: 0 + background-color: transparent + @include left(0) + &.day:hover + cursor: pointer + color: #212121 + &.day.disabled + color: $color-calendar-outrange + &.old, &.new + color: $color-calendar-outrange + &.start-selected:not(.old):not(.new):not(.end-selected) + color: $color-bright + background-color: #1292ff + //@extend .chevron-left + &.range-compare + background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) + @include border-left-radius(0) + &.end-selected-compare, &.start-selected-compare + background-color: mix($color-calendar-day-selected,$color-calendar-day-selected-compare,70%) + &.end-selected-compare + @include border-radius(0) + &.end-selected:not(.old):not(.new):not(.start-selected) + color: $color-bright + background-color: #1292ff + //@extend .chevron-right + &.range-compare + background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) + @include border-right-radius(0) + &.end-selected-compare, &.start-selected-compare + background-color: mix($color-calendar-day-selected,$color-calendar-day-selected-compare,70%) + &.start-selected-compare + @include border-radius(0) + &.start-selected-compare:not(.old):not(.new):not(.end-selected-compare) + color: $color-bright + font-weight: 700 + background-color: $color-calendar-day-selected-compare + @include border-left-radius(15px) + &.range + background-color: #f2f2f2 + @include border-left-radius(0) + &.end-selected-compare:not(.old):not(.new):not(.start-selected-compare) + color: $color-bright + font-weight: 700 + background-color: $color-calendar-day-selected-compare + @include border-right-radius(15px) + &.range + background-color: #f2f2f2 + @include border-right-radius(0) + &.end-selected.start-selected + color: $color-bright + font-weight: 700 + background-color: $color-calendar-day-selected + &.range-compare + background-color: mix($color-calendar-day-selected,$color-calendar-range-compare,70%) + @include border-radius(0) + &.end-selected-compare.start-selected-compare + color: $color-bright + @include border-radius(15px) + font-weight: 700 + background-color: $color-calendar-day-selected-compare + &.range + background-color: mix($color-calendar-day-selected-compare,$color-calendar-range,70%) + @include border-radius(0) + &.range + color: #333 + background-color: #f2f2f2 + &.range-compare + background-color: mix($color-calendar-range,$color-calendar-range-compare,50%) + &.range-compare + color: lighten($color-calendar-range-compare,35%) + background-color: $color-calendar-range-compare + &.range + background-color: mix($color-calendar-range,$color-calendar-range-compare,50%) + &.today + background-color: $color-bright + span + padding: 0 + display: block + width: 33.333% + height: 3em + line-height: 3em + font-weight: 400 + float: left + text-transform: uppercase + cursor: pointer + &:hover + color: white + background-color: $color-calendar-day-selected + &.active + background-color: $color-calendar-day-selected + color: #fff + &.old + color: $color-calendar-outrange + th + &.next + @include text-align(right) + &.prev + @include text-align(left) + &.next, &.prev, &.month-switch + font-size: 16px !important + font-weight: normal + color: #333 !important + &:hover + opacity: 0.8 + thead tr:first-child th + cursor: pointer .ui-datepicker - margin: 5px auto 0 - width: auto !important - z-index: 111111 !important - top: 0 - left: 0 - padding: 12px !important - margin-top: 1px - @include border-radius(4px) - .ui-datepicker-header - background: none - border: none - color: gray - font-weight: normal - .ui-datepicker-title - color: #333 - font-size: 16px - font-style: normal - th - font-size: 12px - font-weight: 600 - color: #777 - text-transform: uppercase - tbody - td - &:last-child - border-right: 0px - tr - border-bottom: 1px solid #bbb - border: none - &:last-child - border-bottom: 0px - a - text-decoration: none - .ui-state-highlight - border: solid 1px darken(#FEFBE2 ,50%) !important - background: #FEFBE2 !important - .ui-datepicker-today - background: #e7f4ff !important - .ui-state-highlight - color: #1292ff !important - .ui-datepicker-current-day, .ui-datepicker-today.ui-datepicker-current-day - background-color: #1292ff !important - .ui-datepicker-current-day, .ui-datepicker-today.ui-datepicker-current-day .ui-state-highlight - color: #fff !important - .ui-state-active - color: white !important - background: $primary-color !important - border: solid 1px darken($primary-color,10%) !important - .ui-datepicker-prev-hover - left: 2px !important + margin: 5px auto 0 + width: auto !important + z-index: 111111 !important + top: 0 + left: 0 + padding: 12px !important + margin-top: 1px + @include border-radius(4px) + .ui-datepicker-header + background: none + border: none + color: gray + font-weight: normal + .ui-datepicker-title + color: #333 + font-size: 16px + font-style: normal + th + font-size: 12px + font-weight: 600 + color: #777 + text-transform: uppercase + tbody + td + &:last-child + border-right: 0px + tr + border-bottom: 1px solid #bbb + border: none + &:last-child + border-bottom: 0px + a + text-decoration: none + .ui-state-highlight + border: solid 1px darken(#FEFBE2 ,50%) !important + background: #FEFBE2 !important + .ui-datepicker-today + background: #e7f4ff !important + .ui-state-highlight + color: #1292ff !important + .ui-datepicker-current-day, .ui-datepicker-today.ui-datepicker-current-day + background-color: #1292ff !important + .ui-datepicker-current-day, .ui-datepicker-today.ui-datepicker-current-day .ui-state-highlight + color: #fff !important + .ui-state-active + color: white !important + background: $primary-color !important + border: solid 1px darken($primary-color,10%) !important + .ui-datepicker-prev-hover + left: 2px !important .form-date-actions .btn:hover, .form-date-actions .btn:focus, .form-date-actions .btn:active - outline: unset !important - text-decoration: none + outline: unset !important + text-decoration: none .form-date-actions - bottom: -27px - position: absolute - width: 100% - z-index: 599 - background-color: #fff - box-shadow: 0 7px 10px 0 rgba(0,0,0,0.26) - padding: 2px - border-bottom-left-radius: 4px - border-bottom-right-radius: 4px + bottom: -27px + position: absolute + width: 100% + z-index: 599 + background-color: #fff + box-shadow: 0 7px 10px 0 rgba(0,0,0,0.26) + padding: 2px + border-bottom-left-radius: 4px + border-bottom-right-radius: 4px .ui-datepicker-prev - float: left - cursor: pointer - &::before - background-position: center -30px - font-weight: bold - font-size: 16px - color: #333 - content: "\f104" - font-family: FontAwesome - position: absolute - left: 8px + float: left + cursor: pointer + &::before + background-position: center -30px + font-weight: bold + font-size: 16px + color: #333 + content: "\f104" + font-family: FontAwesome + position: absolute + left: 8px .ui-datepicker-next - float: right - cursor: pointer - &::before - background-position: center -30px - font-weight: bold - font-size: 16px - color: #333 - content: "\f105" - font-family: FontAwesome - position: absolute - right: 8px - &:hover - top: 5px !important - right: 2px !important + float: right + cursor: pointer + &::before + background-position: center -30px + font-weight: bold + font-size: 16px + color: #333 + content: "\f105" + font-family: FontAwesome + position: absolute + right: 8px + &:hover, &.ui-datepicker-next-hover + top: 5px !important + right: 2px !important + +.ui-datepicker-rtl + .ui-datepicker-next + &:hover, &.ui-datepicker-next-hover + left: 2px !important + right: auto !important .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus - border: unset - background: none - font-weight: none - color: none + border: unset + background: none + font-weight: none + color: none .ui-widget-content.ui-datepicker - border: none - box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.26) + border: none + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.26) .ui-datepicker td span, .ui-datepicker td a - display: inline-block - text-align: center - line-height: 25px - color: #ffffff + display: inline-block + text-align: center + line-height: 25px + color: #ffffff .ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next - top: 5px !important - background-color: #f0f0f0 - border: none - border-radius: 50% + top: 5px !important + background-color: #f0f0f0 + border: none + border-radius: 50% .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default - border: none !important - background: transparent !important - font-size: 14px - color: #333 + border: none !important + background: transparent !important + font-size: 14px + color: #333 .ui-widget-content - .ui-icon - background-image: none !important + .ui-icon + background-image: none !important .ui-datepicker td span, .ui-datepicker td a - text-align: center !important - padding: 4px 9px !important + text-align: center !important + padding: 4px 9px !important .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus - background: unset !important - border: unset !important + background: unset !important + border: unset !important .ui-widget-content .ui-slider-handle, .ui-datepicker-current .ui-slider-handle - border: 1px solid #d3d3d3 !important - color: #555555 !important - background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) !important + border: 1px solid #d3d3d3 !important + color: #555555 !important + background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) !important .ui-datepicker-prev-hover - top: unset !important \ No newline at end of file + top: unset !important diff --git a/admin/themes/default/sass/partials/_date-range-picker.sass b/admin/themes/default/sass/partials/_date-range-picker.sass index 812aadf72..b63956a92 100644 --- a/admin/themes/default/sass/partials/_date-range-picker.sass +++ b/admin/themes/default/sass/partials/_date-range-picker.sass @@ -16,9 +16,9 @@ $color-calendar-range-compare: lighten($color-calendar-compare,10%) #datepicker .input-selected margin: 0 - #date-start.input-selected, #date-end.input-selected, + #date-start.input-selected, #date-end.input-selected border: solid 3px $color-calendar-day-selected - #date-start-compare.input-selected, #date-end-compare.input-selected, + #date-start-compare.input-selected, #date-end-compare.input-selected border: solid 3px $color-calendar-day-selected-compare div#datepicker-form #date-range diff --git a/admin/themes/default/sass/partials/_growl.sass b/admin/themes/default/sass/partials/_growl.sass index 37884b1bc..900f51ac3 100644 --- a/admin/themes/default/sass/partials/_growl.sass +++ b/admin/themes/default/sass/partials/_growl.sass @@ -8,72 +8,72 @@ $namespace: "growl" $duration: 0.4s #growls - z-index: 50000 - position: fixed - - &.default - top: 100px - @include right(10px) - &.tl - top: 10px - @include left(10px) - &.tr - top: 10px - @include right(10px) - &.bl - bottom: 10px - @include left(10px) - &.br - bottom: 10px - @include right(10px) + z-index: 50000 + position: fixed + + &.default + top: 100px + @include right(10px) + &.tl + top: 10px + @include left(10px) + &.tr + top: 10px + @include right(10px) + &.bl + bottom: 10px + @include left(10px) + &.br + bottom: 10px + @include right(10px) .growl - opacity: 1 - position: relative - @include border-radius(4px) - @include transition(all $duration ease-in-out) + opacity: 1 + position: relative + @include border-radius(4px) + @include transition(all $duration ease-in-out) - &.#{$namespace}-incoming - opacity: 0.0 + &.#{$namespace}-incoming + opacity: 0.0 - &.#{$namespace}-outgoing - opacity: 0.0 + &.#{$namespace}-outgoing + opacity: 0.0 - &.#{$namespace}-small - width: 200px - padding: 5px - margin: 5px - &.#{$namespace}-medium - width: 250px - padding: 10px - margin: 10px - &.#{$namespace}-large - width: 300px - padding: 15px - margin: 15px + &.#{$namespace}-small + width: 200px + padding: 5px + margin: 5px + &.#{$namespace}-medium + width: 250px + padding: 10px + margin: 10px + &.#{$namespace}-large + width: 300px + padding: 15px + margin: 15px - &.#{$namespace}-default - color: #FFF - background: gray - &.#{$namespace}-error - color: white - background: rgba($brand-danger,0.8) - &.#{$namespace}-notice - color: white - background: rgba($brand-success,0.8) - &.#{$namespace}-warning - color: white - background: rgba($brand-warning,0.8) - .#{$namespace}-close - cursor: pointer - font-size: 14px - line-height: 18px - font-weight: normal - font-family: helvetica, verdana, sans-serif - @include float(right) - .#{$namespace}-title - font-size: 18px - line-height: 24px - .#{$namespace}-message - font-size: 14px - line-height: 18px \ No newline at end of file + &.#{$namespace}-default + color: #FFF + background: gray + &.#{$namespace}-error + color: white + background: rgba($brand-danger,0.8) + &.#{$namespace}-notice + color: white + background: rgba($brand-success,0.8) + &.#{$namespace}-warning + color: white + background: rgba($brand-warning,0.8) + .#{$namespace}-close + cursor: pointer + font-size: 14px + line-height: 18px + font-weight: normal + font-family: helvetica, verdana, sans-serif + @include float(right) + .#{$namespace}-title + font-size: 18px + line-height: 24px + .#{$namespace}-message + font-size: 14px + line-height: 18px \ No newline at end of file diff --git a/admin/themes/default/sass/partials/_ladda.sass b/admin/themes/default/sass/partials/_ladda.sass index 0a8427917..b6a12eb24 100644 --- a/admin/themes/default/sass/partials/_ladda.sass +++ b/admin/themes/default/sass/partials/_ladda.sass @@ -12,302 +12,302 @@ $spinnerSize: 32px // MIXINS @mixin prefix ( $property, $value ) - -webkit-#{$property}: $value - -moz-#{$property}: $value - -ms-#{$property}: $value - -o-#{$property}: $value - #{$property}: $value + -webkit-#{$property}: $value + -moz-#{$property}: $value + -ms-#{$property}: $value + -o-#{$property}: $value + #{$property}: $value @mixin transition( $value ) - -webkit-transition: $value !important // important to override bootstrap - -moz-transition: $value !important - -ms-transition: $value !important - -o-transition: $value !important - transition: $value !important + -webkit-transition: $value !important // important to override bootstrap + -moz-transition: $value !important + -ms-transition: $value !important + -o-transition: $value !important + transition: $value !important @mixin vendor-transform( $value ) - @include prefix( transform, $value ) + @include prefix( transform, $value ) @mixin transform-origin( $value ) - @include prefix( transform-origin, $value ) + @include prefix( transform-origin, $value ) @mixin buttonColor( $name, $color ) - &[data-color=#{$name}] - background: $color - &:hover - background-color: lighten( $color, 5% ) + &[data-color=#{$name}] + background: $color + &:hover + background-color: lighten( $color, 5% ) // BUTTON BASE .ladda-button - position: relative - .ladda-spinner - position: absolute - z-index: 2 - display: inline-block - width: $spinnerSize - height: $spinnerSize - top: 50% - margin-top: -$spinnerSize/2 - opacity: 0 - pointer-events: none + position: relative + .ladda-spinner + position: absolute + z-index: 2 + display: inline-block + width: $spinnerSize + height: $spinnerSize + top: 50% + margin-top: -$spinnerSize/2 + opacity: 0 + pointer-events: none - .ladda-label - position: relative - z-index: 3 + .ladda-label + position: relative + z-index: 3 - .ladda-progress - position: absolute - width: 0 - height: 100% - top: 0 - background: rgba( 0, 0, 0, 0.2 ) - visibility: hidden - opacity: 0 - @include left(0) - @include transition( 0.1s linear all ) - &[data-loading] .ladda-progress - opacity: 1 - visibility: visible + .ladda-progress + position: absolute + width: 0 + height: 100% + top: 0 + background: rgba( 0, 0, 0, 0.2 ) + visibility: hidden + opacity: 0 + @include left(0) + @include transition( 0.1s linear all ) + &[data-loading] .ladda-progress + opacity: 1 + visibility: visible // EASING .ladda-button, .ladda-button .ladda-spinner, .ladda-button .ladda-label - @include transition( 0.3s cubic-bezier(0.175, 0.885, 0.320, 1.275) background-color ) + @include transition( 0.3s cubic-bezier(0.175, 0.885, 0.320, 1.275) background-color ) .ladda-button[data-style=zoom-in], .ladda-button[data-style=zoom-in] .ladda-spinner, .ladda-button[data-style=zoom-in] .ladda-label, .ladda-button[data-style=zoom-out], .ladda-button[data-style=zoom-out] .ladda-spinner, .ladda-button[data-style=zoom-out] .ladda-label - @include transition( 0.3s ease all ) + @include transition( 0.3s ease all ) // EXPAND LEFT .ladda-button[data-style=expand-right] - .ladda-spinner - @include right(14px) - &[data-size="s"] .ladda-spinner, - &[data-size="xs"] .ladda-spinner - @include right(4px) - &[data-loading] - @include padding-right(56px) - .ladda-spinner - opacity: 1 - &[data-size="s"], - &[data-size="xs"] - @include padding-right(40px) + .ladda-spinner + @include right(14px) + &[data-size="s"] .ladda-spinner, + &[data-size="xs"] .ladda-spinner + @include right(4px) + &[data-loading] + @include padding-right(56px) + .ladda-spinner + opacity: 1 + &[data-size="s"], + &[data-size="xs"] + @include padding-right(40px) // EXPAND RIGHT .ladda-button[data-style=expand-left] - .ladda-spinner - @include left(14px) - &[data-size="s"] .ladda-spinner, - &[data-size="xs"] .ladda-spinner - @include left(4px) - &[data-loading] - @include padding-left(56px) - .ladda-spinner - opacity: 1 - &[data-size="s"], - &[data-size="xs"] - @include padding-left(40px) + .ladda-spinner + @include left(14px) + &[data-size="s"] .ladda-spinner, + &[data-size="xs"] .ladda-spinner + @include left(4px) + &[data-loading] + @include padding-left(56px) + .ladda-spinner + opacity: 1 + &[data-size="s"], + &[data-size="xs"] + @include padding-left(40px) // EXPAND UP .ladda-button[data-style=expand-up] - overflow: hidden - .ladda-spinner - top: -$spinnerSize - @include margin-left(-$spinnerSize/2) - @include left(50%) - &[data-loading] - padding-top: 54px - .ladda-spinner - opacity: 1 - top: 14px - margin-top: 0 - &[data-size="s"], - &[data-size="xs"] - padding-top: 32px - .ladda-spinner - top: 4px + overflow: hidden + .ladda-spinner + top: -$spinnerSize + @include margin-left(-$spinnerSize/2) + @include left(50%) + &[data-loading] + padding-top: 54px + .ladda-spinner + opacity: 1 + top: 14px + margin-top: 0 + &[data-size="s"], + &[data-size="xs"] + padding-top: 32px + .ladda-spinner + top: 4px // EXPAND DOWN .ladda-button[data-style=expand-down] - overflow: hidden - .ladda-spinner - top: 62px - @include left(50%) - margin-left: -$spinnerSize/2 - &[data-size="s"] .ladda-spinner, - &[data-size="xs"] .ladda-spinner - top: 40px - &[data-loading] - padding-bottom: 54px - .ladda-spinner - opacity: 1 - &[data-size="s"] - &[data-size="xs"] - padding-bottom: 32px + overflow: hidden + .ladda-spinner + top: 62px + @include left(50%) + margin-left: -$spinnerSize/2 + &[data-size="s"] .ladda-spinner, + &[data-size="xs"] .ladda-spinner + top: 40px + &[data-loading] + padding-bottom: 54px + .ladda-spinner + opacity: 1 + &[data-size="s"] + &[data-size="xs"] + padding-bottom: 32px // SLIDE LEFT .ladda-button[data-style=slide-left] - overflow: hidden - .ladda-label - position: relative - .ladda-spinner - @include left(100%) - @include margin-left(-$spinnerSize/2) - &[data-loading] - .ladda-label - opacity: 0 - @include left(-100%) - .ladda-spinner - opacity: 1 - @include left(50%) + overflow: hidden + .ladda-label + position: relative + .ladda-spinner + @include left(100%) + @include margin-left(-$spinnerSize/2) + &[data-loading] + .ladda-label + opacity: 0 + @include left(-100%) + .ladda-spinner + opacity: 1 + @include left(50%) // SLIDE RIGHT .ladda-button[data-style=slide-right] - overflow: hidden - .ladda-label - position: relative - .ladda-spinner - @include right(100%) - @include margin-left(-$spinnerSize/2) - &[data-loading] - .ladda-label - opacity: 0 - @include left(100%) - .ladda-spinner - opacity: 1 - @include left(50%) + overflow: hidden + .ladda-label + position: relative + .ladda-spinner + @include right(100%) + @include margin-left(-$spinnerSize/2) + &[data-loading] + .ladda-label + opacity: 0 + @include left(100%) + .ladda-spinner + opacity: 1 + @include left(50%) // SLIDE UP .ladda-button[data-style=slide-up] - overflow: hidden - .ladda-label - position: relative - .ladda-spinner - margin-top: 1em - @include left(50%) - @include margin-left(-$spinnerSize/2) - &[data-loading] - .ladda-label - opacity: 0 - top: -1em - .ladda-spinner - opacity: 1 - margin-top: -$spinnerSize/2 + overflow: hidden + .ladda-label + position: relative + .ladda-spinner + margin-top: 1em + @include left(50%) + @include margin-left(-$spinnerSize/2) + &[data-loading] + .ladda-label + opacity: 0 + top: -1em + .ladda-spinner + opacity: 1 + margin-top: -$spinnerSize/2 // SLIDE DOWN .ladda-button[data-style=slide-down] - overflow: hidden - .ladda-label - position: relative - .ladda-spinner - margin-top: -2em - @include margin-left(-$spinnerSize/2) - @include left(50%) - &[data-loading] - .ladda-label - opacity: 0 - top: 1em - .ladda-spinner - opacity: 1 - margin-top: -$spinnerSize/2 + overflow: hidden + .ladda-label + position: relative + .ladda-spinner + margin-top: -2em + @include margin-left(-$spinnerSize/2) + @include left(50%) + &[data-loading] + .ladda-label + opacity: 0 + top: 1em + .ladda-spinner + opacity: 1 + margin-top: -$spinnerSize/2 // ZOOM-OUT .ladda-button[data-style=zoom-out] - overflow: hidden - .ladda-spinner - @include left(50%) - @include margin-left(-$spinnerSize/2) - @include vendor-transform( scale( 2.5 ) ) - .ladda-label - position: relative - display: inline-block - &[data-loading] .ladda-label - opacity: 0 - @include vendor-transform( scale( 0.5 ) ) - &[data-loading] .ladda-spinner - opacity: 1 - @include vendor-transform( none ) + overflow: hidden + .ladda-spinner + @include left(50%) + @include margin-left(-$spinnerSize/2) + @include vendor-transform( scale( 2.5 ) ) + .ladda-label + position: relative + display: inline-block + &[data-loading] .ladda-label + opacity: 0 + @include vendor-transform( scale( 0.5 ) ) + &[data-loading] .ladda-spinner + opacity: 1 + @include vendor-transform( none ) // ZOOM-IN .ladda-button[data-style=zoom-in] - overflow: hidden - .ladda-spinner - @include margin-left(-$spinnerSize/2) - @include left(50%) - @include vendor-transform( scale( 0.2 ) ) - .ladda-label - position: relative - display: inline-block - &[data-loading] .ladda-label - opacity: 0 - @include vendor-transform( scale( 2.2 ) ) - &[data-loading] .ladda-spinner - opacity: 1 - @include vendor-transform( none ) + overflow: hidden + .ladda-spinner + @include margin-left(-$spinnerSize/2) + @include left(50%) + @include vendor-transform( scale( 0.2 ) ) + .ladda-label + position: relative + display: inline-block + &[data-loading] .ladda-label + opacity: 0 + @include vendor-transform( scale( 2.2 ) ) + &[data-loading] .ladda-spinner + opacity: 1 + @include vendor-transform( none ) // CONTRACT .ladda-button[data-style=contract] - overflow: hidden - width: 100px - .ladda-spinner - @include left(50%) - @include margin-left(-16px) + overflow: hidden + width: 100px + .ladda-spinner + @include left(50%) + @include margin-left(-16px) .ladda-button[data-style=contract][data-loading] - border-radius: 50% - width: 52px - .ladda-label - opacity: 0 - .ladda-spinner - opacity: 1 + border-radius: 50% + width: 52px + .ladda-label + opacity: 0 + .ladda-spinner + opacity: 1 // OVERLAY .ladda-button[data-style=contract-overlay] - overflow: hidden - width: 100px - @include ltr - box-shadow: 0px 0px 0px 3000px rgba(0,0,0,0) - @include rtl - box-shadow: 0px 3000px 0px 0px rgba(0,0,0,0) - .ladda-spinner - @include left(50%) - @include margin-left(-16px) - &[data-loading] - border-radius: 50% - width: 52px - @include ltr - box-shadow: 0px 0px 0px 3000px rgba(0,0,0,0.8) - @include rtl - box-shadow: 0px 3000px 0px 0px rgba(0,0,0,0.8) - .ladda-label - opacity: 0 - .ladda-spinner - opacity: 1 + overflow: hidden + width: 100px + @include ltr + box-shadow: 0px 0px 0px 3000px rgba(0,0,0,0) + @include rtl + box-shadow: 0px 3000px 0px 0px rgba(0,0,0,0) + .ladda-spinner + @include left(50%) + @include margin-left(-16px) + &[data-loading] + border-radius: 50% + width: 52px + @include ltr + box-shadow: 0px 0px 0px 3000px rgba(0,0,0,0.8) + @include rtl + box-shadow: 0px 3000px 0px 0px rgba(0,0,0,0.8) + .ladda-label + opacity: 0 + .ladda-spinner + opacity: 1 .ladda-button - &[disabled], - &[data-loading] - border-color: rgba( 0, 0, 0, 0.07 ) - cursor: default - background-color: #999 - &:hover - cursor: default - background-color: #999 - &[data-size=xs] - padding: 4px 8px - .ladda-label - font-size: 0.7em - &[data-size=s] - padding: 6px 10px - .ladda-label - font-size: 0.9em - &[data-size=l] .ladda-label - font-size: 1.2em - &[data-size=xl] .ladda-label - font-size: 1.5em + &[disabled], + &[data-loading] + border-color: rgba( 0, 0, 0, 0.07 ) + cursor: default + background-color: #999 + &:hover + cursor: default + background-color: #999 + &[data-size=xs] + padding: 4px 8px + .ladda-label + font-size: 0.7em + &[data-size=s] + padding: 6px 10px + .ladda-label + font-size: 0.9em + &[data-size=l] .ladda-label + font-size: 1.2em + &[data-size=xl] .ladda-label + font-size: 1.5em diff --git a/admin/themes/default/sass/partials/_tables.sass b/admin/themes/default/sass/partials/_tables.sass index 7382ff13a..12f61e76c 100644 --- a/admin/themes/default/sass/partials/_tables.sass +++ b/admin/themes/default/sass/partials/_tables.sass @@ -90,7 +90,7 @@ td.actions @include text-align(right) @include padding-right(5px) - th.actions .btn, + th.actions .btn margin-bottom: 4px !important tr.myDragClass diff --git a/admin/themes/default/template/controllers/modules/configure.tpl b/admin/themes/default/template/controllers/modules/configure.tpl index 24b6560a0..3d3f0d1b9 100644 --- a/admin/themes/default/template/controllers/modules/configure.tpl +++ b/admin/themes/default/template/controllers/modules/configure.tpl @@ -60,7 +60,7 @@
  • -
    {l s='Back'}
    + {l s='Back'}
  • + icon-calendar + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/qloicsexport/views/img/index.php b/modules/qloicsexport/views/img/index.php new file mode 100644 index 000000000..1ac4dd02b --- /dev/null +++ b/modules/qloicsexport/views/img/index.php @@ -0,0 +1,32 @@ += checkIn && dmy <= checkOut)) { + return [true, 'in-select-date-range', '']; + } + } + + return [true, '']; +} \ No newline at end of file diff --git a/modules/qloicsexport/views/js/index.php b/modules/qloicsexport/views/js/index.php new file mode 100644 index 000000000..1ac4dd02b --- /dev/null +++ b/modules/qloicsexport/views/js/index.php @@ -0,0 +1,32 @@ + + + +{/if} \ No newline at end of file diff --git a/modules/qloicsexport/views/templates/hook/index.php b/modules/qloicsexport/views/templates/hook/index.php new file mode 100644 index 000000000..1ac4dd02b --- /dev/null +++ b/modules/qloicsexport/views/templates/hook/index.php @@ -0,0 +1,32 @@ + "none" ); - $returnData = base64_encode(Tools::jsonEncode($temp)) . '.'; + $returnData = base64_encode(json_encode($temp)) . '.'; $temp = array( "iss" => trim(Configuration::get('WK_PAYPAL_COMMERCE_CLIENT_ID')), "payer_id" => Configuration::get('WK_PAYPAL_COMMERCE_MERCHANT_ID') ); - $returnData .= base64_encode(Tools::jsonEncode($temp)) . '.'; + $returnData .= base64_encode(json_encode($temp)) . '.'; return $returnData; } @@ -145,7 +145,7 @@ class WkPaypalCommerceHelper CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", - CURLOPT_POSTFIELDS => Tools::jsonEncode($postData), + CURLOPT_POSTFIELDS => json_encode($postData), CURLOPT_HTTPHEADER => array( "PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID, "authorization: Bearer " . $token, @@ -161,7 +161,7 @@ class WkPaypalCommerceHelper if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); } else { - $webhookResponse = Tools::jsonDecode($response, true); + $webhookResponse = json_decode($response, true); if (isset($webhookResponse['id']) && !empty($webhookResponse['id'])) { $apiResp['success'] = true; $apiResp['webhook_id'] = $webhookResponse['id']; @@ -243,7 +243,7 @@ class WkPaypalCommerceHelper CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", - CURLOPT_POSTFIELDS => Tools::jsonEncode($postData), + CURLOPT_POSTFIELDS => json_encode($postData), CURLOPT_HTTPHEADER => array( "PayPal-Partner-Attribution-Id: " . PayPalHelper::WK_PAYPAL_COMMERCE_ATTRIBUTION_ID, "authorization: Bearer " . $accessToken['access_token'], @@ -260,7 +260,7 @@ class WkPaypalCommerceHelper if ($err) { throw new PrestaShopException(sprintf('cURL Error #: %s', $err)); } else { - $apiResp = Tools::jsonDecode($response, true); + $apiResp = json_decode($response, true); } } return $apiResp; diff --git a/modules/qlopaypalcommerce/classes/WkPaypalCommerceWebhook.php b/modules/qlopaypalcommerce/classes/WkPaypalCommerceWebhook.php index a1bc73ae0..4a6833f40 100644 --- a/modules/qlopaypalcommerce/classes/WkPaypalCommerceWebhook.php +++ b/modules/qlopaypalcommerce/classes/WkPaypalCommerceWebhook.php @@ -52,7 +52,7 @@ class WkPaypalCommerceWebhook if (isset($eventData['resource']['note_to_payer'])) { $refundObj->refund_reason = $eventData['resource']['note_to_payer']; } - $refundObj->response = Tools::jsonEncode($eventData); + $refundObj->response = json_encode($eventData); $refundObj->refund_status = $eventData['resource']['status']; $refundObj->save(); } @@ -188,7 +188,7 @@ class WkPaypalCommerceWebhook return Db::getInstance()->execute( 'UPDATE `'._DB_PREFIX_.'wk_paypal_commerce_order` SET `pp_payment_status` = "'.pSQL($payment_status).'", - `response` = "'.pSQL(Tools::jsonEncode($orderData)).'" + `response` = "'.pSQL(json_encode($orderData)).'" WHERE `pp_transaction_id` = "'.pSQL($transaction_id).'" ' ); diff --git a/modules/qlopaypalcommerce/controllers/admin/AdminPaypalCommerceTransactionController.php b/modules/qlopaypalcommerce/controllers/admin/AdminPaypalCommerceTransactionController.php index 8de5e39e3..3e8a23b17 100644 --- a/modules/qlopaypalcommerce/controllers/admin/AdminPaypalCommerceTransactionController.php +++ b/modules/qlopaypalcommerce/controllers/admin/AdminPaypalCommerceTransactionController.php @@ -137,39 +137,46 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController $smartyVars = array(); $refundData = array(); $totalRefunded = 0; - $transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans); - $orderCurrency = new Currency((int)$transactionData['id_currency']); - $refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans); - $totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true); + if ($transactionData = WKPayPalCommerceOrder::getTransactionDetails((int)$idTrans)) { + $orderCurrency = new Currency((int)$transactionData['id_currency']); + $refundData = WkPaypalCommerceRefund::getRefundListByTransID((int)$idTrans); + $totalRefundedFormatted = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, true); - $totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false); - $remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded); - $response = Tools::jsonDecode($transactionData['response'], true); + $totalRefunded = WkPaypalCommerceRefund::getTotalRefundedAmount((int)$idTrans, false); + $remainingRefund = (float)($transactionData['pp_paid_total'] - $totalRefunded); + $response = Tools::jsonDecode($transactionData['response'], true); - // Buyer making a payment in a different currency (ex: EUR) which is different from the default currency of merchant (Ex: USD), In all those cross currency cases, After Capture, transaction will fall into Pending state and will require merchant to manually go to his PayPal account and accept the payment. - $objPPOrder = new WKPayPalCommerceOrder(); - if (isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']) - && ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED') - && isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']) - ) { - if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) { - $smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']]; + // Buyer making a payment in a different currency (ex: EUR) which is different from the default currency of merchant (Ex: USD), In all those cross currency cases, After Capture, transaction will fall into Pending state and will require merchant to manually go to his PayPal account and accept the payment. + $objPPOrder = new WKPayPalCommerceOrder(); + if ( + isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']) + && ($transactionData['pp_payment_status'] == 'PENDING' || $transactionData['pp_payment_status'] == 'DENIED') + && isset($response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']) + ) { + if (isset($objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']])) { + $smartyVars['ppstatusDetailMsg'] = $objPPOrder->ppStatusDetail[$response['data']['purchase_units'][0]['payments']['captures'][0]['status_details']['reason']]; + } } + + $smartyVars['transaction_url'] = $this->context->link->getAdminLink('AdminPaypalCommerceTransaction',Tools::getAdminTokenLite('AdminPaypalCommerceTransaction')).'&viewwk_paypal_commerce_order&id_paypal_commerce_order=' . (int)$idTrans; + $smartyVars['transaction_data'] = $transactionData; + $smartyVars['refund_data'] = $refundData; + $smartyVars['refunded_amount'] = $totalRefundedFormatted; + $smartyVars['remaining_refund'] = $remainingRefund; + $smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency); + $smartyVars['currency'] = $orderCurrency; + $smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL; + $smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL; + + $this->context->smarty->assign($smartyVars); + $this->base_tpl_view = 'view.tpl'; + return parent::renderView(); + } else { + Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token); } - - $smartyVars['transaction_data'] = $transactionData; - $smartyVars['refund_data'] = $refundData; - $smartyVars['refunded_amount'] = $totalRefundedFormatted; - $smartyVars['remaining_refund'] = $remainingRefund; - $smartyVars['remaining_refund_format'] = Tools::displayPrice($remainingRefund, $orderCurrency); - $smartyVars['currency'] = $orderCurrency; - $smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_FULL; - $smartyVars['WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL'] = WkPaypalCommerceRefund::WK_PAYPAL_COMMERCE_REFUND_TYPE_PARTIAL; - - $this->context->smarty->assign($smartyVars); + } else { + Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token); } - $this->base_tpl_view = 'view.tpl'; - return parent::renderView(); } public function postProcess() @@ -231,7 +238,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController WkPaypalCommerceHelper::logMsg('refund', 'PayPal Transaction ID: '. $transactionData['pp_transaction_id']); WkPaypalCommerceHelper::logMsg('refund', 'PayPal Order ID: '. $transactionData['pp_order_id']); WkPaypalCommerceHelper::logMsg('refund', 'Refund request data: '); - WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($postData)); + WkPaypalCommerceHelper::logMsg('refund', json_encode($postData)); $objPPCommerce = new PayPalCommerce(); $refundData = $objPPCommerce->orders->refund($postData); @@ -243,7 +250,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController WkPaypalCommerceHelper::logMsg('refund', 'Refund success: ', true); WkPaypalCommerceHelper::logMsg('refund', 'PayPal Refund Id: '. $refundID); WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: '); - WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData)); + WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData)); WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true); $refundObj = new WkPaypalCommerceRefund(); @@ -253,7 +260,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController $refundObj->refund_type = (int)$refundType; $refundObj->currency_code = $transactionData['pp_paid_currency']; $refundObj->refund_reason = $refundReason; - $refundObj->response = Tools::jsonEncode($refundData); + $refundObj->response = json_encode($refundData); $refundObj->refund_status = $refundData['data']['status']; if ($refundObj->save()) { $urlString = '&viewwk_paypal_commerce_order=&id_paypal_commerce_order=' . (int)Tools::getValue('id_paypal_commerce_order'); @@ -263,7 +270,7 @@ class AdminPaypalCommerceTransactionController extends ModuleAdminController } else { WkPaypalCommerceHelper::logMsg('refund', 'Refund failed: ', true); WkPaypalCommerceHelper::logMsg('refund', 'Refund reponse data: '); - WkPaypalCommerceHelper::logMsg('refund', Tools::jsonEncode($refundData)); + WkPaypalCommerceHelper::logMsg('refund', json_encode($refundData)); WkPaypalCommerceHelper::logMsg('refund', '----------------------- ', true); $this->errors[] = $refundData['data']['message']; } diff --git a/modules/qlopaypalcommerce/controllers/front/callback.php b/modules/qlopaypalcommerce/controllers/front/callback.php index daa39abb9..89aac427d 100644 --- a/modules/qlopaypalcommerce/controllers/front/callback.php +++ b/modules/qlopaypalcommerce/controllers/front/callback.php @@ -44,25 +44,25 @@ class QloPaypalCommerceCallbackModuleFrontController extends ModuleFrontControll } if ($json) { - $payload['webhook_event'] = Tools::jsonDecode($json, true); + $payload['webhook_event'] = json_decode($json, true); } if ($payload) { WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true); WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE')); WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: '); - WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload)); + WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload)); WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...'); $validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload); WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: '); - WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig)); + WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig)); if (isset($validateSig['verification_status']) && $validateSig['verification_status'] == 'SUCCESS' ) { - $eventData = Tools::jsonDecode($json, true); + $eventData = json_decode($json, true); $objWebhook = new WkPaypalCommerceWebhook(); switch ($eventData['event_type']) { case 'CHECKOUT.ORDER.APPROVED': diff --git a/modules/qlopaypalcommerce/controllers/front/payment.php b/modules/qlopaypalcommerce/controllers/front/payment.php index 61eeb19c1..3795a5e75 100644 --- a/modules/qlopaypalcommerce/controllers/front/payment.php +++ b/modules/qlopaypalcommerce/controllers/front/payment.php @@ -69,7 +69,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle switch ($action) { case 1: $json = Tools::file_get_contents('php://input'); - $orderDetails = Tools::jsonDecode($json, true); + $orderDetails = json_decode($json, true); $cart = $this->context->cart; @@ -86,23 +86,23 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle // create order $orderDetails['original'] = $this->getOrderDetails(); - WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($orderDetails)); + WkPaypalCommerceHelper::logMsg('payment', json_encode($orderDetails)); $ppOrderData = $ppCommerce->orders->create($orderDetails); WkPaypalCommerceHelper::logMsg('payment', 'Payment response data: ', true); - WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($ppOrderData)); + WkPaypalCommerceHelper::logMsg('payment', json_encode($ppOrderData)); - die(Tools::jsonEncode($ppOrderData)); + die(json_encode($ppOrderData)); case 2: $json = Tools::file_get_contents('php://input'); - $orderData = Tools::jsonDecode($json, true); + $orderData = json_decode($json, true); if ($orderData['orderID'] && $orderData['getOrderData']) { $ppCommerce = new PayPalCommerce(); $returnData = $ppCommerce->orders->capture($orderData['orderID']); header('Content-Type: application/json'); - echo Tools::jsonEncode($returnData['data']); + echo json_encode($returnData['data']); die; } elseif (Tools::getIsset('order_id')) { $orderID = Tools::getValue('order_id'); @@ -116,14 +116,14 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle WkPaypalCommerceHelper::logMsg('payment', 'Customer ID: '. $cart->id_customer); WkPaypalCommerceHelper::logMsg('payment', 'Currency ID: '. $cart->id_currency); WkPaypalCommerceHelper::logMsg('payment', 'Cart Total: '. $cart->getOrderTotal(true, Cart::BOTH)); - WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode($returnData)); + WkPaypalCommerceHelper::logMsg('payment', json_encode($returnData)); if (isset($returnData['data']['id']) && !empty($returnData['data']['id'])) { // Payment success $paypalOrderID = $returnData['data']['id']; // Save order data - $this->saveOrderData($returnData); + $transaction_id = $this->saveOrderData($returnData); if ($paypalOrderID) { $currency = $this->context->currency; $total = (float)$cart->getOrderTotal(true, Cart::BOTH); @@ -144,6 +144,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle $orderStatus = Configuration::get('PS_OS_AWAITING_PAYMENT'); } + $extraVars['transaction_id'] = $transaction_id; // create order for the payment $this->module->validateOrder( $cart->id, @@ -151,7 +152,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle $total, $this->module->l('PayPal Checkout', 'payment'), null, - null, + $extraVars, (int)$currency->id, false, $customer->secure_key @@ -210,7 +211,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle break; case 3: WkPaypalCommerceHelper::logMsg('payment', 'Payment cancelled by customer...', true); - WkPaypalCommerceHelper::logMsg('payment', Tools::jsonEncode(Tools::getAllValues())); + WkPaypalCommerceHelper::logMsg('payment', json_encode(Tools::getAllValues())); WkPaypalCommerceHelper::logMsg('payment', '--------------', true); Tools::redirect($this->context->link->getPageLink('order-opc', true, null).'?pp_cancel=1'); @@ -226,6 +227,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle // Save order data private function saveOrderData($orderData) { + $transaction_id = ''; if ($orderData) { $purchaseUnits = $orderData['data']['purchase_units']; foreach ($purchaseUnits as $purchase) { @@ -260,15 +262,13 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle $orderObj->pp_order_id = $orderData['data']['id']; $orderObj->pp_transaction_id = $transaction_id; $orderObj->pp_payment_status = $payment_status; - $orderObj->response = Tools::jsonEncode($orderData); + $orderObj->response = json_encode($orderData); $orderObj->order_date = date('Y-m-d H:i:s'); $orderObj->save(); } - - return true; } - return false; + return $transaction_id; } // Create order data to send to PayPal diff --git a/modules/qlopaypalcommerce/controllers/front/webhook.php b/modules/qlopaypalcommerce/controllers/front/webhook.php index 0ff356f8f..8315afd89 100644 --- a/modules/qlopaypalcommerce/controllers/front/webhook.php +++ b/modules/qlopaypalcommerce/controllers/front/webhook.php @@ -44,25 +44,25 @@ class QloPaypalCommerceWebhookModuleFrontController extends ModuleFrontControlle } if ($json) { - $payload['webhook_event'] = Tools::jsonDecode($json, true); + $payload['webhook_event'] = json_decode($json, true); } if ($payload) { WkPaypalCommerceHelper::logMsg('webhook', 'Webhook initiated...', true); WkPaypalCommerceHelper::logMsg('webhook', 'Environment: '. Configuration::get('WK_PAYPAL_COMMERCE_PAYMENT_MODE')); WkPaypalCommerceHelper::logMsg('webhook', 'Webhook payload data: '); - WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($payload)); + WkPaypalCommerceHelper::logMsg('webhook', json_encode($payload)); WkPaypalCommerceHelper::logMsg('webhook', 'Validating webhook signature...'); $validateSig = WkPaypalCommerceHelper::validateWebhookSig($payload); WkPaypalCommerceHelper::logMsg('webhook', 'Webhook respose data: '); - WkPaypalCommerceHelper::logMsg('webhook', Tools::jsonEncode($validateSig)); + WkPaypalCommerceHelper::logMsg('webhook', json_encode($validateSig)); if (isset($validateSig['verification_status']) && $validateSig['verification_status'] == 'SUCCESS' ) { - $eventData = Tools::jsonDecode($json, true); + $eventData = json_decode($json, true); $objWebhook = new WkPaypalCommerceWebhook(); switch ($eventData['event_type']) { case 'CHECKOUT.ORDER.APPROVED': diff --git a/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php b/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php index cdd2952ba..f3c42b7ce 100644 --- a/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php +++ b/modules/qlopaypalcommerce/libs/Helpers/HttpHelper.php @@ -70,7 +70,7 @@ class HttpHelper { $headerSize = curl_getinfo($this->_curl, CURLINFO_HEADER_SIZE); $body = substr($result, $headerSize); - return Tools::jsonDecode($body, true); + return json_decode($body, true); } public function resetHelper() { @@ -85,7 +85,7 @@ class HttpHelper { public function setBody($postData) { if(is_array($postData)) { - $postData = Tools::jsonEncode($postData); + $postData = json_encode($postData); } curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $postData); curl_setopt($this->_curl, CURLOPT_POST, true); diff --git a/modules/qlopaypalcommerce/views/css/front/wk_payment.css b/modules/qlopaypalcommerce/views/css/front/wk_payment.css index 27256b7ff..5843f2c29 100644 --- a/modules/qlopaypalcommerce/views/css/front/wk_payment.css +++ b/modules/qlopaypalcommerce/views/css/front/wk_payment.css @@ -45,3 +45,15 @@ @keyframes rotate { 0% {transform: rotate(0deg);} 100% {transform: rotate(360deg);}} + +p.payment_module a#qlo_paypal_btn { + background: url(../../img/paypal-payment-icon.png) 15px 8px no-repeat #fbfbfb; +} + +.qlo_paypal_methods_wrapper { + text-align: center; + padding: 20px 15px; + background: #fbfbfb; + border-radius: 3px; + border: 1px solid #d6d4d4; +} diff --git a/modules/qlopaypalcommerce/views/img/index.php b/modules/qlopaypalcommerce/views/img/index.php new file mode 100644 index 000000000..409280877 --- /dev/null +++ b/modules/qlopaypalcommerce/views/img/index.php @@ -0,0 +1,32 @@ + 0} -
    +
    @@ -176,6 +176,7 @@ {l s='Amount' mod='qlopaypalcommerce'} {l s='Type' mod='qlopaypalcommerce'} {l s='Status' mod='qlopaypalcommerce'} + {l s='Remark' mod='qlopaypalcommerce'} {l s='Date' mod='qlopaypalcommerce'} {if $refund_data} @@ -197,6 +198,7 @@ {/if} + {$refund.refund_reason|escape:'html':'UTF-8'} {$refund.date_add|escape:'html':'UTF-8'} {/foreach} diff --git a/modules/qlopaypalcommerce/views/templates/hook/payment.tpl b/modules/qlopaypalcommerce/views/templates/hook/payment.tpl index f5bcbe0de..d1a6a8f8a 100644 --- a/modules/qlopaypalcommerce/views/templates/hook/payment.tpl +++ b/modules/qlopaypalcommerce/views/templates/hook/payment.tpl @@ -20,82 +20,114 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -
    -