# VFP Views

# Visual FoxPro webnet.prg — Client-Side Structure Map

**File**: `C:\inetpub\wwwroot\FOXISAPI\webnet.prg`  
**Size**: 161,252 lines | **Procedures**: 379  
**Architecture**: URL-routed CGI entry point → procedure dispatcher → HTML form generator  

---

## Overview: Navigation & Authorization

### Entry Points
- **STARTPOINT** (line 685): Main dispatcher; checks authorization (z01/z02/z03, z06), routes to requested procedure via `bzp` parameter
- **MAINMENU** (line 14651): Homepage; shows nav menu, featured titles, error messages
- **INIT** (line 33): Pre-initialization hook

### Authorization Parameters
- **z01**: Username
- **z02**: Password (hashed)
- **z03**: Customer Key (account ID) — persists session
- **z04**: Transaction/Order ID
- **z06**: Master password (admin/staff only)
- **bzp**: Target procedure name (routing parameter)

### Core Menus
- **MENU_LEFT**: Dynamic navigation sidebar (upcoming titles, categories)
- **BRUTUS_MENU**: Primary horizontal menu bar
- **HEADER_MENU**: Secondary tier
- **NEW_TD_SECONDARY_MENU**: Catalog/specialized section menus

---

## Domain 1: INVENTORY & CATALOG

### Primary Views

#### TD_TITLE_VIEW (line 15019)
**Purpose**: Catalog browser; search/filter titles; view details; add to cart (if logged in)

**Entry Point**:  
`/SGZ?bzp=TD_TITLE_VIEW[&INVQUERY=ONSPOT|CHOICE|TRADE|BACKLIST][&PROMONAME=...][&INVLMNT=CP|TR]`

**Key Parameters**:
- `INVQUERY`: Catalog segment (ONSPOT=featured, CHOICE=customer choice, TRADE=trade/wholesale, BACKLIST=older)
- `INVLMNT`: Inventory limit (CP=Center Point, TR=Trade Publishers, CPBACK=CP backlist, TRBACK=Trade backlist)
- `PROMONAME`: Promotion filter
- `SINGLEISBN`: Direct ISBN lookup
- `SEARCH_INPUT`: Title/author/ISBN search string
- `FULLVIEW`: Toggle expanded detail (ON/OFF)
- `CREATELISTE`: Flag to create a new list

**Displays**:
- Title search results (picture grid or table)
- Individual title detail card: cover image, synopsis, author, pricing
- Purchase options (if logged in & available)
- Related titles / recommendations
- Availability status (In Stock, Out of Print, Backlist, Coming Soon)

**User Actions**:
- Search by title, author, ISBN, keyword
- Filter by publication date, category, subject
- View full detail / synopsis
- **Add to cart** (route to GENERAL_VIEW if logged in; redirect to login if not)
- Click through to related Standing Orders / Choice plans if applicable
- Switch between view modes (grid/list)

**Related Procedures**:
- `TD_TITLE_WRITE` (line 19405): Save catalog edits (admin/staff)
- `TD_AT_DISPLAY`: Render title grid/list on MAINMENU
- `PICTURE_DISPLAY`: Render photo gallery
- `GENERAL_VIEW_ACCESS_MARC` (line 20272): MARC record viewer
- `INV_READ`, `INV_WRITE`, `INV_DELETE`: Direct inventory admin

---

#### INV_READ / INV_WRITE / INV_DELETE (lines 84028, 111719, 112936)
**Purpose**: Inventory admin (staff only); add/edit/delete titles from catalog

**Entry Point**: `bzp=INV_READ|INV_WRITE|INV_DELETE` (z06 required)

**Parameters**:
- `SINGLEISBN`: ISBN to edit
- `WHATACTION`: CREATE, EDIT, DELETE
- Form fields: title, author, list price, sale price, pub date, status, etc.

**Displays**: Admin form with all title fields

**User Actions**:
- Create new catalog entry
- Bulk update pricing, pub dates, availability
- Delete deprecated titles
- Manage pricing overlays

---

### Secondary Inventory Views

#### NOSTOCK_READ / NOSTOCK_WRITE (lines 112766, 112845)
**Purpose**: Manage out-of-stock titles; mark items as unavailable; backorder notifications

#### OPEN_STANDARD_SHEETS / OPEN_SPECIAL_SHEETS (lines 104041, 104099)
**Purpose**: Downloadable worksheets (printable order forms)

---

## Domain 2: ORDERS (Web Cart & Transactional)

### Primary Views

#### GENERAL_VIEW (line 61606)
**Purpose**: Shopping cart manager; order entry; order modification; line-item editor; applies pricing/discounts

**Entry Point**:  
`/SGZ?bzp=GENERAL_VIEW[&WHATACTION=CREATENEWORDER|CREATENEWRETURN|MANAGENEWORDER|MANAGENEWRETURN][&z04=TRANSNO][&HEADER_FILE=WEBHEAD|BROHEAD|BACKHEAD|ALLHEAD][&DETAIL_FILE=WEBDETAIL|BRODETAIL|BACKDETAIL|ALLDETAIL]`

**Key Parameters**:
- `CREATENEWORDER`: Create new wholesale order (new TRANSNO, init WEBHEAD/WEBDETAIL)
- `CREATENEWRETURN`: Create return (NEW RMA, new BROHEAD/BRODETAIL)
- `MANAGENEWORDER`: Edit in-progress order
- `MANAGENEWRETURN`: Edit in-progress return
- `WHATACTION`: Secondary action (CHANGEMA=update item, DELETEITEM=remove line, etc.)
- `SEARCHBY`: BYTITLE or BYISBN for item lookup
- `HEADER_FILE` / `DETAIL_FILE`: Which order tables to use (WEB=web orders, BRO=broker returns, BACK=backorders, ALL=consolidated)
- `NEEDSAPO`: Require PO# before checkout
- `TPOTHREE`: Age filter (3-day old orders)

