diff --git a/.env.example b/.env.example index e51bf8067..1f5cc21c7 100644 --- a/.env.example +++ b/.env.example @@ -16,6 +16,9 @@ CI_ENVIRONMENT = production # Configure with comma-separated list of domains/subdomains: # app.allowedHostnames = 'yourdomain.com,www.yourdomain.com' # +# Or via environment variable (useful for Docker/Compose): +# ALLOWED_HOSTNAMES=yourdomain.com,www.yourdomain.com +# # For local development: # app.allowedHostnames = 'localhost' # diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 82438ec67..23774385e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -123,6 +123,7 @@ jobs: . !.git !node_modules + include-hidden-files: true retention-days: 1 docker: diff --git a/CHANGELOG.md b/CHANGELOG.md index e79764d70..407c8b711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,4 @@ -[unreleased]: https://github.com/opensourcepos/opensourcepos/compare/3.4.0...HEAD -[3.4.2]: https://github.com/opensourcepos/opensourcepos/compare/3.4.1...3.4.2 +[unreleased]: https://github.com/opensourcepos/opensourcepos/compare/3.4.1...HEAD [3.4.1]: https://github.com/opensourcepos/opensourcepos/compare/3.4.0...3.4.1 [3.4.0]: https://github.com/opensourcepos/opensourcepos/compare/3.3.9...3.4.0 [3.3.9]: https://github.com/opensourcepos/opensourcepos/compare/3.3.8...3.3.9 @@ -34,10 +33,36 @@ All notable changes to this project will be documented in this file. ## [Unreleased] -## [3.4.0] - 2025-02-06 +## [3.4.1] - 2025-06-05 +- Feature: PSR-12 Compliant Indentation by @objecttothis in ([#4196](https://github.com/opensourcepos/opensourcepos/pull/4196)) +- Add .env to dist zip by @jekkos in ([#4199](https://github.com/opensourcepos/opensourcepos/pull/4199)) +- Add CI4 coding standards linter ([#3708](https://github.com/opensourcepos/opensourcepos/issues/3708)) by @jekkos in ([#4198](https://github.com/opensourcepos/opensourcepos/pull/4198)) +- Bump canvg from 3.0.10 to 3.0.11 by @dependabot in ([#4189](https://github.com/opensourcepos/opensourcepos/pull/4189)) +- Bump jspdf and jspdf-autotable by @dependabot in ([#4190](https://github.com/opensourcepos/opensourcepos/pull/4190)) +- Feature bump ci to 4.6.0 by @objecttothis in ([#4197](https://github.com/opensourcepos/opensourcepos/pull/4197)) +- Add Kurdish language option to UI by @BudsieBuds in ([#4210](https://github.com/opensourcepos/opensourcepos/pull/4210)) +- Convert language ku to ckb by @BudsieBuds in ([#4211](https://github.com/opensourcepos/opensourcepos/pull/4211)) +- Fix PHP 8.4 errors by @BudsieBuds in ([#4215](https://github.com/opensourcepos/opensourcepos/pull/4215)) +- Add default bootstrap to themes by @BudsieBuds in ([#4219](https://github.com/opensourcepos/opensourcepos/pull/4219)) +- Update language names by @BudsieBuds in ([#4218](https://github.com/opensourcepos/opensourcepos/pull/4218)) +- Update install docs by @BudsieBuds in ([#4217](https://github.com/opensourcepos/opensourcepos/pull/4217)) +- Convert menu icons to SVG by @BudsieBuds in ([#4220](https://github.com/opensourcepos/opensourcepos/pull/4220)) +- Enhance license handling by @BudsieBuds in ([#4223](https://github.com/opensourcepos/opensourcepos/pull/4223)) +- Fix datetime rendering ([#4226](https://github.com/opensourcepos/opensourcepos/issues/4226)) by @jekkos in ([#4227](https://github.com/opensourcepos/opensourcepos/pull/4227)) +- Fix datetime rendering by @jekkos in ([#4228](https://github.com/opensourcepos/opensourcepos/pull/4228)) +- Fix null error when sending by email a receipt of a sale that has no invoice by @diego-ramos in ([#4229](https://github.com/opensourcepos/opensourcepos/pull/4229)) +- Update Receivings.php to save form. by @odiea in ([#4231](https://github.com/opensourcepos/opensourcepos/pull/4231)) +- Update Cashups.php for ajax cashup total to work. by @odiea in ([#4238](https://github.com/opensourcepos/opensourcepos/pull/4238)) +- Coding style updates for PSR-12 compliance & improved readability by @BudsieBuds in ([#4204](https://github.com/opensourcepos/opensourcepos/pull/4204)) +- Fix Codeigniter disallowed characters error with payment types that have accents by @diego-ramos in ([#4232](https://github.com/opensourcepos/opensourcepos/pull/4232)) +- Fixed broken escape string for success & warning messages by @Franchovy in ([#4253](https://github.com/opensourcepos/opensourcepos/pull/4253)) +- Bugfix constraint migration fix by @objecttothis in ([#4230](https://github.com/opensourcepos/opensourcepos/pull/4230)) +- Fix item number lookup in sales/receivings ([#4212](https://github.com/opensourcepos/opensourcepos/issues/4212)) by @jekkos in ([#4250](https://github.com/opensourcepos/opensourcepos/pull/4250)) + +## [3.4.0] - 2025-03-23 - Translation updates (Spanish, Indonesian, Swedish, Urdu, Chinese, Thai, French, Dutch) -- PHP 8.x support +- PHP `8.x` support - Security fixes (XSS, SQLi) - Migration to Gulp as buildsystem - Decimal validation fix diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 10e1acd6c..302dae0b9 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,98 +1,85 @@ -Contributor Covenant Code of Conduct -Our Pledge -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. -Our Standards -Examples of behavior that contributes to a positive environment for our -community include: +[comment]: # (Contributor Covenant 2.1 - from https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, -and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall -community +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or advances of -any kind +* The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others’ private information, such as a physical or email address, -without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a -professional setting +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting -Enforcement Responsibilities -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. -Scope -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official email address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. -Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. -All complaints will be reviewed and investigated promptly and fairly. -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. -Enforcement Guidelines -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: -1. Correction -Community Impact: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. -Consequence: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. -2. Warning -Community Impact: A violation through a single incident or series of -actions. -Consequence: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. -3. Temporary Ban -Community Impact: A serious violation of community standards, including -sustained inappropriate behavior. -Consequence: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. -4. Permanent Ban -Community Impact: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. -Consequence: A permanent ban from any sort of public interaction within the -community. -Attribution -This Code of Conduct is adapted from the Contributor Covenant, -version 2.1, available at -https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. -Community Impact Guidelines were inspired by -Mozilla’s code of conduct enforcement ladder. -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. +## Enforcement Responsibilities +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/Dockerfile b/Dockerfile index db1f8a1c1..4180c9259 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,8 @@ RUN echo "date.timezone = \"\${PHP_TIMEZONE}\"" > /usr/local/etc/php/conf.d/time WORKDIR /app COPY --chown=www-data:www-data . /app -RUN chmod 770 /app/writable/uploads /app/writable/logs /app/writable/cache \ +RUN chmod 750 /app/writable/logs /app/writable/uploads /app/writable/cache /app/public/uploads /app/public/uploads/item_pics \ + && chmod 640 /app/writable/uploads/importCustomers.csv \ && ln -s /app/*[^public] /var/www \ && rm -rf /var/www/html \ && ln -nsf /app/public /var/www/html diff --git a/SECURITY.md b/SECURITY.md index 771524f48..ab58ee26e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -5,8 +5,9 @@ - [Supported Versions](#supported-versions) - [Security Advisories](#security-advisories) - [Reporting a Vulnerability](#reporting-a-vulnerability) + - [Disclosure Process](#disclosure-process) - + # Security Policy @@ -21,26 +22,116 @@ We release patches for security vulnerabilities. ## Security Advisories -The following security vulnerabilities have been published: - -### High Severity - -| CVE | Vulnerability | CVSS | Published | Fixed In | Credit | -|-----|--------------|------|-----------|----------|--------| -| [CVE-2025-68434](https://github.com/opensourcepos/opensourcepos/security/advisories/GHSA-wjm4-hfwg-5w5r) | CSRF leading to Admin Creation | 8.8 | 2025-12-17 | 3.4.2 | @Nixon-H, @jekkos | -| [CVE-2025-68147](https://github.com/opensourcepos/opensourcepos/security/advisories/GHSA-xgr7-7pvw-fpmh) | Stored XSS in Return Policy | 8.1 | 2025-12-17 | 3.4.2 | @Nixon-H, @jekkos | -| [CVE-2025-66924](https://github.com/opensourcepos/opensourcepos/security/advisories/GHSA-gv8j-f6gq-g59m) | Stored XSS in Item Kits | 7.2 | 2026-03-04 | 3.4.2 | @hungnqdz, @omkaryepre | - -### Medium Severity - -| CVE | Vulnerability | CVSS | Published | Fixed In | Credit | -|-----|--------------|------|-----------|----------|--------| -| [CVE-2025-68658](https://github.com/opensourcepos/opensourcepos/security/advisories/GHSA-32r8-8r9r-9chw) | Stored XSS in Company Name | 4.3 | 2026-01-13 | 3.4.2 | @hungnqdz | - -For a complete list including draft advisories, see our [GitHub Security Advisories page](https://github.com/opensourcepos/opensourcepos/security/advisories). +For a complete list of published and draft security advisories with CVE details, see our [GitHub Security Advisories page](https://github.com/opensourcepos/opensourcepos/security/advisories). ## Reporting a Vulnerability -Please report (suspected) security vulnerabilities to **[jeroen@steganos.dev](mailto:jeroen@steganos.dev)**. +**Option 1: GitHub Security Advisory (Preferred)** -You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days. \ No newline at end of file +1. Create a draft security advisory directly on GitHub: + - Go to https://github.com/opensourcepos/opensourcepos/security/advisories + - Click "New draft security advisory" + - Fill in the vulnerability details using our [template below](#vulnerability-template) + - Submit as **draft** (not published) + +2. Notify us for triage: + - Send an email to **[jeroen@steganos.dev](mailto:jeroen@steganos.dev)** with: + - Subject: `[GHSA] Brief description of vulnerability` + - Link to the draft advisory + - Brief summary + +**Option 2: Email Report** + +Send vulnerability details to **[jeroen@steganos.dev](mailto:jeroen@steganos.dev)**. + +You will receive a response within 48 hours. Confirmed vulnerabilities will be patched within a few days depending on complexity. + +## Disclosure Process + +### Timeline + +| Step | Timeline | Action | +|------|----------|--------| +| 1. Report received | Day 0 | We acknowledge within 48 hours | +| 2. Triage & confirmation | Day 1-3 | We validate the vulnerability | +| 3. Fix development | Day 3-7 | We develop and test the fix | +| 4. Patch release | Day 7-10 | We release a security patch | +| 5. CVE request | Day 7-14 | We request CVE from GitHub (if applicable) | +| 6. Advisory published | Day 14 | We publish the advisory with credit | +| 7. Public disclosure | Day 14+ | Full disclosure after patch release | + +### CVE Process + +**We request CVE identifiers through GitHub's security advisory system.** This is the preferred and easiest method: + +1. After we confirm and fix the vulnerability, we'll request a CVE through GitHub +2. GitHub coordinates with MITRE on our behalf +3. The CVE is automatically linked to the advisory +4. You'll be credited as the reporter in the published advisory + +**Already have a CVE?** If you've already obtained a CVE from another source (e.g., VulDB, CVE.MITRE.ORG), please include it in your report or advisory. We'll update our advisory to reference the existing CVE. + +### No Bug Bounty Program + +**Important:** Open Source Point of Sale does not offer a bug bounty program. + +- All security research and vulnerability triage is done on a **voluntary basis** in our free time +- We do not offer monetary rewards for vulnerability reports +- We do credit reporters in published advisories (unless anonymity is requested) +- We greatly appreciate the security research community's efforts to help improve project security + +### Security Best Practices for Researchers + +- **Do not** access, modify, or delete data that doesn't belong to you +- **Do not** perform denial of service attacks +- **Do not** publicly disclose vulnerabilities before we've had time to fix them +- **Do** provide sufficient information to reproduce the vulnerability +- **Do** allow us reasonable time to fix before public disclosure +- **Do** report through official channels (GitHub advisories or email) + +### Vulnerability Template + +When creating a draft advisory, please include: + +``` +## Summary +[Brief description of the vulnerability] + +## Impact +- **Confidentiality:** [High/Medium/Low - what data can be exposed] +- **Integrity:** [High/Medium/Low - what can be modified] +- **Availability:** [High/Medium/Low - service disruption potential] +- **Privilege Required:** [None/Low/High - authentication level needed] +- **CVSS v3.1:** [Score] ([Vector string]) + +## Details +[Technical details about the vulnerability] + +**Affected Code:** +```php +// Path to affected file and vulnerable code +``` + +**Attack Vector:** +[How an attacker can exploit this] + +## Proof of Concept +```bash +# Steps to reproduce +``` + +## Patch +[Suggested fix or approach] + +## Affected Versions +- OpenSourcePOS X.Y.Z and earlier + +## Credit +[Your GitHub username or preferred name] +``` + +--- + +**Thank you to all security researchers who have contributed to making Open Source Point of Sale more secure.** Your voluntary efforts help protect thousands of users worldwide and contribute to a safer, more trustworthy free and open-source software ecosystem. We deeply appreciate your responsible disclosure and the time you invest in improving our project. + +If you've reported a vulnerability and would like to discuss CVE coordination or have questions about the process, please reach out to us at [jeroen@steganos.dev](mailto:jeroen@steganos.dev). \ No newline at end of file diff --git a/app/Config/App.php b/app/Config/App.php index db4b0a876..23cbe016b 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -58,9 +58,9 @@ class App extends BaseConfig * Allowed Hostnames in the Site URL other than the hostname in the baseURL. * If you want to accept multiple Hostnames, set this. * - * E.g., - * When your site URL ($baseURL) is 'http://example.com/', and your site - * also accepts 'http://media.example.com/' and 'http://accounts.example.com/': + * Or via environment variable (useful for Docker/Compose): + * ALLOWED_HOSTNAMES=example.com,www.example.com + * * ['media.example.com', 'accounts.example.com'] * * @var list @@ -286,7 +286,11 @@ class App extends BaseConfig // Solution for CodeIgniter 4 limitation: arrays cannot be set from .env // See: https://github.com/codeigniter4/CodeIgniter4/issues/7311 - $envAllowedHostnames = getenv('app.allowedHostnames'); + // Support both: app.allowedHostnames (from .env) and ALLOWED_HOSTNAMES (from environment/Docker) + $envAllowedHostnames = getenv('ALLOWED_HOSTNAMES'); + if ($envAllowedHostnames === false || trim($envAllowedHostnames) === '') { + $envAllowedHostnames = getenv('app.allowedHostnames'); + } if ($envAllowedHostnames !== false && trim($envAllowedHostnames) !== '') { $this->allowedHostnames = array_values(array_filter( array_map('trim', explode(',', $envAllowedHostnames)), @@ -327,7 +331,7 @@ class App extends BaseConfig $errorMessage = 'Security: allowedHostnames is not configured. ' . 'Host header injection protection is disabled. ' . - 'Set app.allowedHostnames in your .env file. ' . + 'Set app.allowedHostnames in your .env file or ALLOWED_HOSTNAMES environment variable. ' . 'Example: app.allowedHostnames = "example.com,www.example.com" ' . 'Received Host: ' . $httpHost; diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php index 2bd51d475..c2db7340c 100644 --- a/app/Config/Mimes.php +++ b/app/Config/Mimes.php @@ -486,10 +486,9 @@ class Mimes /** * Attempts to determine the best mime type for the given file extension. * - * @param string $extension - * @return array|string|null The mime type found, or none if unable to determine. + * @return string|null The mime type found, or none if unable to determine. */ - public static function guessTypeFromExtension(string $extension): array|string|null + public static function guessTypeFromExtension(string $extension) { $extension = trim(strtolower($extension), '. '); @@ -507,7 +506,7 @@ class Mimes * * @return string|null The extension determined, or null if unable to match. */ - public static function guessExtensionFromType(string $type, ?string $proposedExtension = null): ?string + public static function guessExtensionFromType(string $type, ?string $proposedExtension = null) { $type = trim(strtolower($type), '. '); @@ -523,7 +522,7 @@ class Mimes } // Reverse check the mime type list if no extension was proposed. - // This search is order-sensitive! + // This search is order sensitive! foreach (static::$mimes as $ext => $types) { if (in_array($type, (array) $types, true)) { return $ext; diff --git a/app/Config/OSPOS.php b/app/Config/OSPOS.php index 1f411394d..ecc6eb59a 100644 --- a/app/Config/OSPOS.php +++ b/app/Config/OSPOS.php @@ -48,7 +48,8 @@ class OSPOS extends BaseConfig $this->settings = [ 'language' => 'english', 'language_code' => 'en', - 'company' => 'Home' + 'company' => 'Home', + 'barcode_type' => 'Code39' ]; } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 705b3e7cf..ab45a7710 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -28,12 +28,9 @@ abstract class BaseController extends Controller // protected $session; /** - * @param RequestInterface $request - * @param ResponseInterface $response - * @param LoggerInterface $logger * @return void */ - public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger): void + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { // Load here all helpers you want to be available in your controllers that extend BaseController. // Caution: Do not put the this below the parent::initController() call below. diff --git a/app/Controllers/Config.php b/app/Controllers/Config.php index 3140e9baf..a21317224 100644 --- a/app/Controllers/Config.php +++ b/app/Controllers/Config.php @@ -81,7 +81,7 @@ class Config extends Secure_Controller $npmDev = false; $license = []; - $license[$i]['title'] = 'Open Source Point Of Sale ' . config('App')->application_version; + $license[$i]['title'] = 'Open Source Point of Sale ' . config('App')->application_version; if (file_exists('license/LICENSE')) { $license[$i]['text'] = file_get_contents('license/LICENSE', false, null, 0, 3000); @@ -220,6 +220,7 @@ class Config extends Secure_Controller */ public function getIndex(): string { + $data['config'] = $this->config; $data['stock_locations'] = $this->stock_location->get_all()->getResultArray(); $data['dinner_tables'] = $this->dinner_table->get_all()->getResultArray(); $data['customer_rewards'] = $this->customer_rewards->get_all()->getResultArray(); @@ -230,6 +231,8 @@ class Config extends Secure_Controller $data['line_sequence_options'] = $this->sale_lib->get_line_sequence_options(); $data['register_mode_options'] = $this->sale_lib->get_register_mode_options(); $data['invoice_type_options'] = $this->sale_lib->get_invoice_type_options(); + $data['keyboardShortcutOptions'] = $this->sale_lib->getKeyShortcutsOptions(); + $data['keyboardShortcuts'] = $this->sale_lib->getKeyShortcuts(); $data['rounding_options'] = rounding_mode::get_rounding_options(); $data['tax_code_options'] = $this->tax_lib->get_tax_code_options(); $data['tax_category_options'] = $this->tax_lib->get_tax_category_options(); @@ -823,7 +826,9 @@ class Config extends Secure_Controller public function postSaveReceipt(): ResponseInterface { $batch_save_data = [ - 'receipt_template' => $this->request->getPost('receipt_template'), + 'receipt_template' => Sale_lib::isValidReceiptTemplate($this->request->getPost('receipt_template')) + ? $this->request->getPost('receipt_template') + : 'receipt_default', 'receipt_font_size' => $this->request->getPost('receipt_font_size', FILTER_SANITIZE_NUMBER_INT), 'print_delay_autoreturn' => $this->request->getPost('print_delay_autoreturn', FILTER_SANITIZE_NUMBER_INT), 'email_receipt_check_behaviour' => $this->request->getPost('email_receipt_check_behaviour'), @@ -848,6 +853,44 @@ class Config extends Secure_Controller return $this->response->setJSON(['success' => $success, 'message' => lang('Config.saved_' . ($success ? '' : 'un') . 'successfully')]); } + /** + * Saves keyboard shortcut bindings. + * + * @return ResponseInterface + * @noinspection PhpUnused + */ + public function postSaveShortcuts(): ResponseInterface + { + $allowedShortcuts = array_keys($this->sale_lib->getKeyShortcutsOptions()); + $currentShortcuts = $this->sale_lib->getKeyShortcuts(); + $batchSaveData = []; + + foreach ($currentShortcuts as $name => $shortcut) { + $postedValue = trim((string)$this->request->getPost('key_' . $name)); + + if (!in_array($postedValue, $allowedShortcuts, true)) { + $postedValue = $shortcut['value']; + } + + $batchSaveData['key_' . $name] = $postedValue; + } + + $duplicateValues = array_filter(array_count_values($batchSaveData), static fn(int $count): bool => $count > 1); + if (!empty($duplicateValues)) { + return $this->response->setJSON([ + 'success' => false, + 'message' => lang('Config.shortcuts_duplicate_bindings') + ]); + } + + $success = $this->appconfig->batch_save($batchSaveData); + + return $this->response->setJSON([ + 'success' => $success, + 'message' => lang('Config.saved_' . ($success ? '' : 'un') . 'successfully') + ]); + } + /** * Saves invoice configuration. Used in app/Views/configs/invoice_config.php. * diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index db67fa8c6..05591a0a8 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -155,8 +155,23 @@ class Items extends Secure_Controller { helper('file'); - $pic_filename = rawurldecode($pic_filename); - $file_extension = pathinfo($pic_filename, PATHINFO_EXTENSION); + // Security: Sanitize filename to prevent path traversal + // Use basename() to strip directory components and prevent '../' attacks + $pic_filename = basename(rawurldecode($pic_filename)); + $file_extension = strtolower(pathinfo($pic_filename, PATHINFO_EXTENSION)); + + // Validate file extension against system-configured allowed image types + // Handle both legacy pipe-separated and current comma-separated formats + // Fallback to types that GD library can process for thumbnail generation + $allowed_types = $this->config['image_allowed_types'] ?? 'jpg,jpeg,gif,png,webp,bmp,tif,tiff'; + $allowed_extensions = strpos($allowed_types, '|') !== false + ? explode('|', $allowed_types) + : explode(',', $allowed_types); + + if (!in_array($file_extension, $allowed_extensions, true)) { + return $this->response->setStatusCode(400)->setBody('Invalid file type'); + } + $images = glob("./uploads/item_pics/$pic_filename"); $base_path = './uploads/item_pics/' . pathinfo($pic_filename, PATHINFO_FILENAME); @@ -1042,14 +1057,20 @@ class Items extends Secure_Controller }); if (!$isFailedRow && $this->item->save_value($itemData, $itemId)) { - $this->save_tax_data($row, $itemData); - $this->save_inventory_quantities($row, $itemData, $allowedStockLocations, $employeeId); + if (!$this->save_tax_data($row, $itemData)) { + $isFailedRow = true; + } + if (!$this->save_inventory_quantities($row, $itemData, $allowedStockLocations, $employeeId)) { + $isFailedRow = true; + } $csvAttributeValues = $this->extractAttributeData($row); - $isFailedRow = !$this->attribute->saveCSVRowAttributeData($csvAttributeValues, $itemData, $attributeData); + if (!$this->attribute->saveCSVRowAttributeData($csvAttributeValues, $itemData, $attributeData)) { + $isFailedRow = true; + } if ($isFailedRow) { $failedRow = $key + 2; $failCodes[] = $failedRow; - log_message('error', "CSV Item import failed on line $failedRow while saving attributes."); + log_message('error', "CSV Item import failed on line $failedRow while saving item."); continue; } @@ -1239,13 +1260,15 @@ class Items extends Secure_Controller * @param array $item_data * @param array $allowed_locations * @param int $employee_id + * @return bool Returns true on success, false on failure * @throws ReflectionException */ - private function save_inventory_quantities(array $row, array $item_data, array $allowed_locations, int $employee_id): void + private function save_inventory_quantities(array $row, array $item_data, array $allowed_locations, int $employee_id): bool { // Quantities & Inventory Section $comment = lang('Items.inventory_CSV_import_quantity'); $is_update = (bool)$row['Id']; + $success = true; foreach ($allowed_locations as $location_id => $location_name) { $item_quantity_data = ['item_id' => $item_data['item_id'], 'location_id' => $location_id]; @@ -1259,20 +1282,22 @@ class Items extends Secure_Controller if (!empty($row["location_$location_name"]) || $row["location_$location_name"] === '0') { $item_quantity_data['quantity'] = $row["location_$location_name"]; - $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); + $success &= $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); $csv_data['trans_inventory'] = $row["location_$location_name"]; - $this->inventory->insert($csv_data, false); + $success &= (bool)$this->inventory->insert($csv_data, false); } elseif ($is_update) { - return; + continue; } else { $item_quantity_data['quantity'] = 0; - $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); + $success &= $this->item_quantity->save_value($item_quantity_data, $item_data['item_id'], $location_id); $csv_data['trans_inventory'] = 0; - $this->inventory->insert($csv_data, false); + $success &= (bool)$this->inventory->insert($csv_data, false); } } + + return (bool)$success; } /** @@ -1280,8 +1305,9 @@ class Items extends Secure_Controller * * @param array $row * @param array $item_data + * @return bool Returns true on success, false on failure */ - private function save_tax_data(array $row, array $item_data): void + private function save_tax_data(array $row, array $item_data): bool { $items_taxes_data = []; @@ -1293,9 +1319,11 @@ class Items extends Secure_Controller $items_taxes_data[] = ['name' => $row['Tax 2 Name'], 'percent' => $row['Tax 2 Percent']]; } - if (isset($items_taxes_data)) { - $this->item_taxes->save_value($items_taxes_data, $item_data['item_id']); + if (!empty($items_taxes_data)) { + return $this->item_taxes->save_value($items_taxes_data, $item_data['item_id']); } + + return true; } /** diff --git a/app/Controllers/Reports.php b/app/Controllers/Reports.php index 073177f53..899e0dcc1 100644 --- a/app/Controllers/Reports.php +++ b/app/Controllers/Reports.php @@ -1246,13 +1246,15 @@ class Reports extends Secure_Controller public function get_payment_type(): array { return [ - 'all' => lang('Common.none_selected_text'), - 'cash' => lang('Sales.cash'), - 'due' => lang('Sales.due'), - 'check' => lang('Sales.check'), - 'credit' => lang('Sales.credit'), - 'debit' => lang('Sales.debit'), - 'invoices' => lang('Sales.invoice') + 'all' => lang('Common.none_selected_text'), + 'cash' => lang('Sales.cash'), + 'due' => lang('Sales.due'), + 'check' => lang('Sales.check'), + 'credit' => lang('Sales.credit'), + 'debit' => lang('Sales.debit'), + 'bank_transfer' => lang('Sales.bank_transfer'), + 'wallet' => lang('Sales.wallet'), + 'invoices' => lang('Sales.invoice') ]; } diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index c2327b740..bfd47ec87 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -93,6 +93,8 @@ class Sales extends Secure_Controller 'only_check' => lang('Sales.check_filter'), 'only_creditcard' => lang('Sales.credit_filter'), 'only_debit' => lang('Sales.debit'), + 'only_bank_transfer'=> lang('Sales.bank_transfer'), + 'only_wallet' => lang('Sales.wallet'), 'only_invoices' => lang('Sales.invoice_filter'), 'selected_customer' => lang('Sales.selected_customer') ]; @@ -156,6 +158,8 @@ class Sales extends Secure_Controller 'selected_customer' => false, 'only_creditcard' => false, 'only_debit' => false, + 'only_bank_transfer'=> false, + 'only_wallet' => false, 'only_invoices' => $this->config['invoice_enable'] && $this->request->getGet('only_invoices', FILTER_SANITIZE_NUMBER_INT), 'is_valid_receipt' => $this->sale->is_valid_receipt($search) ]; @@ -904,6 +908,14 @@ class Sales extends Secure_Controller return $this->_reload($data); } else { $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']); + + // Validate receipt template to prevent path traversal + $receipt_template = $this->config['receipt_template'] ?? ''; + if (!Sale_lib::isValidReceiptTemplate($receipt_template)) { + $receipt_template = 'receipt_default'; + } + $data['receipt_template_view'] = $receipt_template; + $this->sale_lib->clear_all(); return view('sales/receipt', $data); } @@ -1159,6 +1171,13 @@ class Sales extends Secure_Controller } $data['invoice_view'] = $invoice_type; + // Validate receipt template to prevent path traversal + $receipt_template = $this->config['receipt_template'] ?? ''; + if (!Sale_lib::isValidReceiptTemplate($receipt_template)) { + $receipt_template = 'receipt_default'; + } + $data['receipt_template_view'] = $receipt_template; + return $data; } @@ -1253,6 +1272,7 @@ class Sales extends Secure_Controller $data['quote_number'] = $this->sale_lib->get_quote_number(); $data['work_order_number'] = $this->sale_lib->get_work_order_number(); + $data['keyboardShortcuts'] = $this->sale_lib->getKeyShortcuts(); // TODO: the if/else set below should be converted to a switch if ($this->sale_lib->get_mode() == 'sale_invoice') { // TODO: Duplicated code. @@ -1641,7 +1661,9 @@ class Sales extends Secure_Controller */ public function getSalesKeyboardHelp(): string { - return view('sales/help'); + return view('sales/help', [ + 'keyboardShortcuts' => $this->sale_lib->getKeyShortcuts() + ]); } /** diff --git a/app/Database/Dockerfile b/app/Database/Dockerfile index f9e8332b9..43cbc3c0b 100644 --- a/app/Database/Dockerfile +++ b/app/Database/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3.14 -MAINTAINER jekkos +LABEL maintainer="jekkos" ADD database.sql /docker-entrypoint-initdb.d/database.sql VOLUME /docker-entrypoint-initdb.d diff --git a/app/Database/Migrations/20260506000000_AddShortcutKeys.php b/app/Database/Migrations/20260506000000_AddShortcutKeys.php new file mode 100644 index 000000000..66f5347af --- /dev/null +++ b/app/Database/Migrations/20260506000000_AddShortcutKeys.php @@ -0,0 +1,46 @@ + 'key_cancel', 'value' => '27 | ESC'], + ['key' => 'key_items', 'value' => '49 | ALT + 1'], + ['key' => 'key_customers', 'value' => '50 | ALT + 2'], + ['key' => 'key_suspend', 'value' => '51 | ALT + 3'], + ['key' => 'key_suspended', 'value' => '52 | ALT + 4'], + ['key' => 'key_amount', 'value' => '53 | ALT + 5'], + ['key' => 'key_payment', 'value' => '54 | ALT + 6'], + ['key' => 'key_complete', 'value' => '55 | ALT + 7'], + ['key' => 'key_finish', 'value' => '56 | ALT + 8'], + ['key' => 'key_help', 'value' => '57 | ALT + 9'], + ]; + + $this->db->table('app_config')->ignore(true)->insertBatch($shortcutValues); + } + + public function down(): void + { + $shortcutKeys = [ + 'key_cancel', + 'key_items', + 'key_customers', + 'key_suspend', + 'key_suspended', + 'key_amount', + 'key_payment', + 'key_complete', + 'key_finish', + 'key_help', + ]; + + $this->db->table('app_config') + ->whereIn('key', $shortcutKeys) + ->delete(); + } +} diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index fb6024bc2..3ae8f71f1 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -272,6 +272,9 @@ function get_payment_options(): array $payments[lang('Sales.upi')] = lang('Sales.upi'); } + $payments[lang('Sales.bank_transfer')] = lang('Sales.bank_transfer'); + $payments[lang('Sales.wallet')] = lang('Sales.wallet'); + return $payments; } diff --git a/app/Language/en-GB/Sales.php b/app/Language/en-GB/Sales.php index ff71b2c5a..b85a86c94 100644 --- a/app/Language/en-GB/Sales.php +++ b/app/Language/en-GB/Sales.php @@ -9,6 +9,7 @@ return [ "amount_due" => "Amount Due", "amount_tendered" => "Amount Tendered", "authorized_signature" => "Authorised Signature", + "bank_transfer" => "Bank Transfer", "cancel_sale" => "Cancel", "cash" => "Cash", "cash_1" => "", @@ -222,6 +223,7 @@ return [ "update" => "Update", "upi" => "UPI", "visa" => "", + "wallet" => "Wallet", "wholesale" => "", "work_order" => "Work Order", "work_order_number" => "Work Order Number", diff --git a/app/Language/en/Config.php b/app/Language/en/Config.php index 9ed945ca4..bc8a7b5d9 100644 --- a/app/Language/en/Config.php +++ b/app/Language/en/Config.php @@ -293,6 +293,10 @@ return [ "suggestions_layout" => "Search Suggestions Layout", "suggestions_second_column" => "Column 2", "suggestions_third_column" => "Column 3", + "shortcuts" => "Shortcuts", + "shortcuts_configuration" => "Sales Keyboard Shortcut Configuration", + "shortcuts_duplicate_bindings" => "Shortcut bindings must be unique.", + "shortcuts_save_error" => "Unable to save shortcut settings.", "system_conf" => "Setup & Conf", "system_info" => "System Info", "table" => "Table", diff --git a/app/Language/en/Sales.php b/app/Language/en/Sales.php index 788d4fa6c..7d96ebe72 100644 --- a/app/Language/en/Sales.php +++ b/app/Language/en/Sales.php @@ -9,6 +9,7 @@ return [ "amount_due" => "Amount Due", "amount_tendered" => "Amount Tendered", "authorized_signature" => "Authorized Signature", + "bank_transfer" => "Bank Transfer", "cancel_sale" => "Cancel", "cash" => "Cash", "cash_1" => "", @@ -222,6 +223,7 @@ return [ "update" => "Update", "upi" => "UPI", "visa" => "", + "wallet" => "Wallet", "wholesale" => "", "work_order" => "Work Order", "work_order_number" => "Work Order Number", diff --git a/app/Language/es-ES/Sales.php b/app/Language/es-ES/Sales.php index 11f4eda39..f1e73dcf7 100644 --- a/app/Language/es-ES/Sales.php +++ b/app/Language/es-ES/Sales.php @@ -9,6 +9,7 @@ return [ "amount_due" => "Monto Adeudado", "amount_tendered" => "Cantidad Recibida", "authorized_signature" => "Firma Autorizada", + "bank_transfer" => "Transferencia Bancaria", "cancel_sale" => "Cancelar Venta", "cash" => "Efectivo", "cash_1" => "1", @@ -221,6 +222,7 @@ return [ "update" => "Editar", "upi" => "PIN UPI", "visa" => "Tarjeta Visa", + "wallet" => "Monedero", "wholesale" => "Precio al por mayor", "work_order" => "Orden trabajo", "work_order_number" => "Numero Orden Trabajo", diff --git a/app/Language/es-MX/Sales.php b/app/Language/es-MX/Sales.php index d9fc57c6c..8f744ded7 100644 --- a/app/Language/es-MX/Sales.php +++ b/app/Language/es-MX/Sales.php @@ -9,6 +9,7 @@ return [ "amount_due" => "Monto de adeudo", "amount_tendered" => "Cantidad Recibida", "authorized_signature" => "Firma Autorizada", + "bank_transfer" => "Transferencia Bancaria", "cancel_sale" => "Cancelar", "cash" => "Efectivo", "cash_1" => "", @@ -221,6 +222,7 @@ return [ "update" => "Actualizar", "upi" => "UPI", "visa" => "", + "wallet" => "Monedero", "wholesale" => "", "work_order" => "Orden de trabajo", "work_order_number" => "Número de orden de trabajo", diff --git a/app/Language/fr/Sales.php b/app/Language/fr/Sales.php index e4e6b4ea3..a4c678537 100644 --- a/app/Language/fr/Sales.php +++ b/app/Language/fr/Sales.php @@ -9,6 +9,7 @@ return [ "amount_due" => "Montant à Payer", "amount_tendered" => "Montant Présenté", "authorized_signature" => "Signature autorisée", + "bank_transfer" => "Virement Bancaire", "cancel_sale" => "Annuler la Vente", "cash" => "Espèce", "cash_1" => "", @@ -221,6 +222,7 @@ return [ "update" => "Éditer", "upi" => "UPI", "visa" => "", + "wallet" => "Portefeuille", "wholesale" => "", "work_order" => "Commande de travail", "work_order_number" => "Numéro de commande", diff --git a/app/Libraries/Sale_lib.php b/app/Libraries/Sale_lib.php index ca3aed9d4..0f02bbe2b 100644 --- a/app/Libraries/Sale_lib.php +++ b/app/Libraries/Sale_lib.php @@ -23,6 +23,19 @@ use ReflectionException; */ class Sale_lib { + private const KEY_SHORTCUT_DEFAULTS = [ + 'cancel' => ['value' => '27 | ESC', 'code' => 27, 'label' => 'ESC'], + 'items' => ['value' => '49 | ALT + 1', 'code' => 49, 'label' => 'ALT + 1'], + 'customers' => ['value' => '50 | ALT + 2', 'code' => 50, 'label' => 'ALT + 2'], + 'suspend' => ['value' => '51 | ALT + 3', 'code' => 51, 'label' => 'ALT + 3'], + 'suspended' => ['value' => '52 | ALT + 4', 'code' => 52, 'label' => 'ALT + 4'], + 'amount' => ['value' => '53 | ALT + 5', 'code' => 53, 'label' => 'ALT + 5'], + 'payment' => ['value' => '54 | ALT + 6', 'code' => 54, 'label' => 'ALT + 6'], + 'complete' => ['value' => '55 | ALT + 7', 'code' => 55, 'label' => 'ALT + 7'], + 'finish' => ['value' => '56 | ALT + 8', 'code' => 56, 'label' => 'ALT + 8'], + 'help' => ['value' => '57 | ALT + 9', 'code' => 57, 'label' => 'ALT + 9'], + ]; + private Attribute $attribute; private Customer $customer; private Dinner_table $dinner_table; @@ -95,6 +108,11 @@ class Sale_lib 'custom_tax_invoice' ]; + private const ALLOWED_RECEIPT_TEMPLATES = [ + 'receipt_default', + 'receipt_short' + ]; + public function get_invoice_type_options(): array { $invoice_types = []; @@ -105,11 +123,54 @@ class Sale_lib return $invoice_types; } + /** + * Returns the available keyboard shortcut choices for the configuration screen. + * + * @return array + */ + public function getKeyShortcutsOptions(): array + { + $keyShortcuts = []; + + foreach (self::KEY_SHORTCUT_DEFAULTS as $shortcut) { + $keyShortcuts[$shortcut['value']] = $shortcut['label']; + } + + return $keyShortcuts; + } + + /** + * Returns parsed shortcut bindings from app_config with sensible defaults. + * + * @return array + */ + public function getKeyShortcuts(): array + { + $keyboardShortcuts = []; + + foreach (self::KEY_SHORTCUT_DEFAULTS as $name => $default) { + $value = $this->config["key_$name"] ?? $default['value']; + $parts = array_map('trim', explode('|', $value, 2)); + $keyboardShortcuts[$name] = [ + 'value' => $value, + 'code' => (int)($parts[0] ?? $default['code']), + 'label' => $parts[1] ?? $default['label'] + ]; + } + + return $keyboardShortcuts; + } + public static function isValidInvoiceType(string $invoice_type): bool { return in_array($invoice_type, self::ALLOWED_INVOICE_TYPES, true); } + public static function isValidReceiptTemplate(string $receipt_template): bool + { + return in_array($receipt_template, self::ALLOWED_RECEIPT_TEMPLATES, true); + } + /** * @return array */ diff --git a/app/Models/Attribute.php b/app/Models/Attribute.php index 9626c91ca..0017a31a4 100644 --- a/app/Models/Attribute.php +++ b/app/Models/Attribute.php @@ -601,6 +601,10 @@ class Attribute extends Model */ public function saveAttributeLink(int $itemId, int $definitionId, int $attributeId): bool { + if ($attributeId <= 0) { + return false; + } + $normalizedItemId = empty($itemId) ? null : $itemId; $normalizedAttributeId = empty($attributeId) ? null : $attributeId; diff --git a/app/Models/Receiving.php b/app/Models/Receiving.php index eb54de363..18495e079 100644 --- a/app/Models/Receiving.php +++ b/app/Models/Receiving.php @@ -294,7 +294,9 @@ class Receiving extends Model lang('Sales.check') => lang('Sales.check'), lang('Sales.debit') => lang('Sales.debit'), lang('Sales.credit') => lang('Sales.credit'), - lang('Sales.due') => lang('Sales.due') + lang('Sales.due') => lang('Sales.due'), + lang('Sales.bank_transfer') => lang('Sales.bank_transfer'), + lang('Sales.wallet') => lang('Sales.wallet') ]; } diff --git a/app/Models/Reports/Summary_sales_taxes.php b/app/Models/Reports/Summary_sales_taxes.php index a739bfe7d..5b4db1077 100644 --- a/app/Models/Reports/Summary_sales_taxes.php +++ b/app/Models/Reports/Summary_sales_taxes.php @@ -33,14 +33,16 @@ class Summary_sales_taxes extends Summary_report * @param object $builder * @return void */ - protected function _where(array $inputs, object &$builder): void // TODO: hungarian notation + protected function _where(array $inputs, object &$builder): void { $builder->where('sales.sale_status', COMPLETED); - if (empty($this->config['date_or_time_format'])) { // TODO: Duplicated code - $builder->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date'])); + if (empty($this->config['date_or_time_format'])) { + $builder->where('DATE(sales.sale_time) >=', $inputs['start_date']); + $builder->where('DATE(sales.sale_time) <=', $inputs['end_date']); } else { - $builder->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']))); + $builder->where('sales.sale_time >=', $inputs['start_date']); + $builder->where('sales.sale_time <=', $inputs['end_date']); } } @@ -53,9 +55,11 @@ class Summary_sales_taxes extends Summary_report $builder = $this->db->table('sales_taxes'); if (empty($this->config['date_or_time_format'])) { - $builder->where('DATE(sale_time) BETWEEN ' . $inputs['start_date'] . ' AND ' . $inputs['end_date']); + $builder->where('DATE(sale_time) >=', $inputs['start_date']); + $builder->where('DATE(sale_time) <=', $inputs['end_date']); } else { - $builder->where('sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']))); + $builder->where('sale_time >=', $inputs['start_date']); + $builder->where('sale_time <=', $inputs['end_date']); } $builder->select('reporting_authority, jurisdiction_name, tax_category, tax_rate, SUM(sale_tax_amount) AS tax'); diff --git a/app/Models/Sale.php b/app/Models/Sale.php index b2efea5c7..4c37efda7 100644 --- a/app/Models/Sale.php +++ b/app/Models/Sale.php @@ -277,6 +277,14 @@ class Sale extends Model $builder->like('payment_type', lang('Sales.debit')); } + if ($filters['only_bank_transfer']) { + $builder->like('payment_type', lang('Sales.bank_transfer')); + } + + if ($filters['only_wallet']) { + $builder->like('payment_type', lang('Sales.wallet')); + } + $builder->groupBy('payment_type'); $payments = $builder->get()->getResultArray(); @@ -1509,5 +1517,13 @@ class Sale extends Model if ($filters['only_check']) { $builder->like('payments.payment_type', lang('Sales.check')); } + + if ($filters['only_bank_transfer']) { + $builder->like('payments.payment_type', lang('Sales.bank_transfer')); + } + + if ($filters['only_wallet']) { + $builder->like('payments.payment_type', lang('Sales.wallet')); + } } } diff --git a/app/Views/barcodes/barcode_sheet.php b/app/Views/barcodes/barcode_sheet.php index 3e27880f0..12a6a360a 100644 --- a/app/Views/barcodes/barcode_sheet.php +++ b/app/Views/barcodes/barcode_sheet.php @@ -11,31 +11,34 @@ $barcode_lib = new Barcode_lib(); - - - <?= esc(lang('Items.generate_barcodes')) ?> - - - - - - - '; - } - echo ''; - $count++; + + + + <?= esc(lang('Items.generate_barcodes')) ?> + + + + + +
' . $barcode_lib->display_barcode($item, $barcode_config) . '
+ + '; } - ?> - -
- + echo '' . $barcode_lib->display_barcode($item, $barcode_config) . ''; + $count++; + } + ?> + + + + diff --git a/app/Views/configs/barcode_config.php b/app/Views/configs/barcode_config.php index f32f9b753..0a30f505a 100644 --- a/app/Views/configs/barcode_config.php +++ b/app/Views/configs/barcode_config.php @@ -204,6 +204,7 @@ 'control-label col-xs-2 required']) ?>
'number', 'name' => 'barcode_num_in_row', 'id' => 'barcode_num_in_row', 'class' => 'form-control input-sm required', @@ -217,6 +218,9 @@
'number', + 'min' => '0', + 'max' => '100', 'name' => 'barcode_page_width', 'id' => 'barcode_page_width', 'class' => 'form-control input-sm required', @@ -232,6 +236,7 @@
'number', 'name' => 'barcode_page_cellspacing', 'id' => 'barcode_page_cellspacing', 'class' => 'form-control input-sm required', diff --git a/app/Views/configs/email_config.php b/app/Views/configs/email_config.php index 6396a978b..2871cf170 100644 --- a/app/Views/configs/email_config.php +++ b/app/Views/configs/email_config.php @@ -17,9 +17,9 @@ 'mail', - 'sendmail' => 'sendmail', - 'smtp' => 'smtp' + 'mail' => 'Mail', + 'sendmail' => 'Sendmail', + 'smtp' => 'SMTP' ], $config['protocol'], 'class="form-control input-sm" id="protocol"' @@ -55,6 +55,7 @@ 'control-label col-xs-2']) ?>
'number', 'name' => 'smtp_port', 'id' => 'smtp_port', 'class' => 'form-control input-sm', @@ -83,6 +84,7 @@ 'control-label col-xs-2']) ?>
'number', 'name' => 'smtp_timeout', 'id' => 'smtp_timeout', 'class' => 'form-control input-sm', diff --git a/app/Views/configs/info_config.php b/app/Views/configs/info_config.php index 01506465e..54c121d17 100644 --- a/app/Views/configs/info_config.php +++ b/app/Views/configs/info_config.php @@ -105,6 +105,7 @@ 'tel', 'name' => 'phone', 'id' => 'phone', 'class' => 'form-control input-sm required', @@ -122,6 +123,7 @@ 'tel', 'name' => 'fax', 'id' => 'fax', 'class' => 'form-control input-sm', diff --git a/app/Views/configs/manage.php b/app/Views/configs/manage.php index e7eb81411..af71fc87b 100644 --- a/app/Views/configs/manage.php +++ b/app/Views/configs/manage.php @@ -29,6 +29,9 @@
  • +
  • + +
  • @@ -65,6 +68,9 @@
    +
    + +
    diff --git a/app/Views/configs/shortcuts_config.php b/app/Views/configs/shortcuts_config.php new file mode 100644 index 000000000..8ccb356f6 --- /dev/null +++ b/app/Views/configs/shortcuts_config.php @@ -0,0 +1,88 @@ + lang('Sales.key_cancel'), + 'items' => lang('Sales.key_item_search'), + 'customers' => lang('Sales.key_customer_search'), + 'suspend' => lang('Sales.key_suspend'), + 'suspended' => lang('Sales.key_suspended'), + 'amount' => lang('Sales.key_tendered'), + 'payment' => lang('Sales.key_payment'), + 'complete' => lang('Sales.key_finish_sale'), + 'finish' => lang('Sales.key_finish_quote'), + 'help' => lang('Sales.key_help_modal') +]; +?> + + 'shortcuts_config_form', 'class' => 'form-horizontal']) ?> +
    +
    +
    +
    +
    +
      + + $label): ?> +
      + 'control-label col-xs-3']) ?> +
      + + +
      +
      + + +
      + 'submit_shortcuts', + 'id' => 'submit_shortcuts', + 'value' => lang('Common.submit'), + 'class' => 'btn btn-primary btn-sm pull-right' + ]) ?> +
      +
      +
      +
      +
      + + + diff --git a/app/Views/configs/system_info.php b/app/Views/configs/system_info.php index 10b3915b7..0b54c4dd6 100644 --- a/app/Views/configs/system_info.php +++ b/app/Views/configs/system_info.php @@ -25,8 +25,8 @@ use Config\OSPOS;

      -

      General Info

      -

      User Setup


      +

      General Info

      +

      User Setup


      Permissions


      @@ -42,7 +42,7 @@ use Config\OSPOS; echo "» OpenSSL: ", extension_loaded('openssl') ? 'Enabled ✓' : 'Disabled ✗', '
      '; echo "» MBString: ", extension_loaded('mbstring') ? 'Enabled ✓' : 'Disabled ✗', '
      '; echo "» Curl: ", extension_loaded('curl') ? 'Enabled ✓' : 'Disabled ✗', '
      '; - echo "» Json: ", extension_loaded('json') ? 'Enabled ✓' : 'Disabled ✗', '

      '; + echo "» Json: ", extension_loaded('json') ? 'Enabled ✓' : 'Disabled ✗', '
      '; echo "» Xml: ", extension_loaded('xml') ? 'Enabled ✓' : 'Disabled ✗', '

      '; ?> User Configuration:
      diff --git a/app/Views/configs/tax_config.php b/app/Views/configs/tax_config.php index 23248082c..7b970e6a6 100644 --- a/app/Views/configs/tax_config.php +++ b/app/Views/configs/tax_config.php @@ -51,6 +51,10 @@
      'number', + 'step' => 'any', + 'min' => '0', + 'max' => '100', 'name' => 'default_tax_1_rate', 'id' => 'default_tax_1_rate', 'class' => 'form-control input-sm', @@ -72,6 +76,10 @@
      'number', + 'step' => 'any', + 'min' => '0', + 'max' => '100', 'name' => 'default_tax_2_rate', 'id' => 'default_tax_2_rate', 'class' => 'form-control input-sm', diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index 85544bc15..b8539a420 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -101,9 +101,11 @@ p.lead { } .tabs { - list-style: none inside none; + list-style: none; + list-style-position: inside; + margin: 0; padding: 0; - margin: 0 0 -1px; + margin-bottom: -1px; } .tabs li { display: inline; diff --git a/app/Views/login.php b/app/Views/login.php index 51487c44e..81cf94f20 100644 --- a/app/Views/login.php +++ b/app/Views/login.php @@ -5,9 +5,14 @@ * @var bool $is_new_install * @var string $latest_version * @var bool $gcaptcha_enabled + * @var CodeIgniter\HTTP\IncomingRequest $request * @var array $config * @var $validation */ + +use Config\Services; + +$request = Services::request(); ?> @@ -154,11 +159,6 @@
      - - getGet('debug') == 'true') : ?> diff --git a/app/Views/partial/header.php b/app/Views/partial/header.php index 3bb51ac57..84b59545a 100644 --- a/app/Views/partial/header.php +++ b/app/Views/partial/header.php @@ -12,14 +12,16 @@ $request = Services::request(); ?> - + <?= esc($config['company']) . ' | ' . lang('Common.powered_by') . ' OSPOS ' . esc(config('App')->application_version) ?> + - + + /bootstrap.min.css"> getGet('debug') == 'true') : ?> diff --git a/app/Views/sales/help.php b/app/Views/sales/help.php index a4715d026..5c9cc82e8 100644 --- a/app/Views/sales/help.php +++ b/app/Views/sales/help.php @@ -1,3 +1,24 @@ + lang('Sales.key_cancel'), + 'items' => lang('Sales.key_item_search'), + 'customers' => lang('Sales.key_customer_search'), + 'suspend' => lang('Sales.key_suspend'), + 'suspended' => lang('Sales.key_suspended'), + 'amount' => lang('Sales.key_tendered'), + 'payment' => lang('Sales.key_payment'), + 'complete' => lang('Sales.key_finish_sale'), + 'finish' => lang('Sales.key_finish_quote'), + 'help' => lang('Sales.key_help_modal') +]; +?> +
      diff --git a/app/Views/sales/quote_email.php b/app/Views/sales/quote_email.php index 29de5b1b2..436d96d10 100644 --- a/app/Views/sales/quote_email.php +++ b/app/Views/sales/quote_email.php @@ -15,7 +15,7 @@ ?> - + diff --git a/app/Views/sales/receipt.php b/app/Views/sales/receipt.php index cd168cb33..b27031eae 100644 --- a/app/Views/sales/receipt.php +++ b/app/Views/sales/receipt.php @@ -2,11 +2,14 @@ /** * @var int $sale_id_num * @var bool $print_after_sale + * @var string $receipt_template_view * @var array $config */ use App\Models\Employee; +$template = $receipt_template_view ?? 'receipt_default'; + ?> @@ -61,6 +64,6 @@ if (isset($error_message)) {
      - + diff --git a/app/Views/sales/register.php b/app/Views/sales/register.php index ee31a1e62..ead905104 100644 --- a/app/Views/sales/register.php +++ b/app/Views/sales/register.php @@ -405,6 +405,7 @@ helper('url');
      'add_payment_form', 'class' => 'form-horizontal']) ?> + @@ -445,6 +446,7 @@ helper('url'); ?> 'add_payment_form', 'class' => 'form-horizontal']) ?> +
      @@ -565,6 +567,21 @@ helper('url');