<?php
die;
include "config.php"; // your DB connection


// List of all tables
$tables = [
    "work_order_raw_matrial",
    "work_order_name",
    "work_order_detail",
    "work_order_customer_ref_mapping",
    "work_order",
	"work_order_assign",

    "vac_unselected_ok_parts",
    "vac_set_part_count_log",
    "vac_selected_ok_parts",
    "vac_part_count_log",
    "vac_machine_table",
    "vac_machine_changeover",
    "vac_machine_activity_log",
    "vac_first_off_signoff",
	"vac_machine_breakdown_log",


    "purchase_slips",
    "purchase_order_items_mapping",
    "purchase_order",
    "purchase_list",

    "production_planning",
    "part_count_log",

    "po_invoices_items_mapping",
    "po_invoices",

    "manufacture_machine_table",
    "manufacture_machine_children",

    "machine_breakdown_log",
    "machine_breakdown",
    "machine_activity_log",

    "delivery_note_mapping",
    "delivery_notes",

    "cnc_machine_table",
    "cnc_machine_activity_log",
	"cnc_first_off_signoff",
	"cnc_machine_breakdown_log",
	"cnc_machine_changeover",
	"cnc_part_count_log",
	"cnc_selected_ok_parts",
	"cnc_set_part_count_log",
	"cnc_unselected_ok_parts",
	"pu_machine_table",
    "pu_machine_activity_log",
	"pu_first_off_signoff",
	"pu_machine_changeover",
	"pu_part_count_log",
	"pu_selected_ok_parts",
	"pu_set_part_count_log",
	"pu_unselected_ok_parts",
	"pu_machine_breakdown_log",
	
	"assbly_machine_table",
    "assbly_machine_activity_log",
	"assbly_first_off_signoff",
	"assbly_machine_changeover",
	"assbly_part_count_log",
	"assbly_selected_ok_parts",
	"assbly_set_part_count_log",
	"assbly_unselected_ok_parts",
	"assbly_machine_breakdown_log",	
	
	"assypu_machine_table",
    "assypu_machine_activity_log",
	"assypu_first_off_signoff",
	"assypu_machine_changeover",
	"assypu_part_count_log",
	"assypu_selected_ok_parts",
	"assypu_set_part_count_log",
	"assypu_unselected_ok_parts",
	"assypu_machine_breakdown_log",
	
];

// Loop and truncate
foreach ($tables as $table) {
    $query = "TRUNCATE TABLE `$table`";
    
    if (!mysqli_query($conn, $query)) {
        echo "Error truncating $table: " . mysqli_error($conn) . "<br>";
    } else {
        echo "✔ Cleared: $table <br>";
    }
}



echo "<br><b>All tables cleared and IDs reset successfully!</b>";
?>