**Displays**:
- Order header: customer name, billing address, date, status, total
- Order line items: ISBN, title, qty, unit price, extended price, status per item
- Search panel: find titles by ISBN or title to add
- Pricing breakdown: subtotal, discounts, shipping calc, tax, final total
- Order status flags: Open, In Process, Paid, Shipped, Returned, Archived

**User Actions**:
- Create new order / return
- Search & add titles to order
- Change quantities, unit prices, line discounts
- Remove line items
- Update PO# / order special instructions
- **Submit order** (POST to ORDER_POST_FINAL)
- View order history / previous orders
- Mark items as shipped (fulfillment staff)
- Apply promotional discounts
- Split order into multiple shipments

**Related Procedures**:
- `GENERAL_VIEW_SPECIAL` (line 55562): View order history / special searches
- `GENERAL_VIEW_WINDOW_DESTROY` (line 56376): Close order (archive/finalize)
- `GENERAL_VIEW_ORDER_ADJUST` (line 59154): Price override / manual adjustments
- `GENERAL_VIEW_SHOW_HISTORY` (line 64749): Show archived orders
- `GEN_ORDER_MENU` (line 120589): Staff order entry interface
- `GEN_ORDER_MENU_WRITE` (line 122054): Process order form submission
- `GEN_ORDER_MENU_INVPROJECT` (line 122921): Special inventory project orders
- `ORDER_DELETE` (line 32708): Remove entire order
- `ORDER_POST_FINAL` (line 34507): Submit order; create transaction record; update DBF

---

#### ORDER_DELETE (line 32708)
**Purpose**: Cancel/delete order; reverse charges; mark as voided

**Entry Point**: `bzp=ORDER_DELETE[&z04=TRANSNO]`

**User Actions**:
- Confirm order cancellation
- Refund applied (if paid)
- Return inventory to available

---

#### ORDER_POST_FINAL (line 34507)
**Purpose**: Finalize & submit order; validate all required fields; create transaction; update inventory; trigger email confirmation

**Entry Point**: `bzp=ORDER_POST_FINAL[&z04=TRANSNO]`

**Validation**:
- Customer key present
- Billing address complete
- At least one line item
- Payment method specified (if required)

**Actions on Submit**:
1. Write transaction record (TRANSACT table)
2. Update WEBHEAD/WEBDETAIL status to "In Process"
3. Trigger inventory hold (if on-demand)
4. Generate order confirmation email
5. Route to FOH if fulfillment needed
6. Redirect to GENERAL_VIEW with confirmation

---

#### FOH_DETAIL (line 27031)
**Purpose**: Line-item detail viewer; shows item-level status during fulfillment

**Entry Point**: `bzp=FOH_DETAIL[&z04=TRANSNO]`

---

## Domain 3: STANDING ORDERS (Subscription & Auto-Ship)

### Primary Views

#### STANDING_PROFILE (line 25895)
**Purpose**: View standing order summary; subscription settings; auto-renewal options; customer profile photos

**Entry Point**:  
`/SGZ?bzp=STANDING_PROFILE[&z03=CUSTKEY][&SEE_CONTROLS=YES][&HIDE_BUTTONS=YES]`

**Key Parameters**:
- `z03`: Customer key
- `SEE_CONTROLS`: Show admin buttons (YES for staff, omit for customers)
- `HIDE_BUTTONS`: Suppress checkout buttons
- `TSENDPROFILE`: Email profile (staff action)

**Displays**:
- Account holder name, address, contact info
- Standing order plan type (Club A, Club B, Choice, etc.)
- Subscription status (Active, Paused, Cancelled, Expired)
- Plan details: # of selections per month, format, pricing tier
- Account photos (staff pic, email, title, phone)
- Customer class / promotional tier (Class A, Class B, etc.)

**User Actions**:
- View profile details (read-only for customers)
- **Edit profile** (route to AM_NEWMHEAD if admin)
- Email profile (staff action)
- Manage standing order settings

**Related Procedures**:
- `STANDING_WRITE` (line 88165): Edit standing order header fields
- `STANDING_HEAD` (line 89282): Create new standing order / change plan
- `STANDING_CLEAN` (line 95495): Billing consistency review / cleanup
- `STANDING_RENEW` (line 96021): Renew expiring subscription
- `STANDING_CONFIRMATION` (line 114317): Confirm standing order after edit
- `STANDING_NOTE_DISPLAY` (line 27603): View account notes & communications
- `STANDING_DESTINATION` (line 139622): Manage shipping address for standing order
- `CLEARSOWRITE` (line 95959): Archive/close standing order

#### STANDING_HEAD (line 89282)
**Purpose**: Standing order creation; plan selection; billing setup

**Entry Point**: `bzp=STANDING_HEAD[&z03=CUSTKEY]`

**Displays**:
- Plan type selector (Club A, Club B, Choice, etc.)
- Billing address form
- Selection preference (automatic, manual, hybrid)
- Frequency selector (monthly, quarterly, etc.)
- Payment method

**User Actions**:
- Select plan type
- Set up billing
- Choose auto-ship options
- **Save & activate plan** → STANDING_CONFIRMATION

---

#### STANDING_CLEAN (line 95495)
**Purpose**: Billing consistency audit; find orphaned/duplicate records; fix account state

**Entry Point**: `bzp=STANDING_CLEAN` (staff only, z06 required)

**Displays**:
- Account billing state (summary)
- Orphaned standing order entries
- Duplicate payment records
- Mismatch warnings

**User Actions**:
- Review billing anomalies
- Consolidate / merge records
- Archive stale entries

---

### Secondary Standing Order Views

#### VIEW_BACKORDERS (line 95149)
**Purpose**: Show backorder items on customer's standing order; when they'll ship

#### STANDING_NOTE_DISPLAY (line 27603)
**Purpose**: View account notes & communications history

---

## Domain 4: TRADE HOUSE (B2B Wholesale Orders)

