diff --git a/CLAUDE.md b/CLAUDE.md index 65e422e..0d4ac6c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,9 +18,9 @@ This is a classical PrestaShop legacy module with no npm, Composer, Makefile, or | File | Role | |------|------| -| `cyp_withdrawalbutton.php` | Main module class: install/uninstall, config form, hook handlers, utility methods | +| `simple_withdrawalbutton.php` | Main module class: install/uninstall, config form, hook handlers, utility methods | | `controllers/front/withdraw.php` | Public front controller for the withdrawal form (no auth required) | -| `controllers/admin/AdminCypWithdrawalController.php` | Backoffice list/detail view with status management | +| `controllers/admin/AdminSimpleWithdrawalController.php` | Backoffice list/detail view with status management | ### Request Flow @@ -32,7 +32,7 @@ This is a classical PrestaShop legacy module with no npm, Composer, Makefile, or ### Database -Single table `ps_cyp_withdrawal_request`. Schema is defined inline in `cyp_withdrawalbutton.php::install()` — no separate SQL files. Records are intentionally **not deleted on uninstall** (legal compliance). +Single table `ps_cyp_withdrawal_request`. Schema is defined inline in `simple_withdrawalbutton.php::install()` — no separate SQL files. Records are intentionally **not deleted on uninstall** (legal compliance). Key fields: `order_reference`, `withdrawal_scope` (ENUM: full|partial), `status` (ENUM: new|processing|closed), `customer_ip_hash` / `user_agent_hash` (SHA256, privacy). @@ -54,6 +54,6 @@ The items field in `form.tpl` is conditionally shown via vanilla JS only when `w - Use `pSQL()` for all DB string interpolation; `(int)` cast for integers - Hook registration/deregistration in `install()`/`uninstall()` -- Admin tab registered as `AdminCypWithdrawal` — the controller class name must match +- Admin tab registered as `AdminSimpleWithdrawal` — the controller class name must match - Module config stored via `Configuration::get/updateValue()` - Email sending uses `Mail::Send()` with template files in `mails/{lang}/` diff --git a/controllers/admin/AdminCypWithdrawalController.php b/controllers/admin/AdminSimpleWithdrawalController.php similarity index 94% rename from controllers/admin/AdminCypWithdrawalController.php rename to controllers/admin/AdminSimpleWithdrawalController.php index 51eca91..5289fd3 100644 --- a/controllers/admin/AdminCypWithdrawalController.php +++ b/controllers/admin/AdminSimpleWithdrawalController.php @@ -4,12 +4,12 @@ if (!defined('_PS_VERSION_')) { exit; } -class AdminCypWithdrawalController extends ModuleAdminController +class AdminSimpleWithdrawalController extends ModuleAdminController { public function __construct() { $this->bootstrap = true; - $this->table = Cyp_Withdrawalbutton::TABLE_REQUEST; + $this->table = Simple_withdrawalbutton::TABLE_REQUEST; $this->identifier = 'id_withdrawal_request'; $this->lang = false; $this->explicitSelect = true; @@ -103,7 +103,7 @@ class AdminCypWithdrawalController extends ModuleAdminController } $ok = Db::getInstance()->update( - Cyp_Withdrawalbutton::TABLE_REQUEST, + Simple_withdrawalbutton::TABLE_REQUEST, ['status' => $status], '`id_withdrawal_request` = ' . (int) $id ); @@ -119,7 +119,7 @@ class AdminCypWithdrawalController extends ModuleAdminController { $id = (int) Tools::getValue($this->identifier); $row = Db::getInstance()->getRow( - 'SELECT * FROM `' . _DB_PREFIX_ . pSQL(Cyp_Withdrawalbutton::TABLE_REQUEST) . '` + 'SELECT * FROM `' . _DB_PREFIX_ . pSQL(Simple_withdrawalbutton::TABLE_REQUEST) . '` WHERE `id_withdrawal_request` = ' . (int) $id ); diff --git a/controllers/front/withdraw.php b/controllers/front/withdraw.php index bfa52ab..82c26b1 100644 --- a/controllers/front/withdraw.php +++ b/controllers/front/withdraw.php @@ -4,7 +4,7 @@ if (!defined('_PS_VERSION_')) { exit; } -class Cyp_WithdrawalbuttonWithdrawModuleFrontController extends ModuleFrontController +class Simple_withdrawalbuttonWithdrawModuleFrontController extends ModuleFrontController { public $ssl = true; public $auth = false; @@ -32,8 +32,8 @@ class Cyp_WithdrawalbuttonWithdrawModuleFrontController extends ModuleFrontContr 'csrf_token' => $this->module->getFrontToken(), 'action_url' => $this->context->link->getModuleLink($this->module->name, 'withdraw', [], true), 'success_data' => $this->successData, - 'privacy_url' => (string) Configuration::get(Cyp_Withdrawalbutton::CONF_PRIVACY_URL), - 'revocation_url' => (string) Configuration::get(Cyp_Withdrawalbutton::CONF_REVOCATION_URL), + 'privacy_url' => (string) Configuration::get(Simple_withdrawalbutton::CONF_PRIVACY_URL), + 'revocation_url' => (string) Configuration::get(Simple_withdrawalbutton::CONF_REVOCATION_URL), ]); if ($this->currentView === 'confirm') { diff --git a/cyp_withdrawalbutton.php b/simple_withdrawalbutton.php similarity index 96% rename from cyp_withdrawalbutton.php rename to simple_withdrawalbutton.php index e23febc..ce19566 100644 --- a/cyp_withdrawalbutton.php +++ b/simple_withdrawalbutton.php @@ -14,18 +14,18 @@ if (!defined('_PS_VERSION_')) { exit; } -class Cyp_Withdrawalbutton extends Module +class Simple_withdrawalbutton extends Module { - public const TABLE_REQUEST = 'cyp_withdrawal_request'; - public const CONF_SHOP_EMAIL = 'CYP_WITHDRAWAL_SHOP_EMAIL'; - public const CONF_RATE_LIMIT = 'CYP_WITHDRAWAL_RATE_LIMIT'; - public const CONF_PRIVACY_URL = 'CYP_WITHDRAWAL_PRIVACY_URL'; - public const CONF_REVOCATION_URL = 'CYP_WITHDRAWAL_REVOCATION_URL'; - public const CONF_RETENTION_MONTHS = 'CYP_WITHDRAWAL_RETENTION_MONTHS'; + public const TABLE_REQUEST = 'simple_withdrawal_request'; + public const CONF_SHOP_EMAIL = 'SIMPLE_WITHDRAWAL_SHOP_EMAIL'; + public const CONF_RATE_LIMIT = 'SIMPLE_WITHDRAWAL_RATE_LIMIT'; + public const CONF_PRIVACY_URL = 'SIMPLE_WITHDRAWAL_PRIVACY_URL'; + public const CONF_REVOCATION_URL = 'SIMPLE_WITHDRAWAL_REVOCATION_URL'; + public const CONF_RETENTION_MONTHS = 'SIMPLE_WITHDRAWAL_RETENTION_MONTHS'; public function __construct() { - $this->name = 'cyp_withdrawalbutton'; + $this->name = 'simple_withdrawalbutton'; $this->tab = 'administration'; $this->version = '0.1.0'; $this->author = 'Cyprès / Akiko Sake'; @@ -100,7 +100,7 @@ class Cyp_Withdrawalbutton extends Module private function installTab() { - $className = 'AdminCypWithdrawal'; + $className = 'AdminSimpleWithdrawal'; if ((int) Tab::getIdFromClassName($className) > 0) { return true; } @@ -120,7 +120,7 @@ class Cyp_Withdrawalbutton extends Module private function uninstallTab() { - $idTab = (int) Tab::getIdFromClassName('AdminCypWithdrawal'); + $idTab = (int) Tab::getIdFromClassName('AdminSimpleWithdrawal'); if ($idTab <= 0) { return true; } @@ -182,7 +182,7 @@ class Cyp_Withdrawalbutton extends Module } } - $adminLink = $this->context->link->getAdminLink('AdminCypWithdrawal'); + $adminLink = $this->context->link->getAdminLink('AdminSimpleWithdrawal'); $withdrawalLink = $this->getWithdrawalLink(); $this->context->smarty->assign([ @@ -488,7 +488,7 @@ class Cyp_Withdrawalbutton extends Module } $scopeLabel = $this->getScopeLabel($data['withdrawal_scope'], $isoCode); - $adminLink = $this->context->link->getAdminLink('AdminCypWithdrawal'); + $adminLink = $this->context->link->getAdminLink('AdminSimpleWithdrawal'); $templateVars = [ '{id_withdrawal_request}' => (string) $idWithdrawalRequest, diff --git a/views/templates/admin/config_info.tpl b/views/templates/admin/config_info.tpl index 8524e51..4c67147 100644 --- a/views/templates/admin/config_info.tpl +++ b/views/templates/admin/config_info.tpl @@ -1,14 +1,14 @@
- {l s='Frontend withdrawal page:' mod='cyp_withdrawalbutton'} + {l s='Frontend withdrawal page:' mod='simple_withdrawalbutton'} {$withdrawal_link|escape:'html':'UTF-8'}
- {l s='Back office requests:' mod='cyp_withdrawalbutton'} - {l s='Open withdrawal requests' mod='cyp_withdrawalbutton'} + {l s='Back office requests:' mod='simple_withdrawalbutton'} + {l s='Open withdrawal requests' mod='simple_withdrawalbutton'}
- {l s='The module keeps existing withdrawal records when it is uninstalled. Delete the database table manually only after checking your retention obligations.' mod='cyp_withdrawalbutton'} + {l s='The module keeps existing withdrawal records when it is uninstalled. Delete the database table manually only after checking your retention obligations.' mod='simple_withdrawalbutton'}
| {l s='Received' mod='cyp_withdrawalbutton'} | +{l s='Received' mod='simple_withdrawalbutton'} | {$request.created_at|escape:'html':'UTF-8'} |
|---|---|---|
| {l s='Confirmation sent' mod='cyp_withdrawalbutton'} | +{l s='Confirmation sent' mod='simple_withdrawalbutton'} | {if $request.confirmation_sent_at}{$request.confirmation_sent_at|escape:'html':'UTF-8'}{else}-{/if} |
| {l s='Order reference' mod='cyp_withdrawalbutton'} | +{l s='Order reference' mod='simple_withdrawalbutton'} |
{$request.order_reference|escape:'html':'UTF-8'}
{if $order_link != ''}
- {l s='Open order' mod='cyp_withdrawalbutton'} + {l s='Open order' mod='simple_withdrawalbutton'} {/if} |
| {l s='Name' mod='cyp_withdrawalbutton'} | +{l s='Name' mod='simple_withdrawalbutton'} | {$request.customer_name|escape:'html':'UTF-8'} |
| {l s='Email' mod='cyp_withdrawalbutton'} | +{l s='Email' mod='simple_withdrawalbutton'} | {$request.customer_email|escape:'html':'UTF-8'} |
| {l s='Scope' mod='cyp_withdrawalbutton'} | +{l s='Scope' mod='simple_withdrawalbutton'} | {if $request.withdrawal_scope == 'partial'} - {l s='Partial withdrawal' mod='cyp_withdrawalbutton'} + {l s='Partial withdrawal' mod='simple_withdrawalbutton'} {else} - {l s='Full order' mod='cyp_withdrawalbutton'} + {l s='Full order' mod='simple_withdrawalbutton'} {/if} |
| {l s='Affected items / quantities' mod='cyp_withdrawalbutton'} | +{l s='Affected items / quantities' mod='simple_withdrawalbutton'} | {if $request.withdrawal_items_text}{$request.withdrawal_items_text|escape:'html':'UTF-8'|nl2br nofilter}{else}-{/if} |
| {l s='Message' mod='cyp_withdrawalbutton'} | +{l s='Message' mod='simple_withdrawalbutton'} | {if $request.message}{$request.message|escape:'html':'UTF-8'|nl2br nofilter}{else}-{/if} |