## Token Management Panel Help

This guide explains all features, options, and best practices for managing tokens, actions, packages, budgets, and group memberships in the Token Management panel.

##### Introduction

The Token Management panel is the central place for managing the token-based economy in Style Score. Only super admin and admin users can access this panel. You can define token actions, manage user and group budgets, create token packages, credit tokens, and review all transactions and statistics.

##

- Token Actions: Define actions that cost tokens (e.g., event entry, premium features). Set name, description, cost, and category. Edit or delete actions as needed.
- Token Packages: Create and manage packages for users to purchase tokens. Set price, amount, and bonus tokens. Edit or delete packages as needed.
- Add Tokens: Credit tokens to users or groups manually. Useful for admin adjustments, rewards, or corrections.
- Budgets: View and manage all user and group budgets, including balances, spending, and creation of new budgets.
- Transactions: Review all token transactions, including debits (spending) and credits (purchases, admin adjustments).
- Statistics: See system-wide stats: total budgets, balances, transactions, and usage of actions.
- Group Management: Create groups, add/remove members, assign group roles, and manage group budgets.
- Quick Actions: Edit, delete, or view code for actions and packages. Export data for reporting.
- Integration: Use provided PHP and JavaScript code snippets to integrate token checks and charges in your own modules.

##

Who can access the Token Management panel?
  Only super admin and admin users.
How do I add a new token action?
  Click the Add Action button, fill in the details, and submit. The action will be available for use in the system.
Can I edit or delete actions/packages?
  Yes, use the edit or delete buttons next to each item. You cannot delete a package if it has been used in transactions.
How do I credit tokens to a user?
  Use the Add Tokens button, select the user, enter the amount, and submit. The user's budget will be updated.
What is a budget?
  A budget is a token balance assigned to a user or group. All token transactions are tracked against budgets.
How do I create a group or add members?
  Use the Create Group and Add Member options in the Groups tab. Assign roles within the group as needed.
How do I export data?
  Use the export buttons in the overview or statistics sections to download CSV reports of transactions, budgets, or usage.
How do I integrate token checks in my code?
  Use the provided PHP code snippets (e.g., `TokenSystem::charge('action', $user_id)`) or AJAX examples for JavaScript integration.
What happens if a user has insufficient tokens?
  The action will fail, and an error message will be shown. You can check balance before charging using `TokenSystem::canAfford()`.
Can I see which actions are most used?
  Yes, the statistics section shows usage counts and total tokens spent per action.
What if I see a database error?
  Check your database connection and table structure. Contact a super admin if the problem persists.

##

- Cannot access panel: Make sure you are logged in as an admin or super admin.
- Form not submitting: Check for required fields and valid values (e.g., positive token amounts).
- Database errors: Ensure all required tables exist and your database connection is active.
- Cannot delete package: Packages used in transactions cannot be deleted for data integrity.
- Token not credited: Check for errors in the form or database. Try manual addition if automated method fails.
- Still need help? Contact your system administrator or super admin for further assistance.

##### Best Practices

- Double-check all values before submitting forms, especially token amounts and user selections.
- Use descriptive names and categories for actions and packages for easier management.
- Review statistics regularly to monitor token usage and detect anomalies.
- Export data periodically for backup and reporting.
- Deactivate actions or packages instead of deleting if you want to preserve history.