### Primary Views

#### TRADE_HOUSE_CUSTOMER_VIEW (line 49592)
**Purpose**: Trade/wholesale customer dashboard; show plan participation, order history, inventory for upcoming titles, manage selections

**Entry Point**:  
`/SGZ?bzp=TRADE_HOUSE_CUSTOMER_VIEW[&z03=CUSTKEY][&SORTMETHOD=...][&MONTHLIMIT=...][&SHOWBACKLIST=ON|OFF]`

**Key Parameters**:
- `SORTMETHOD`: Sort display by title, author, publication date, etc.
- `MONTHLIMIT`: Show only titles within N months
- `SHOWBACKLIST`: Include backlist titles (ON/OFF)
- `TEMPFULL`: Show full detail (OFF to compact)
- `CHANGELISTING`: Pagination control

**Displays**:
- Trade publisher customer account name & location
- Upcoming trade titles (publication schedule)
- Per-title information: cover, ISBN, title, author, pub date, list price, trade discount %
- Selection checkboxes / quantity fields (if plan allows custom selections)
- Order history summary
- Account rep contact info

**User Actions**:
- Browse upcoming trade titles
- Select titles for standing order / shipment
- Change quantities per title
- Sort/filter display
- **Submit selections** → TRADE_HOUSE_SELECT_DISPLAY
- View backorders & in-process shipments

**Related Procedures**:
- `TRADE_HOUSE_SELECT_DISPLAY` (line 52522): Save selections; confirm order
- `NEW_TRADE_HOUSE_CUSTOMER_VIEW_WRITE` (line 50800): Write selection changes
- `TRADE_HOUSE_SELECT_HEADER` (line 40911): Header tier for selection flow
- `TRADE_HOUSE_ADMIN_ORDER_UPDATE` (line 131884): Staff-side order adjustment
- `TRADE_HOUSE_GENERAL_SCREEN` (line 130316): Admin view of all orders
- `TRADE_HOUSE_PLAN_PRINT_LOOK` (line 134685): Print-ready order summary
- `TRADE_HOUSE_LOAD_LEVEL` (line 133536): Load inventory tier/allocation
- `TRADE_HOUSE_PUBDATE` (line 131884): Filter titles by pub date range
- `TRADE_HOUSE_PICTURES_COPY` (line 42679): Cache cover images
- `TRADE_HOUSE_ZEBRA` (line 42875): Barcode/shipping label integration
- `TRADE_HOUSE_EMAIL_SUBSYSTEM` (line 41943): Bulk email to trade customers

---

#### TRADE_HOUSE_SELECT_DISPLAY (line 52522)
**Purpose**: Confirm & save trade customer selections before checkout

**Entry Point**: `bzp=TRADE_HOUSE_SELECT_DISPLAY[&z03=CUSTKEY][&SWITCHVALUE=...]`

**Displays**:
- Selected titles (list with qty, total)
- Order total (with trade discounts applied)
- Billing address (confirm)
- Shipping address

**User Actions**:
- Review selections
- Adjust quantities (back to TRADE_HOUSE_CUSTOMER_VIEW)
- **Confirm & submit** → creates transaction

---

#### REVIEW_TRADE_PLANS (line 152822)
**Purpose**: Staff view; review all trade plans, allocations, customer participation

**Entry Point**: `bzp=REVIEW_TRADE_PLANS` (z06 required)

---

### Secondary Trade Views

#### TRADE_HOUSE_SWITCH_WRITE / TITLE (lines 130020, 130088)
**Purpose**: Switch between trade publishers (staff function); manage plan routing

#### TRADE_PREPAID_DATE / PREPAIDS (lines 151951, 142157)
**Purpose**: Track trade customer prepayments; aging; collection status

#### NEW_TRADE_SUMMARY (line 32106)
**Purpose**: Summary view of new trade orders in process

---

## Domain 5: FULFILLMENT & BACK-ORDER MANAGEMENT

### Primary Views

#### FOH (line 56387)
**Purpose**: Fulfillment Operations Hub; staff view of all orders needing shipment; fulfillment status tracking; shipment creation

**Entry Point**:  
`/SGZ?bzp=FOH[&z04=TRANSNO|ORDER_TRANSNO=...][&HEADER_FILE=...][&DETAIL_FILE=...][&TPOTHREE=...|SHOWARCH|SHOWPAY|CANARCH|TRADEBO|BTPAID|BTUNCONFIRMED|INCURRENT|INPAID|FORARCH]`

**Key Parameters**:
- `ORDER_TRANSNO`: Specific order to show
- `TPOTHREE`: Filter by age (3+ days old)
- `SHOWARCH`: Include archived orders
- `SHOWPAY`: Show unpaid orders
- `TRADEBO`: Trade orders only
- `BTPAID`: Paid orders ready to ship
- `BTUNCONFIRMED`: Orders awaiting payment confirmation

**Displays**:
- Order list (WEBHEAD/WEBDETAIL or BROHEAD/BRODETAIL or BACKHEAD/BACKDETAIL)
- For each order:
  - Customer name, account number
  - Order date, PO#
  - Line items with qty ordered vs. qty allocated vs. qty shipped
  - Status per line (Open, Partial, Complete, Back-ordered, On-hold)
  - Total books/units, dollar value
  - Fulfillment notes / special instructions

**User Actions**:
- Filter orders by status (open, paid, unpaid, archived, etc.)
- View order detail
- **Mark items as shipped** (create fulfillment record)
- Apply fulfillment holds
- Merge orders into single shipment
- Generate packing slips / labels
- Archive completed orders

**Related Procedures**:
- `FOH_DETAIL` (line 27031): Item-level fulfillment detail
- `FOH_BT_MARK_WOULD` (line 128660): Mark item for fulfillment
- `FOH_BT_LINE_ITEMS` (line 128701): Edit fulfillment quantities
- `CPBACKORDERS` (line 60095): Backorder-specific fulfillment
- `BACKMANAGEMENT` (line 154206): Backorder aging, reneging, cancellation
- `BACKMANAGEMENT_MARK` (line 155330): Mark backorder action
- `BACKMANAGEMENT_WRITE` (line 155753): Write backorder changes

