403Webshell
Server IP : 216.92.14.13  /  Your IP : 216.73.217.126
Web Server : Apache
System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64
User : rmlac2fmr ( 1040637)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/home/rmlac2fmr/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/home/rmlac2fmr/cleanup_craft_halstead.py
#!/usr/bin/env python3
"""
JBT Travel Ops — Convert Marc Craft and Alex Halstead to Hotel-Only entries

Both have person + assignment only (no TR, no hotel booking, no PD).
This script:
  1. Creates a standalone hotel booking for each (no personId — exactly like
     entries added via "Add Hotel-Only Guest" modal)
  2. Removes their person profiles and their NMDC (S2) assignments
  3. Backs up db.json first

Hotel info from user (Hilton Capitol Hill, check-in 5/22, check-out 5/25):
  - Marc Craft:    Conf 3445992777
  - Alex Halstead: Conf 3448467646
"""
import json
import os
import sys
import shutil
import time
from datetime import datetime

candidates = ['db.json', './data/db.json', os.path.expanduser('~/public_html/jn.com/ops/data/db.json')]
db_path = next((c for c in candidates if os.path.exists(c)), None)
if not db_path: print("ERROR: db.json not found"); sys.exit(1)

# Backup first
backup_path = db_path + '.backup-' + datetime.now().strftime('%Y%m%d-%H%M%S')
shutil.copy2(db_path, backup_path)
print(f"✓ Backup created: {backup_path}\n")

with open(db_path, 'r') as f:
    db = json.load(f)

# Find the show ID for NMDC2026 to confirm S2 is right
show_s2 = next((s for s in db.get('shows', []) if s.get('id') == 'S2'), None)
if show_s2:
    print(f"Target show: {show_s2.get('code','S2')} - {show_s2.get('name','')}\n")

# Look up hotel name from show config (so it matches exactly what's stored elsewhere)
hotel_name = 'Hilton Washington DC Capitol Hill'  # default
hotel_props = (show_s2 or {}).get('hotelConfig', {}).get('properties', [])
for p in hotel_props:
    pname = (p.get('name','') or '').lower()
    if 'hilton' in pname and 'capitol' in pname:
        hotel_name = p.get('name')
        break
print(f"Using hotel name: '{hotel_name}'\n")

# Target person IDs from diagnostic
TARGETS = [
    {
        'personId': 'P810205985mvl5',
        'assignmentId': 'A1776981020598l6j5S2',
        'firstName': 'Marc',
        'lastName': 'Craft',
        'title': 'Musco Tech',
        'conf': '3445992777',
    },
    {
        'personId': 'P81020598cqcp4',
        'assignmentId': 'A177698102059837t4S2',
        'firstName': 'Alex',
        'lastName': 'Halstead',
        'title': 'Musco Tech',
        'conf': '3448467646',
    },
]

# Confirm targets exist before any destructive operation
missing = []
for t in TARGETS:
    p = next((x for x in db.get('persons',[]) if x.get('id') == t['personId']), None)
    if not p:
        missing.append(f"Person {t['personId']} ({t['firstName']} {t['lastName']})")
if missing:
    print("ABORTING — these expected records are missing:")
    for m in missing: print("  - " + m)
    sys.exit(1)

# Build hotel bookings
created_hotels = []
now_iso = datetime.now().isoformat() + 'Z'
ts_seed = int(time.time() * 1000)

for i, t in enumerate(TARGETS):
    hotel_id = f'H{ts_seed + i}cleanup'
    booking = {
        'id': hotel_id,
        'personId': None,           # detached — this is what makes it hotel-only
        'showId': 'S2',
        'hotel': hotel_name,
        'conf': t['conf'],
        'roomNum': '',
        'dept': '',
        'title': t['title'],
        'lastName': t['lastName'],
        'firstName': t['firstName'],
        'loyaltyNum': '',
        'roomCode': '',
        'roomType': '',
        'checkIn': '2026-05-22',
        'checkOut': '2026-05-25',
        'rate': 0,
        'taxFees': 0,
        'sharing': False,
        'sharingWith': '',
        'billing': '',
        'billingNotes': '',
        'notesForHotel': '',
        'invoiceTotal': '',
        'internalNotes': f'Converted from crew profile to hotel-only on {datetime.now().strftime("%Y-%m-%d")}',
        'status': 'pending',
        'changeHighlight': '#FFFF00',
        'assigned': True,
        'lastModified': now_iso
    }
    db.setdefault('hotelBookings', []).append(booking)
    created_hotels.append(booking)

# Delete persons + assignments
removed_persons = 0
removed_assigns = 0
for t in TARGETS:
    before_p = len(db.get('persons', []))
    db['persons'] = [p for p in db['persons'] if p.get('id') != t['personId']]
    removed_persons += (before_p - len(db['persons']))
    before_a = len(db.get('assignments', []))
    db['assignments'] = [a for a in db['assignments'] if a.get('personId') != t['personId']]
    removed_assigns += (before_a - len(db['assignments']))

# Save
with open(db_path, 'w') as f:
    json.dump(db, f, indent=2)

print("=" * 60)
print("DONE")
print("=" * 60)
for h in created_hotels:
    print(f"  ✓ Hotel booking created: {h['id']}")
    print(f"      {h['firstName']} {h['lastName']} — {h['hotel']} — Conf #{h['conf']}")
    print(f"      {h['checkIn']} → {h['checkOut']}")
print(f"\n  ✓ Removed persons:     {removed_persons}")
print(f"  ✓ Removed assignments: {removed_assigns}")
print(f"\n  Backup: {backup_path}")
print()
print("NEXT STEPS:")
print("  1. Restart Node:")
print("       kill -9 `lsof -t -i :3000`")
print("  2. Hard-refresh browser")
print("  3. Verify:")
print("     ✓ Both appear on Hotel grid")
print("     ✗ Neither in Crew Database")
print("     ✗ Neither in Missing Forms widget")

Youez - 2016 - github.com/yon3zu
LinuXploit