# POS விற்பனை அமைப்பு (Sales POS System)

## 📋 Overview
Keyboard-friendly Point of Sale (POS) system designed for fast data entry, similar to Excel workflow. Built for Ihita Commission Shop.

## 🚀 Features

### ✨ Key Capabilities
- **Excel-like Keyboard Navigation**: Navigate entirely using keyboard (Tab, Enter, Arrow keys)
- **Real-time Product Search**: Auto-suggest products as you type
- **Instant Calculations**: Automatic calculations for items and totals
- **கூலி (Cooli) Support**: Add additional charges to the invoice
- **Customer Balance Display**: View customer outstanding balance
- **Print Invoice**: Generate and print professional invoices

### ⌨️ Keyboard Shortcuts
| Key | Action |
|-----|--------|
| **F2** | Focus to Product Code field |
| **Enter** | Move to next field / Add to cart |
| **↑ ↓** | Navigate product suggestions |
| **F10** | Save & Print Sale |
| **Esc** | Close suggestions |

### 📊 Workflow
1. **Select Customer** (or press F2 to start)
2. **Type Product Code** → Auto-suggestions appear
3. **Press Enter** → Moves to Rate field
4. **Enter Rate** → Press Enter → Moves to Quantity
5. **Enter Quantity** → Press Enter → Adds to cart
6. Repeat for multiple items
7. **Enter கூலி (Cooli)** if applicable
8. **Press F10** or click "சேமி & அச்சிடு" to save

## 📁 File Structure
```
Sales/
├── index.php              # Main POS interface
├── print-invoice.php      # Invoice printing page
├── setup_tables.sql       # Database tables
├── api/
│   ├── search-product.php # Product auto-search API
│   ├── get-product.php    # Get product by code
│   └── save-sale.php      # Save sale transaction
├── css/
│   └── sales.css          # Compact POS styling
└── js/
    └── sales.js           # Keyboard navigation & cart logic
```

## 🗄️ Database Tables

### tblproducts
Stores product information
- ProductCode (Unique)
- ProductName
- Rate (Default price)
- Unit
- IsActive

### tblsales
Sales master record
- InvoiceNumber (Auto-generated)
- CustomerID
- SaleDate
- SubTotal
- CooliAmount
- TotalAmount
- PaymentMode
- Notes

### tblsales_details
Sales line items
- SaleID
- ProductID
- ProductCode
- ProductName
- Rate
- Quantity
- Amount

## 🔧 Installation

### 1. Database Setup
```bash
# Run from PowerShell
cd C:\wamp64\bin\mysql\mysql8.0.21\bin
Get-Content "c:\wamp64\www\customized\CommissionShop\Sales\setup_tables.sql" | .\mysql.exe -u root uzrs_commission_shop
```

### 2. Add Sample Products
Sample products are automatically created during setup. You can add more through database:
```sql
INSERT INTO tblproducts (ProductCode, ProductName, Rate, Unit, AddedBy) 
VALUES ('P006', 'பொருள் பெயர்', 500.00, 'Nos', 1);
```

## 🌐 Usage

### Access POS
```
http://localhost/customized/CommissionShop/Sales/
```

Or with customer pre-selected:
```
http://localhost/customized/CommissionShop/Sales/?customer_id=2
```

### Integration from Customer Accounts
Replace the modal in `customer/accounts.php` with a link:
```html
<a href="../Sales/?customer_id=<?php echo $customerId; ?>" class="btn btn-primary">
    புதிய பரிவர்த்தனை சேர்க்க
</a>
```

## 💡 Tips for Fast Entry

1. **Memorize Product Codes**: Faster than searching
2. **Use Tab**: Quick navigation between fields
3. **Enter Key**: Your best friend for moving forward
4. **F2 Shortcut**: Instant focus to product code from anywhere
5. **Arrow Keys**: Navigate suggestions without mouse

## 🔄 Transaction Flow

### When Sale is Saved:
1. Creates entry in `tblsales` (master)
2. Creates entries in `tblsales_details` (line items)
3. Adds **பற்று (Debit)** entry to `tblcustomer_accounts`
4. Updates customer's `CurrentBalance`
5. Generates invoice for printing

### கூலி (Cooli) Calculation
- Entered separately in dedicated field
- Added to subtotal to get grand total
- `Grand Total = SubTotal + CooliAmount`

## 🎨 Design Features

### Compact Layout
- Minimal padding and margins
- Maximum screen utilization
- Clear visual hierarchy
- Color-coded sections

### Excel-like Experience
- Monospace fonts for numbers
- Tab-based navigation
- Auto-focus management
- Quick keyboard access

## 📱 Responsive
Works on tablets and smaller screens with responsive design.

## 🔐 Security
- Session-based authentication
- SQL injection protection
- Input validation on both client and server
- Transaction-based database operations

## 📞 Support
For issues or customization requests, contact the development team.

## 📝 License
Proprietary - Ihita Commission Shop

---
**Version**: 1.0  
**Created**: October 2025  
**Language**: Tamil (தமிழ்) / English