---

#### CPBACKORDERS (line 60095)
**Purpose**: Backorder dashboard; show all unfulfilled items; aging; projected fulfillment dates

**Entry Point**: `bzp=CPBACKORDERS[&SHOWARCH=ON]`

**Displays**:
- Backorder line items (customer, ISBN, title, qty, date ordered, expected ship date)
- Backorder age (days outstanding)
- Projected availability (from INVENT.pubdate for future titles)
- Customer contact info (for follow-up)

**User Actions**:
- Sort by age, customer, title
- View fulfillment status
- **Mark as shipped** (when inventory arrives)
- **Renege / cancel** (if title cancelled / unlikely to restock)
- Bulk email to customers with status updates

**Related Procedures**:
- `BACKMANAGEMENT` (line 154206): Backorder admin
- `BACKMANAGEMENT_MARK` / `WRITE` (lines 155330, 155753): Change backorder status
- `MAKE_AVAILABLE` (line 145548): Trigger fulfillment when stock arrives

---

#### BACKMANAGEMENT (line 154206)
**Purpose**: Comprehensive backorder management; aging reports; collection workflow

**Entry Point**: `bzp=BACKMANAGEMENT` (z06 required)

**Displays**:
- Backorder inventory by ISBN (total demand vs. available qty)
- Backorder customer list (name, qty on order, date ordered)
- Aging buckets (0–30 days, 30–60, 60–90, 90+)
- Alert flags (titles unlikely to be published; customers unresponsive)

**User Actions**:
- Bulk mark items as shipped
- Bulk cancel backorders
- Generate aging reports
- Email customers with updates

---

## Domain 6: ACCOUNT MANAGEMENT & PROFILES

### Primary Views

#### ACCOUNT_MANAGEMENT_FULLVIEW (line 76615)
**Purpose**: Complete account admin dashboard; staff view for customer profiles; notes, contact info, subscription status, history

**Entry Point**:  
`/SGZ?bzp=ACCOUNT_MANAGEMENT_FULLVIEW[&z06=MASTERPASS][&z03=CUSTKEY][&MENUMODE=LESS|FULL][&RETURNPAGE=...][&NOTELIMIT=...][&NOTEACTION=...]`

**Key Parameters**:
- `MENUMODE`: LESS (summary) or FULL (detailed; default)
- `RETURNPAGE`: Redirect after edit
- `NOTELIMIT`: Show N most recent notes
- `NOTEACTION`: Note operation (NEW, EDIT, DELETE, VIEWIT)
- `SUBLEVEL`: Tab selection (PROFILE, NOTES, CONTACTS, BILLING, STANDING_ORDERS, etc.)

**Displays**:
- **PROFILE tab**: Name, address, email, phone, contact history
- **NOTES tab**: Customer communication log (internal memos, follow-ups, service requests)
- **CONTACTS tab**: Multiple shipping/billing addresses
- **BILLING tab**: Payment history, account balance, payment method
- **STANDING ORDERS tab**: Current subscriptions, plan details, renewal dates
- **PURCHASES tab**: Order history, lifetime value
- **CLASS tab**: Account classification (A/B/C/D/F/G/K/L/Q/R/S), promotional tier
- **BONUSES tab**: Free/gift books earned, bonus selections

**User Actions**:
- View all account data
- **Add note** (internal comment, follow-up flag)
- Edit address (EDTSETLINK)
- Change contact info
- Update account classification
- View order history
- Manage linked contacts
- Archive / close account

**Related Procedures**:
- `ACCOUNT_DISPLAY` (line 24783): Customer card view (summary)
- `AM_CONTACTS` (line 25567): Manage secondary addresses
- `AM_WORK` (line 29646): Account edit form (detailed entry)
- `AM_WORK_DETAILS` (line 30024): Address details editor
- `AM_WORK_SPECIAL` (line 30670): Special handling flags
- `AM_BASE_LETTER` (line 31611): Account communication letter
- `AM_COMMCODE` (line 23926): Set customer comm code (sales rep assignment)
- `AM_SETCALL` (line 24379): Set call priority
- `ACCOUNT_KEYED_ACCESS` (line 97212): Direct key lookup
- `EDTLINKPUB` (line 25312): Link account to publisher
- `EDTSETLINK` (line 25460): Set primary address
- `NEWMCHANGECOMMCODE` (line 68305): Change comm code
- `AM_NEWMHEAD` (line 68318): Staff account edit form (new style)
- `AM_NEWMHEAD_TARGETS` (line 74669): Account targeting / segmentation

---

#### AM_NEWMHEAD (line 68318)
**Purpose**: Comprehensive account editor (newer UI); customer class, promotions, preferences, contact mgmt

**Entry Point**: `bzp=AM_NEWMHEAD[&z06=MASTERPASS][&z03=CUSTKEY]`

**Displays**:
- Account header (customer name, key, type)
- Tabs:
  - Basic info (name, address, phone, email)
  - Contact mgmt (ship-to addresses, contacts)
  - Account settings (call priority, comm code, promotional flags)
  - Standing orders (if applicable)
  - Special handling
  - Account history

**User Actions**:
- Edit customer details
- Manage addresses
- Assign sales rep
- Set promotional flags (promote_western, promote_romance, etc.)
- Mark inactive / do-not-contact

---

#### ACCOUNT_LOG_ON (line 35395)
**Purpose**: Customer login; authentication; session creation

**Entry Point**:  
`/SGZ?bzp=ACCOUNT_LOG_ON[&THISUSERNAME=...][&THISPASSWORD=...][&WHERETOGO=MAINMENU|GENERAL_VIEW|...]`

