INSERT INTO service_catalog (code, name, description, hours, category, skill_level, flat_rate_code, warranty, seasonal) VALUES -- ========= GENERAL / DIAGNOSTIC ========= ('GEN-001','General inspection','Full safety and condition inspection of unit',0.8,'General','B','GEN',0,0), ('GEN-002','Pre-purchase inspection','Comprehensive inspection for potential purchase',1.2,'General','B','GEN',0,0), ('GEN-003','Full diagnostic – no start','Electrical/fuel/spark/compression diagnosis for no-start condition',1.0,'Diagnostics','A','DIAG',0,0), ('GEN-004','Full diagnostic – running issue','Diagnosis of misfire, bog, hesitation, or poor running',1.2,'Diagnostics','A','DIAG',0,0), ('GEN-005','Electrical diagnostic – short/parasite','Trace and locate electrical short or parasitic draw',1.5,'Diagnostics','A','ELEC',0,0), ('GEN-006','Charging system test','Test stator, regulator/rectifier, and battery under load',0.5,'Diagnostics','B','ELEC',0,0), ('GEN-007','Compression test – single cylinder','Compression test on single cylinder engine',0.4,'Diagnostics','B','DIAG',0,0), ('GEN-008','Compression test – multi cylinder','Compression test on multi-cylinder engine',0.7,'Diagnostics','B','DIAG',0,0), ('GEN-009','Leak-down test – single cylinder','Leak-down test and interpretation',0.6,'Diagnostics','A','DIAG',0,0), ('GEN-010','Leak-down test – multi cylinder','Leak-down test on multi-cylinder engine',0.9,'Diagnostics','A','DIAG',0,0), -- ========= ENGINE – TOP END ========= ('ENG-101','Top end rebuild – air-cooled single','Remove and rebuild top end, hone, piston, rings, gaskets',4.5,'Engine','A','TOPEND',0,0), ('ENG-102','Top end rebuild – liquid-cooled single','Remove and rebuild top end, coolant service included',5.0,'Engine','A','TOPEND',0,0), ('ENG-103','Top end rebuild – 2-stroke single','Piston, rings, power valve cleaning, gaskets',3.8,'Engine','A','TOPEND',0,0), ('ENG-104','Top end rebuild – twin','Top end rebuild on parallel or V-twin',6.0,'Engine','A','TOPEND',0,0), ('ENG-105','Cylinder head gasket replacement – single','Replace head gasket, torque to spec, fluids',3.0,'Engine','A','HEAD',0,0), ('ENG-106','Cylinder head gasket replacement – multi','Replace head gasket on multi-cylinder engine',5.5,'Engine','A','HEAD',0,0), ('ENG-107','Valve clearance check – single OHC','Check and record valve clearances',1.2,'Engine','B','VALVE',0,0), ('ENG-108','Valve clearance adjust – shim under bucket','Adjust clearances, cams out, shim selection',3.0,'Engine','A','VALVE',0,0), ('ENG-109','Valve clearance adjust – screw & locknut','Adjust clearances on rocker style valvetrain',1.5,'Engine','B','VALVE',0,0), ('ENG-110','Cam chain replacement – single','Replace cam chain, guides as needed',3.5,'Engine','A','TIMING',0,0), ('ENG-111','Cam chain replacement – multi','Replace cam chain on multi-cylinder engine',5.0,'Engine','A','TIMING',0,0), ('ENG-112','Timing chain tensioner replacement','Replace and set cam chain tensioner',1.0,'Engine','B','TIMING',0,0), ('ENG-113','Engine oil & filter change','Drain and refill engine oil, replace filter, inspect',0.4,'Engine','C','OIL',0,1), ('ENG-114','Engine oil change – ATV/SxS','Oil and filter change on ATV or side-by-side',0.6,'Engine','C','OIL',0,1), ('ENG-115','Spark plug replacement – single','Replace spark plug, inspect cap and wire',0.3,'Engine','C','TUNE',0,0), ('ENG-116','Spark plug replacement – multi','Replace all spark plugs on multi-cylinder engine',0.6,'Engine','C','TUNE',0,0), ('ENG-117','Air filter service – foam','Clean, oil, and reinstall foam air filter',0.4,'Engine','C','TUNE',0,1), ('ENG-118','Air filter replacement – paper','Replace paper air filter element',0.3,'Engine','C','TUNE',0,1), ('ENG-119','Throttle body sync – multi','Synchronize throttle bodies or carb bank',1.2,'Engine','A','TUNE',0,0), ('ENG-120','Idle and mixture tune – carbureted','Adjust idle speed and mixture screws',0.7,'Engine','B','TUNE',0,0), -- ========= FUEL SYSTEM / CARBURETION ========= ('FUEL-201','Carb clean – single','Remove, disassemble, clean, and reinstall single carb',2.0,'Fuel','B','CARB',0,0), ('FUEL-202','Carb clean – twin','Remove, clean, and sync twin carbs',3.0,'Fuel','B','CARB',0,0), ('FUEL-203','Carb clean – 3–4 cylinder bank','Remove, clean, bench sync multi-carb bank',4.5,'Fuel','A','CARB',0,0), ('FUEL-204','Fuel injector clean – off-bike','Remove injectors, bench clean and flow test',1.5,'Fuel','B','EFI',0,0), ('FUEL-205','Fuel pump replacement – in-tank','Replace in-tank fuel pump assembly',1.8,'Fuel','B','EFI',0,0), ('FUEL-206','Fuel filter replacement – external','Replace inline fuel filter and inspect lines',0.4,'Fuel','C','FUEL',0,0), ('FUEL-207','Fuel tank flush – contaminated fuel','Drain, flush, and clean tank for contamination',1.5,'Fuel','B','FUEL',0,0), ('FUEL-208','Throttle body removal & clean','Remove and clean throttle body assembly',1.5,'Fuel','B','EFI',0,0), -- ========= COOLING SYSTEM ========= ('COOL-301','Coolant flush – motorcycle','Drain, flush, and refill cooling system',0.8,'Cooling','C','COOL',0,1), ('COOL-302','Coolant flush – ATV/SxS','Flush and refill cooling system on ATV/SxS',1.0,'Cooling','C','COOL',0,1), ('COOL-303','Radiator replacement','Replace radiator and bleed system',1.5,'Cooling','B','COOL',0,0), ('COOL-304','Water pump rebuild','Replace seals, bearings, and impeller as needed',2.0,'Cooling','A','COOL',0,0), ('COOL-305','Thermostat replacement','Replace thermostat and test operation',0.7,'Cooling','C','COOL',0,0), ('COOL-306','Cooling fan diagnostic & repair','Diagnose and repair cooling fan circuit',1.2,'Cooling','B','ELEC',0,0), -- ========= DRIVETRAIN / TRANSMISSION ========= ('DRIV-401','Chain & sprocket replacement','Replace chain and both sprockets, adjust alignment',1.0,'Drivetrain','C','CHAIN',0,0), ('DRIV-402','Chain adjustment & lube','Adjust chain slack and lubricate',0.3,'Drivetrain','C','CHAIN',0,1), ('DRIV-403','Final drive oil change – shaft','Drain and refill final drive oil',0.4,'Drivetrain','C','DRIVE',0,1), ('DRIV-404','Clutch cable replacement & adjust','Replace clutch cable and set free play',0.6,'Drivetrain','C','CLUTCH',0,0), ('DRIV-405','Hydraulic clutch bleed','Bleed hydraulic clutch system',0.5,'Drivetrain','C','CLUTCH',0,0), ('DRIV-406','Clutch pack replacement – wet','Replace clutch plates and springs, set free play',2.0,'Drivetrain','B','CLUTCH',0,0), ('DRIV-407','CVT belt replacement – ATV/SxS','Replace CVT belt and inspect clutches',1.2,'Drivetrain','B','CVT',0,0), ('DRIV-408','CVT service – clean & inspect','Disassemble, clean, and inspect CVT system',2.0,'Drivetrain','B','CVT',0,0), ('DRIV-409','Transmission oil change – separate','Change transmission oil on separate gearbox',0.5,'Drivetrain','C','DRIVE',0,1), -- ========= SUSPENSION ========= ('SUS-501','Fork seal replacement – conventional','Replace fork seals and oil on conventional forks',3.0,'Suspension','B','FORK',0,0), ('SUS-502','Fork seal replacement – USD','Replace fork seals and oil on upside-down forks',3.5,'Suspension','A','FORK',0,0), ('SUS-503','Fork oil change only','Drain and refill fork oil',1.5,'Suspension','B','FORK',0,0), ('SUS-504','Shock removal & send-out','Remove shock for external rebuild service',0.8,'Suspension','C','SHOCK',0,0), ('SUS-505','Shock replacement – bolt-on','Replace rear shock assembly',1.0,'Suspension','C','SHOCK',0,0), ('SUS-506','Linkage service – clean & grease','Disassemble, clean, and grease linkage bearings',2.0,'Suspension','B','SUS',0,0), ('SUS-507','Steering head bearing service','Replace or service steering head bearings',2.5,'Suspension','B','SUS',0,0), -- ========= BRAKES ========= ('BRK-601','Front brake pad replacement','Replace front pads and inspect caliper',0.6,'Brakes','C','BRAKE',0,0), ('BRK-602','Rear brake pad replacement','Replace rear pads and inspect caliper',0.5,'Brakes','C','BRAKE',0,0), ('BRK-603','Front & rear pad replacement','Replace all pads, inspect system',1.0,'Brakes','C','BRAKE',0,0), ('BRK-604','Brake fluid flush – single circuit','Flush and bleed one brake circuit',0.7,'Brakes','C','BRAKE',0,1), ('BRK-605','Brake fluid flush – dual circuit','Flush and bleed front and rear circuits',1.0,'Brakes','C','BRAKE',0,1), ('BRK-606','Brake rotor replacement – single','Replace single rotor and pads',0.8,'Brakes','C','BRAKE',0,0), ('BRK-607','Brake rotor replacement – dual','Replace dual rotors and pads',1.4,'Brakes','C','BRAKE',0,0), ('BRK-608','Caliper rebuild – single','Rebuild single brake caliper with seals',1.5,'Brakes','B','BRAKE',0,0), ('BRK-609','Caliper rebuild – dual','Rebuild dual calipers',2.5,'Brakes','B','BRAKE',0,0), -- ========= TIRES / WHEELS ========= ('TIRE-701','Tire mount & balance – off bike','Mount and balance tire off the bike',0.5,'Tires','C','TIRE',0,0), ('TIRE-702','Tire mount & balance – on bike front','Remove wheel, mount and balance tire',0.7,'Tires','C','TIRE',0,0), ('TIRE-703','Tire mount & balance – on bike rear','Remove wheel, mount and balance tire',0.8,'Tires','C','TIRE',0,0), ('TIRE-704','Tube replacement – off bike','Replace tube and inspect tire',0.4,'Tires','C','TIRE',0,0), ('TIRE-705','Spoke wheel true & tension','True wheel and tension spokes',1.5,'Tires','B','WHEEL',0,0), ('TIRE-706','Wheel bearing replacement – front','Replace front wheel bearings',0.8,'Tires','C','WHEEL',0,0), ('TIRE-707','Wheel bearing replacement – rear','Replace rear wheel bearings',1.0,'Tires','C','WHEEL',0,0), -- ========= ELECTRICAL / LIGHTING ========= ('ELEC-801','Battery test & replacement','Test and replace battery as needed',0.4,'Electrical','C','ELEC',0,0), ('ELEC-802','Starter motor replacement','Replace starter motor assembly',1.2,'Electrical','B','ELEC',0,0), ('ELEC-803','Stator replacement','Replace charging stator and test output',2.0,'Electrical','B','ELEC',0,0), ('ELEC-804','Regulator/rectifier replacement','Replace regulator/rectifier and test system',0.7,'Electrical','C','ELEC',0,0), ('ELEC-805','Accessory wiring – basic','Install and wire single accessory (grips, charger, etc.)',0.8,'Electrical','C','ELEC',0,0), ('ELEC-806','Accessory wiring – complex','Multiple accessories, relay block, or custom harness',2.0,'Electrical','B','ELEC',0,0), ('ELEC-807','Lighting upgrade – LED kit','Install LED headlight or auxiliary lighting kit',1.2,'Electrical','C','ELEC',0,0), ('ELEC-808','Turn signal/hazard repair','Diagnose and repair turn signal circuit',1.0,'Electrical','B','ELEC',0,0), -- ========= CONTROLS / COCKPIT ========= ('CTRL-901','Handlebar replacement','Replace handlebars and transfer controls',1.5,'Controls','C','CTRL',0,0), ('CTRL-902','Lever & perch replacement','Replace clutch or brake lever and perch',0.4,'Controls','C','CTRL',0,0), ('CTRL-903','Throttle tube & housing service','Service or replace throttle tube and housing',0.6,'Controls','C','CTRL',0,0), ('CTRL-904','Switchgear replacement – single side','Replace left or right switch assembly',0.7,'Controls','C','CTRL',0,0), ('CTRL-905','Mirror replacement – pair','Replace both mirrors',0.3,'Controls','C','CTRL',0,0), -- ========= ATV / SXS SPECIFIC ========= ('ATV-1001','Front diff fluid change','Change front differential fluid',0.5,'ATV/SxS','C','ATV',0,1), ('ATV-1002','Rear diff fluid change','Change rear differential fluid',0.5,'ATV/SxS','C','ATV',0,1), ('ATV-1003','4x4 system diagnostic','Diagnose 4x4 engagement issues',1.2,'ATV/SxS','B','ATV',0,0), ('ATV-1004','Axle replacement – CV shaft','Replace one CV axle shaft',1.5,'ATV/SxS','B','ATV',0,0), ('ATV-1005','Winch install','Install and wire winch kit',2.0,'ATV/SxS','B','ATV',0,0), ('ATV-1006','Plow install','Install plow mount and blade',1.8,'ATV/SxS','C','ATV',0,1), -- ========= SNOW / PWC / SEASONAL ========= ('SNOW-1101','Snowmobile pre-season service','Full pre-season inspection and service',2.5,'Snow','B','SEASON',0,1), ('SNOW-1102','Snowmobile post-season service','Post-season service and storage prep',2.0,'Snow','B','SEASON',0,1), ('SNOW-1103','Hyfax replacement – pair','Replace both hyfax rails',1.0,'Snow','C','SNOW',0,0), ('SNOW-1104','Track tension & alignment','Set track tension and alignment',0.7,'Snow','C','SNOW',0,0), ('PWC-1201','PWC pre-season service','Pre-season inspection and service',2.0,'PWC','B','SEASON',0,1), ('PWC-1202','PWC post-season winterize','Winterize PWC for storage',1.5,'PWC','B','SEASON',0,1), -- ========= PDI / SETUP ========= ('PDI-1301','Motorcycle PDI – new unit','Pre-delivery inspection and setup for new motorcycle',2.0,'PDI','B','PDI',1,0), ('PDI-1302','ATV PDI – new unit','Pre-delivery inspection and setup for new ATV',2.2,'PDI','B','PDI',1,0), ('PDI-1303','SxS PDI – new unit','Pre-delivery inspection and setup for new side-by-side',2.5,'PDI','B','PDI',1,0), ('PDI-1304','Snowmobile PDI – new unit','Pre-delivery inspection and setup for snowmobile',2.3,'PDI','B','PDI',1,0), ('PDI-1305','PWC PDI – new unit','Pre-delivery inspection and setup for PWC',2.0,'PDI','B','PDI',1,0); // --------------------------------------------------------- // ADD PART FROM CATALOG (uses parts.id) // --------------------------------------------------------- if ($method === 'POST' && $action === 'add_part_from_catalog') { $d = body(); $wo_id = (int)($d['workorder_id'] ?? 0); $part_id = (int)($d['part_id'] ?? 0); $qty = (int)($d['qty'] ?? 1); if ($wo_id <= 0 || $part_id <= 0 || $qty <= 0) { err("Missing fields"); } // load part from catalog $stmt = $pdo->prepare(" SELECT sku, description, cost, price FROM parts WHERE id = ? LIMIT 1 "); $stmt->execute([$part_id]); $part = $stmt->fetch(PDO::FETCH_ASSOC); if (!$part) { err("Part not found", 404); } $cost = (float)$part['price']; // use sell price on WO line $line_total = $qty * $cost; $stmt = $pdo->prepare(" INSERT INTO workorder_parts (workorder_id, part_number, description, qty, cost, line_total) VALUES (:wo, :pn, :d, :q, :c, :t) "); $stmt->execute([ ':wo' => $wo_id, ':pn' => $part['sku'], ':d' => $part['description'], ':q' => $qty, ':c' => $cost, ':t' => $line_total ]); echo json_encode(["id" => $pdo->lastInsertId()]); exit; }