# Comprehensive Analysis of Old Central Shipping Page

## Overview
The Shipping page in old central is a comprehensive shipment management system built with Phalcon framework. It provides functionality for order tracking, bulk shipping, individual order shipping, and shipment management.

## Core Functionalities

### 1. Main Shipment Page (`/shipment/index`)
**Location**: `/home/opstest/www/central/app/views/shipment/index.phtml`

**Features**:
- **Order Tracking Section**:
  - Simple form to track shipments by order number
  - POST request to `/shipment/track/`
  
- **Bulk Shipping Section**:
  - File upload for bulk processing
  - Warehouse selection dropdown
  - "Ignore Items Status" checkbox option
  - POST request to `/shipment/bulk/`
  
- **Latest Shipments List**:
  - Displays paginated list of shipments (50 per page)
  - Shows: Order #, Shipment #, Customer, Address, Carrier, Method, Warehouse, Tracking #, Submitted date, Shipped date
  - Delete functionality for unshipped orders
  - Expandable rows showing individual items in each shipment
  - Notes section for each shipment

### 2. Ship Order Page (`/shipment/ship/{orderId}`)
**Location**: `/home/opstest/www/central/app/views/shipment/ship.phtml`

**Features**:
- **Address Display**:
  - Shows billing and shipping addresses side by side
  
- **Shipping Method Selection**:
  - Warehouse dropdown
  - Carrier dropdown (FedEx, UPS, USPS, Amazon)
  - Method dropdown (Ground, Express, Priority, etc.)
  - Package selection
  
- **Order Items Table**:
  - Checkbox to select items to ship
  - Product details
  - Status
  - Part number
  - Best carrier recommendation
  - Supplier information
  - ETA
  - Stock availability
  - Extra partslink options
  
- **Shipment Details Form**:
  - Company name
  - Customer name
  - Address (2 lines)
  - City, State, Zip
  - Country
  - Phone
  - Insurance provider selection
  - Declared value for insurance
  - Package dimensions (length, width, height)
  - Package weight
  - Signature options
  
- **Actions**:
  - "Ship Now" button - processes the shipment
  - "Shipping Cost Estimates" button - gets rate quotes

### 3. Track Order Page (`/shipment/track`)
**Location**: `/home/opstest/www/central/app/views/shipment/track.phtml`

**Features**:
- Search results showing all shipments for an order
- Displays shipment details and tracking information
- Shows associated items

### 4. Bulk Shipping (`/shipment/bulk`)
**Features**:
- CSV/text file upload processing
- Batch shipment creation
- Progress reporting

## Database Structure

### Tables Used:
1. **shipments**
   - shipment_id (primary key)
   - external_shipment_id (ShipStation ID)
   - warehouse_id
   - carrier
   - shipment_method
   - tracking_number
   - notes
   - date_submitted
   - date_shipped
   - shipping_cost

2. **orders_items_shipments** (pivot table)
   - shipment_id
   - order_item_id
   - Links shipments to order items

3. **orders_items**
   - order_item_id
   - order_id
   - Product and supplier information

4. **orders**
   - order_id
   - external_order_id
   - Customer and shipping information

## Business Logic

### Key Controllers:
- **ShipmentController** (`/home/opstest/www/central/app/controllers/ShipmentController.php`)
  - indexAction() - Main listing page
  - trackAction() - Order tracking
  - shipAction() - Individual order shipping
  - bulkAction() - Bulk shipping
  - deleteAction() - Delete shipment
  - resultAction() - Process shipment submission
  - dropshipAction() - Dropship functionality
  - getDeliveryAction() - AJAX endpoint for delivery estimates

### Key Helpers:
- **ShipmentHelper** - Core business logic for shipping
  - Carrier and method mappings
  - ShipStation integration
  - Rate calculation
  - Warehouse management
  
- **WarehouseHelper** - Warehouse-specific logic
  - Warehouse codes and names
  - Availability checking

### Integration Points:
1. **ShipStation API** - Primary shipping platform
2. **Carrier APIs** - Direct integration with FedEx, UPS, USPS
3. **Amazon Shipping** - Amazon carrier integration

## AJAX/JavaScript Features
1. Delete shipment confirmation modal
2. Dynamic shipping rate calculations
3. Real-time delivery estimates
4. Item selection management

## Key Differences from New Central
The new central already has:
- Laravel/Filament framework (vs Phalcon)
- Eloquent models setup
- Basic shipment listing and deletion
- Some ShipStation integration

## What Needs to be Ported
1. **Ship Individual Order functionality** - The entire shipping form and processing
2. **Bulk shipping** - File upload and batch processing
3. **Shipping rate estimates** - Real-time rate calculation
4. **Item selection for shipping** - Partial order fulfillment
5. **Carrier/method selection logic** - Dynamic dropdowns
6. **Package dimension calculations**
7. **Insurance options**
8. **Signature requirements**
9. **Dropship functionality**
10. **Enhanced tracking display**