**Parameters**:
- `THISUSERNAME`: Customer username (email or account number)
- `THISPASSWORD`: Password
- `WHERETOGO`: Redirect target after login (default: MAINMENU)

**Flow**:
1. Validate credentials against PASSWORD table (z01, z02 hash, z03 key)
2. Create session (persisted in z03)
3. Redirect to WHERETOGO

**Error Handling**:
- Invalid username/password → show login form with error
- Expired session → force re-login
- Locked account → show message; contact staff

**Related Procedures**:
- `ACCOUNT_LOG_OFF` (line 46709): Customer logout; clear session
- `ACCOUNT_LOG_OFF_WRITE` (line 47106): Finalize logout

---

#### ACCOUNT_LOG_OFF (line 46709)
**Purpose**: Customer logout; session cleanup

**Entry Point**: `bzp=ACCOUNT_LOG_OFF[&z03=CUSTKEY]`

**Actions**:
- Clear z03 session
- Redirect to MAINMENU
- Show "logged out" confirmation

---

### Secondary Account Views

#### ACCOUNT_ACCESS (line 22453)
**Purpose**: Account lookup; select customer from list

#### ACCOUNT_DISPLAY (line 24783)
**Purpose**: Condensed customer card; summary info

#### ACCOUNT_MANAGEMENT_ONESCREEN_WRITE (line 78214)
**Purpose**: Single-screen account edit form submission

#### ACCOUNT_MANAGEMENT_READ (line 78576)
**Purpose**: Account lookup / search interface

#### ACCOUNT_MANAGEMENT_KICKBACK (line 81219)
**Purpose**: Referral / kickback commission tracking

#### ACCOUNT_MANAGEMENT_CALLSTAT (line 81744)
**Purpose**: Call history / follow-up tracking

#### AM_DELETEBASES (line 83457)
**Purpose**: Account cleanup; archive old accounts

#### AM_REVIEW_DETAILS (line 114744)
**Purpose**: Review account details before finalizing changes

#### AM_WORK_CHOICE (line 113456)
**Purpose**: Customer choice plan selection (part of standing order flow)

---

## Domain 7: PRICING & DISCOUNTS

### Integration Points (Not Standalone Procedures)

Pricing is embedded throughout order workflows:

- **GENERAL_VIEW**: Applies pricing based on customer class (A/B/C), promotional tier, purchase quantity, standing order membership
- **TD_TITLE_VIEW**: Shows list price, sale price, discount % (if applicable) per title per customer class
- **FOH**: Displays pricing in order summary (subtotal, discounts, shipping, tax)
- **ORDER_POST_FINAL**: Recalculates & validates pricing before submission

**Pricing Calculation Components**:
- Base list price (from INVENT.listprice)
- Customer discount (from PASSFILE.discount by account)
- Promotional overlays (from PRICINGOVERLAY by ISBN × account type)
- Volume discounts (if qty >= threshold)
- Standing order tier discounts
- Coupon discounts (from COUPON tables)

**Pricing Sources**:
- INVENT.listprice (base)
- PASSFILE.company, discount, priceoverride
- PRICINGOVERLAY (promo pricing per ISBN × account class)
- COUPON (coupon code discounts)

---

## Domain 8: REPORTS & EXPORTS

### Primary Views

#### PRINTCAT (line 98465)
**Purpose**: Catalog export / print; downloadable booklist in PDF or plain text

**Entry Point**:  
`/SGZ?bzp=PRINTCAT[&z03=CUSTKEY][&PROMONAME=...][&INVQUERY=...][&FORMAT=PDF|TEXT][&COLUMNS=...]`

**Key Parameters**:
- `FORMAT`: PDF, Text, CSV, or HTML
- `COLUMNS`: Select which fields to export (ISBN, title, author, price, status, etc.)
- `PROMONAME`: Limit to specific promotion

**Displays** (in browser or downloadable file):
- Title list with selected columns
- Sortable by ISBN, title, author, pub date, price
- Prices shown based on customer class (if logged in)

**User Actions**:
- Select export format
- Choose columns
- **Download** file

**Related Procedures**:
- `PRINTTABLE` (line 97611): Generic table export
- `CREATE_OUTPUT_DATA` (line 98544): Build export dataset
- `PROOF_WEB_COPY` (line 102948): Proof / QA copies (internal)
- `CREATE_PROMOTIONS` (line 108480): Promo booklet generator
- `CREATE_PROMOTIONS_WRITE` (line 108706): Process promo creation form

---

#### PRINT_STANDING (line 129164)
**Purpose**: Print standing order summary; customer standing order statement / renewal notice

**Entry Point**: `bzp=PRINT_STANDING[&z03=CUSTKEY][&FORMAT=PDF]`

**Displays**:
- Customer standing order profile
- Current plan (type, selections/month, pricing)
- Recent shipments (dates, titles, totals)
- Renewal date / expiration notice
- Payment method

---

#### GEN_EDITORIAL_MENU (line 117941)
**Purpose**: Editorial staff interface; manage published content, reviews, author info

**Entry Point**: `bzp=GEN_EDITORIAL_MENU` (staff only, z06 required)

**Displays**:
- Editorial content list (by topic, author, title)
- Edit/delete controls

**Related Procedures**:
- `GEN_EDITORIAL_SHOW` (line 120589): Display editorial content
- `GEN_EDITORIAL_UPDATE_COMPUTER_SALES` (line 119991): Update sales tracking

---

#### GEN_ONIX_MENU (line 115725)
**Purpose**: ONIX metadata management; export ONIX format (industry standard book data)

**Entry Point**: `bzp=GEN_ONIX_MENU` (z06 required)

**Related Procedures**:
- `GEN_ONIX_WRITE` (line 116055): Export ONIX data

---

#### GEN_ORDER_MENU (line 120589)
**Purpose**: Staff order entry; quick add orders for customers (phone orders, manual entry)

