# Details

Commit `fcfeb446887114e06f0c2cd19a84d2511fc2e6c1` adds an explicit Daily or Weekly cap-period selector to the Text Search campaign edit page. Previously, users could edit a cap amount without seeing or changing its stored period, which could leave a weekly period in place when a daily cap was intended.

# Plan

- Added a Cap Period selector to the RPC / Conversion Cap form.
- Loaded the existing `cap_type`, defaulting to Daily when no value is available.
- Persisted the selected period through the existing RPC-cap update flow.
- Restricted submitted period values to Daily or Weekly.
- Preserved compatibility with clients that do not submit `cap_type`.

# Impact - Low

The change affects authorized management users editing RPC or conversion caps for Text Search campaigns. Existing records remain unchanged until a campaign is saved with a selected cap period.

# Sites Impacted

- AdCenter Text Search campaign edit page
- AdCenter campaign update endpoint

# Tables Impacted

- `affiliate_campaign_rpc` — updates `cap_type` when an authorized user saves a cap period.
- `affiliate_campaign_rpc_history` — records the change through the existing audit flow.
- No schema changes or data migrations.

# Rollback Plan - Revert commit `fcfeb446887114e06f0c2cd19a84d2511fc2e6c1`

# Reviewed By - To be confirmed

# Proof of Testing Evidence

- PHP syntax checks passed for `Campaign.php` and `form-rpc-cap.php`.
- `git diff --check` passed.
- Focused checks passed for Daily and Weekly persistence in RPC and conversion modes.
- Verified that omitting `cap_type` preserves the existing period.
- Verified that the form selects the stored period.

# Deployment Date / Time - October 2, 2026; time to be confirmed

# Developer - Allen

# Testing Instructions

1. Sign in as a management user authorized to edit RPC settings.
2. Open a Text Search campaign that has RPC or conversion-cap settings.
3. Confirm the Cap Period field displays the campaign's stored Daily or Weekly value.
4. Select **RPC Mode**, enter a click cap of `150`, choose **Daily**, and save.
5. Reopen the campaign and confirm the cap remains `150` and the period remains **Daily**.
6. Confirm the campaign list uses a cap of `150`; after four clicks, the remaining value should be `146`.
7. Change the period to **Weekly**, save, and confirm **Weekly** remains selected after reopening the campaign.
8. Confirm the campaign list uses the rounded daily average of `21` for a weekly cap of `150`; after four clicks, the remaining value should be `17`.
9. Repeat the period-save check in **Conversion Cap** mode.
10. Submit an invalid `cap_type` and confirm the update is rejected with `Cap period must be Daily or Weekly.`
