# Button Standardization Script

## Overview
This script standardizes Cancel and Submit buttons across all create and edit forms in the application to ensure consistent styling and layout.

## Standards Applied
- **Cancel button**: `btn-outline-danger` class
- **Submit button**: `btn-outline-primary` class  
- **Button container**: `d-flex justify-content-end gap-2` (right-aligned with spacing)

## Script Location
`standardize_form_buttons.php` (root directory)

## Usage
```bash
# Dry run (preview changes without modifying files)
php standardize_form_buttons.php --dry-run

# Dry run with verbose output
php standardize_form_buttons.php --dry-run --verbose

# Apply changes
php standardize_form_buttons.php

# Apply with verbose output
php standardize_form_buttons.php --verbose
```

## Results (Initial Run)
- **Files scanned**: 138 (all create.php and edit.php files)
- **Files modified**: 136
- **Buttons fixed**: 247
- **Errors**: 0

## What the Script Does
1. **Finds all create.php and edit.php files** in the `views/` directory
2. **Fixes Cancel buttons**:
   - Searches for `<a>` and `<button>` tags containing "Cancel"
   - Replaces any `btn-*` class with `btn-outline-danger`
3. **Fixes Submit buttons**:
   - Searches for buttons with `type="submit"` or containing "Create", "Update", or "Save"
   - Replaces any `btn-*` class with `btn-outline-primary`
4. **Fixes button containers**:
   - Finds `<div>` elements containing both Cancel and Submit buttons
   - Ensures they have `d-flex justify-content-end gap-2` classes

## Reference Implementation
See `views/crm/contacts/create.php` lines 135-142 for the standard button layout:
```php
<div class="d-flex justify-content-end gap-2">
    <a href="<?= base_url('crm/contacts') ?>" class="btn btn-outline-danger">
        Cancel
    </a>
    <button type="submit" class="btn btn-outline-primary">
        <i class="bi bi-floppy"></i> Create Contact
    </button>
</div>
```

## Files Processed
All create and edit forms across modules:
- Accounting (assets, budgets, tax)
- Accounts
- Announcements
- Assumptions
- Attendance
- Automation (email templates)
- Battery Quotes
- BOMs
- Camera Audit (stations)
- Clients
- Companies
- Credit Notes
- CRM (activities, contacts, documents, support)
- Customer Payments
- Data Access
- Debit Notes
- Employees
- Goods Receipts
- Help Desk
- HR (contracts, positions, recruitment, reviews, relations)
- Inventory (movements, transfers)
- Invoices
- Journal
- Layouts
- Locations
- Manufacturing (business lines, equipment, equipment types)
- Menus
- NDAs
- Payments
- Payroll
- Permission Groups
- Products
- Projects
- Purchase Bills
- Purchase Orders
- Purchase Payments
- Purchase Requisitions
- Purchase Returns
- Purchases (contracts)
- Quotes (battery, general)
- Recurring
- RFQs
- Roles
- Sales (delivery notes, pricing, promotions, returns)
- Sales Orders
- Settings (action menus, business parameters, email templates, facilities, NDA templates, payroll, terms & conditions, user groups)
- Shipments
- Suppliers
- Tax (jurisdictions, payments)
- Users
- Vendor Payments
- Warehouses
- Work Orders

## Re-running the Script
The script is idempotent and can be safely re-run. It will:
- Skip buttons that already have the correct classes
- Only modify files that need changes
- Report which files were modified

## Notes
- The script only targets create and edit pages
- Other pages (index, show, trash) are not modified
- Action buttons in other contexts (like modals or inline actions) are not affected
- The script preserves button text and icons