**Entry Point**: `bzp=GEN_ORDER_MENU[&z06=MASTERPASS]`

**Displays**:
- Customer lookup/selection
- Title search panel
- Order form (similar to GENERAL_VIEW but staff-driven)

**Related Procedures**:
- `GEN_ORDER_MENU_WRITE` (line 122054): Process staff order submission
- `GEN_ORDER_MENU_INVPROJECT` (line 122921): Special project orders

---

---

## Domain 9: EDI & DATA EXCHANGE

### Primary Views

#### EDI_MENU (line 139788)
**Purpose**: EDI (Electronic Data Interchange) admin; manage inbound/outbound order feeds; file management

**Entry Point**: `bzp=EDI_MENU` (z06 required)

**Displays**:
- Incoming EDI files (orders from trading partners)
- In-process files (being parsed/imported)
- Outgoing files (acknowledgments, shipping notices, invoices)
- File status, timestamps, line count, error logs

**User Actions**:
- View incoming order feed
- Trigger import
- Resend confirmation / shipping notice
- Download error report

**Related Procedures**:
- `EDI_FACT_MENU` (line 141394): FACT (Forwarding Agent Commission Transaction) submenu
- `EDI_FACT_SHOWCONTENTS` (line 141836): Show FACT file contents
- `EDI_MANIFEST` (line 142884): Shipping manifest generator
- `EDI_SCANNER_ENTRY` (line 147127): Barcode scanner entry (receiving)
- `EDI_SHOWCONTENTS` (line 148806): Show file contents
- `EDI_CREATE_NEW_SHIPMENT` (line 149040): Create new shipment record
- `EDI_INVOICE_TRANSPORT` (line 149330): Invoice EDI exchange

---

#### EDI_MANIFEST (line 142884)
**Purpose**: Generate EDI shipping manifest; structured shipment data for EDI partners

**Entry Point**: `bzp=EDI_MANIFEST[&z03=CUSTKEY|z06=MASTERPASS]`

**Displays**:
- Shipment items (line count, totals)
- Structured EDI format (ORDERS, ORDERS message, line items, pricing)
- Print-ready manifest

---

---

## Domain 10: NOTIFICATIONS, EMAILS & MESSAGING

### Primary Views

#### EMZ_SERVICES (line 66208)
**Purpose**: Email marketing / promotion management; bulk email campaigns

**Entry Point**: `bzp=EMZ_SERVICES[&z03=CUSTKEY|z06=MASTERPASS]`

**Displays**:
- Service offerings (email templates, announcement options)
- Customer opt-in status
- Email history

**Related Procedures**:
- `EMZ_SERVICES_VIEW` (line 66906): Email template viewer
- `EMZ_SERVICES_WRITE` (line 68201): Save email preferences
- `EMZ_SERVICES_CHARACTERS` (line 54634): Character limit check for email
- `EMZ_UPCOMING_TITLES` (line 54756): Auto-email upcoming titles to customer

---

#### NEW_EMAIL_CONSOLE (line 136450)
**Purpose**: Unified email management; compose & send emails to customers

**Entry Point**: `bzp=NEW_EMAIL_CONSOLE[&z06=MASTERPASS]`

**Related Procedures**:
- `NEW_EMAIL_BASIC_UPDATE` (line 136961): Send basic notification email
- `NEW_EMAIL_START_UPDATE` (line 137021): Send order confirmation email
- `NEW_EMAIL_INVENTORY_UPDATE` (line 137131): Send inventory notification
- `NEW_EMAIL_BACKORDER_UPDATE` (line 137722): Send backorder status update
- `NEW_EMAIL_CREATE_FILE_UPDATE` (line 139514): Create email template file

---

#### MAIL_CONSOLE_MENU (line 85519)
**Purpose**: Internal staff communication; mail/note system

**Entry Point**: `bzp=MAIL_CONSOLE_MENU[&z06=MASTERPASS]`

**Displays**:
- Staff inbox (messages from other staff)
- Message threads (by customer, project, topic)
- Unread count, recent activity

**Related Procedures**:
- `MAIL_CONSOLE_WRITE` (line 85783): Compose staff message
- `MAIL_CONSOLE_READ` (line 126260): Read staff message
- `MAIL_CONSOLE_CS` (line 126260): Customer service variant
- `DELETEMAILHEAD` / `DELETEMAILWRITE` (lines 94671, 94729): Delete message

---

#### MAIL_CONSOLE_MENU (variants)
- `BULKMAIL_MENU_READ` (line 98795): Bulk mailing list editor
- `BULKMAIL_MENU_WRITE` (line 98965): Save bulk mail settings

---

---

## Domain 11: PLATFORM & UTILITY FUNCTIONS

### Core UI Procedures

#### WEBSITE_HEAD (line 45014)
**Purpose**: Page header template; includes nav, logo, session info

**Displays**:
- Site logo & branding
- Top navigation (Home, Catalog, My Account, Log Out)
- User greeting (if logged in)
- Search bar

---

#### WEBSITE_TAIL (line 45796)
**Purpose**: Page footer template; includes copyright, links, contact info

---

#### HEADER_INFO (function, not procedure)
**Purpose**: Build HTML header with <title>, <meta>, <style> tags

---

#### MY_PREFERENCES (line 44345)
**Purpose**: User preferences editor; display options, email frequency, etc.

**Entry Point**: `bzp=MY_PREFERENCES[&z03=CUSTKEY]`

**Related Procedures**:
- `MY_PREFERENCES_WRITE` (line 44846): Save preference changes

---

#### CP_CONNECTION (line 47530)
**Purpose**: System diagnostics; check database/server connectivity

**Entry Point**: `bzp=CP_CONNECTION`

---

#### MENU_SWITCH (line 54460)
**Purpose**: Secondary menu router; switches between major sections

---

#### WEBCOMMENTS_HEAD (line 47182)
**Purpose**: User feedback/survey form header

---

#### SERVICE_REQUESTS (line 151553)
**Purpose**: Customer service request form; complaint/inquiry submission

**Entry Point**: `bzp=SERVICE_REQUESTS[&z03=CUSTKEY]`

---

#### ONSPOT_SERVICES_MENU (line 80459)
**Purpose**: ONSPOT (featured promotions) service menu

**Related Procedures**:
- `ONSPOT_SERVICES_VIEW` (line 80584): Display ONSPOT offerings

---

#### BONUS_BOOK_USE (line 31798)
**Purpose**: Manage free/bonus book selections in standing orders

**Entry Point**: `bzp=BONUS_BOOK_USE[&z03=CUSTKEY]`

**Related Procedures**:
- `BONUS_HEAD` (line 115212): Bonus book admin (staff)
- `BONUS_HEAD_DELETE` (line 115616): Delete bonus allocation
- `BONUS_HEAD_WRITE` (line 115658): Save bonus allocation

---

#### ACCOUNT_MANAGEMENT_SHOW_ALLDETAIL (line 156286)
**Purpose**: Show all customer addresses/contacts (detail view)

---

#### ACCOUNT_MANAGEMENT_FILL_DAILY (line 158174)
**Purpose**: Daily fill/fulfillment tracking (internal)

---

#### ACCOUNT_MANAGEMENT_FILL_CHOICE (line 158781)
**Purpose**: Choice plan fulfillment (which titles selected & shipped)

---

#### ACCOUNT_MANAGEMENT_CREATE_FLIER (line 156951)
**Purpose**: Generate promotional flier for account (mail merge)

---

#### ARCHIVE_ORDERS (line 146614)
**Purpose**: Archive/purge old orders from active database

**Entry Point**: `bzp=ARCHIVE_ORDERS` (z06 required)

---

#### MARKET_INFO_WRITE (line 94212)
**Purpose**: Update market research data / demographic info

---

#### CHECK_CASHING (line 146614)
**Purpose**: Track check clearing status (payment method tracking)

---

#### FASTPRINT (line 158814)
**Purpose**: Fast/print-on-demand order variant; rapid turnaround titles

**Entry Point**: `bzp=FASTPRINT[&z03=CUSTKEY]`

**Related Procedures**:
- `FASTMARK` (line 158781): Flag for fast printing
- `FASTPRINT_DELETE` (line 160065): Cancel fast order
- `FASTPRINT_CREATE` (line 160254): Create fast order

---

#### FIXSHIP (line 160928)
**Purpose**: Correct shipping records; fix shipped-but-not-marked entries

**Related Procedures**:
- `FIXSHIPWRITE` (line 161010): Write shipping correction

---

#### INVENTORY_FIX (line 161077)
**Purpose**: Correct inventory discrepancies; manual quantity adjustments

**Related Procedures**:
- `INVENTORY_FIX_WRITE` (line 161194): Write inventory correction

---

#### DATA_TRANSFER_MODULE (line 104208)
**Purpose**: Export/import data; data interchange with external systems

**Related Procedures**:
- `DATA_TRANSFER_MODULE_WRITE` (line 104818): Process data transfer

---

#### EASYDATA (line 99863)
**Purpose**: Quick-entry tool; bulk data paste/import

---

---

## Domain 12: PFP (Publisher For Profit)

*No dedicated procedures identified; likely integrated into standing order / Trade House flows.*

---

---

## Cross-Domain Workflows

### A. Typical Customer Journey

1. **Browse Catalog** → TD_TITLE_VIEW (search, filter, view titles)
2. **Login** → ACCOUNT_LOG_ON (z03 session created)
3. **Add to Cart** → GENERAL_VIEW (shopping cart in WEBHEAD/WEBDETAIL)
4. **Manage Cart** → GENERAL_VIEW (adjust quantities, pricing calculated)
5. **Checkout** → ORDER_POST_FINAL (validate, create TRANSACT record)
6. **Fulfillment** → FOH (staff marks shipped)
7. **Logout** → ACCOUNT_LOG_OFF

### B. Standing Order Signup Flow

1. **Browse Plan Options** → MAINMENU or TD_TITLE_VIEW
2. **Initiate Plan** → STANDING_HEAD (select plan type, billing)
3. **Confirm Plan** → STANDING_CONFIRMATION (review & activate)
4. **Auto-Fulfill** → Monthly selections → GENERAL_VIEW (customer-initiated) or auto-shipment
5. **View Status** → STANDING_PROFILE (check subscription status)

### C. Trade/Wholesale Flow

1. **Trade Customer Logs In** → ACCOUNT_LOG_ON (z03 for trade account)
2. **Browse Titles** → TRADE_HOUSE_CUSTOMER_VIEW (upcoming trade titles, allocations)
3. **Select Titles** → Make selections → TRADE_HOUSE_SELECT_DISPLAY
4. **Confirm Order** → TRADE_HOUSE_SELECT_DISPLAY (finalize, create TRANSACT)
5. **Fulfillment** → FOH (BROHEAD/BRODETAIL or equivalent)
6. **Shipping** → EDI_MANIFEST (send shipment notification)

### D. Staff Order Entry Flow

1. **Staff Logs In** → ACCOUNT_LOG_ON with z06 (master password)
2. **Search Customer** → ACCOUNT_ACCESS or ACCOUNT_MANAGEMENT_READ
3. **Create Order** → GENERAL_VIEW with CREATENEWORDER
4. **Add Items** → Search TD_TITLE_VIEW, add to cart
5. **Submit** → ORDER_POST_FINAL
6. **Ship** → FOH (mark shipped)

### E. Backorder Management Flow

1. **View Backorders** → CPBACKORDERS (all unfulfilled items)
2. **Check Availability** → MAKE_AVAILABLE (when stock arrives)
3. **Auto-Ship or Notify** → Trigger GENERAL_VIEW fulfillment or email notification
4. **Archive** → Move to archive table

---

## Key Parameters Summary

### Session / Auth
- `z01`: Username
- `z02`: Password (hashed)
- `z03`: Customer Key (session ID)
- `z04`: Transaction/Order ID
- `z06`: Master password (staff/admin)

### Navigation
- `bzp`: Procedure name (routing parameter)
- `WHERETOGO`: Redirect target after login
- `RETURNPAGE`: Return target after action

### Ordering / Cart
- `HEADER_FILE`: WEBHEAD, BROHEAD, BACKHEAD, ALLHEAD, DAYHEAD, DAILYHEAD
- `DETAIL_FILE`: WEBDETAIL, BRODETAIL, BACKDETAIL, ALLDETAIL, DAYDETAIL, DAILYDETAIL
- `WHATINFILE`: Status filter (WEBCOMPLETE, WEBINCOMPLETE, etc.)
- `WHATACTION`: Action type (CREATENEWORDER, MANAGENEWORDER, CHANGEITEM, DELETEITEM, CHANGEQTY, CHANGEPRICE, etc.)

### Catalog
- `INVQUERY`: Catalog segment (ONSPOT, CHOICE, TRADE, BACKLIST, UPCOMING)
- `INVLMNT`: Inventory limit (CP=Center Point, TR=Trade, CPBACK, TRBACK)
- `PROMONAME`: Promotion/feature group
- `SINGLEISBN`: Direct ISBN lookup
- `SEARCH_INPUT`: Search query (title, author, ISBN)
- `FULLVIEW`: Toggle detailed display (ON/OFF)

### Filters / Display
- `SORTMETHOD`: Sort order (TITLE, AUTHOR, PUBDATE, PRICE, etc.)
- `MONTHLIMIT`: Show only titles within N months
- `TPOTHREE`: Filter by age (3+ days old)
- `SHOWARCH`: Include archived items
- `SHOWBACKLIST`: Include backlist

### Email / Promotion
- `ADVERTISE`: Show advertisements (ON/OFF)
- `BOOKB`: Book club code
- `SALEPRICE`: Override sale price
- `DISCOUNT`: Override discount %
- `KICKBACK`: Referral commission amount
- `SUBJECT`: Email subject

---

## Summary: Procedure Count by Domain

| Domain | Procedures | Key Views |
|--------|-----------|-----------|
| Inventory/Catalog | 8+ | TD_TITLE_VIEW, TD_TITLE_WRITE, INV_READ/WRITE/DELETE, NOSTOCK_* |
| Orders | 10+ | GENERAL_VIEW, GENERAL_VIEW_*, ORDER_DELETE, ORDER_POST_FINAL, GEN_ORDER_MENU |
| Standing Orders | 8+ | STANDING_PROFILE, STANDING_HEAD, STANDING_WRITE, STANDING_CLEAN, VIEW_BACKORDERS |
| Trade House | 12+ | TRADE_HOUSE_CUSTOMER_VIEW, TRADE_HOUSE_SELECT_DISPLAY, REVIEW_TRADE_PLANS |
| Fulfillment | 8+ | FOH, CPBACKORDERS, BACKMANAGEMENT, BACKMANAGEMENT_*, FOH_DETAIL |
| Accounts | 20+ | ACCOUNT_MANAGEMENT_FULLVIEW, AM_NEWMHEAD, ACCOUNT_LOG_ON/OFF, AM_* |
| Pricing | (embedded) | — (integrated into GENERAL_VIEW, TD_TITLE_VIEW, FOH) |
| Reports | 12+ | PRINTCAT, PRINT_STANDING, GEN_EDITORIAL_*, GEN_ONIX_*, GEN_ORDER_MENU* |
| EDI | 8+ | EDI_MENU, EDI_FACT_*, EDI_MANIFEST, EDI_INVOICE_* |
| Emails/Messaging | 8+ | EMZ_SERVICES*, NEW_EMAIL_*, MAIL_CONSOLE_*, BULKMAIL_* |
| Platform/Utility | 25+ | MAINMENU, MY_PREFERENCES, CP_CONNECTION, WEBSITE_HEAD/TAIL, etc. |
| PFP | (embedded) | — (integrated into standing orders / trade flows) |

---

## Architecture Notes

### Parameter Passing
- URL query string (`/SGZ?param1=value1&param2=value2...`)
- Form POST (same parameter set)
- MBCODED: Pre-encoded parameter set passed between procedures

### Session Management
- z03 (customer key) persists across page loads
- z06 (master password) required for staff actions
- Session timeout: Not explicitly documented (likely server-side)

### Error Handling
- TNEW_ERROR_INFO: URL-encoded error message shown to user
- Procedures validate input and return error parameters to MAINMENU or prior screen
- Critical errors: Route to BADPROG procedure (generic error page)

### Database Tables (Key References)
- INVENT: Catalog (title, author, ISBN, list price, pub date, status)
- PASSWORD: Users (z01/z02, z03 key, email, contact)
- PASSFILE: Customer pricing (discount %, company type)
- WEBHEAD / WEBDETAIL: Web orders (in progress)
- BROHEAD / BRODETAIL: Broker/return orders
- BACKHEAD / BACKDETAIL: Backorder records
- ALLHEAD / ALLDETAIL: Consolidated order view
- STANDING: Standing orders (subscriptions)
- VENDOR: Trade/wholesale customer accounts
- CUSTNOTE: Customer notes / communication log
- TRANSACT: Transaction log (audit trail)
- BONDETAIL: Bonus book allocations
- COUPON: Promotional codes
- PRICINGOVERLAY: Dynamic pricing by ISBN × account class

---

## References

- **Entry Point**: STARTPOINT (line 685) — Main dispatcher
- **Main Menu**: MAINMENU (line 14651) — Homepage
- **Session Auth Parameters**: z01, z02, z03, z06
- **Routing Parameter**: bzp (procedure name)
- **Error Parameter**: TNEW_ERROR_INFO (URL-encoded message)