<?php
include '../koneksi.php';
    $query = mysqli_query($konek, "
    SELECT MAX(idtelp_custraxi) AS last_id FROM telp_custraxi");
    $data = mysqli_fetch_assoc($query);

    $lastId = $data['last_id']; // PGW005
    $urutan = (int) substr($lastId, 3, 5);
    $urutan++;

    $idtelp_custraxi = 'TCR' . str_pad($urutan, 5, '0', STR_PAD_LEFT);
        header("Location: ../telp_custraxitambah.php?idtelp_custraxi=$idtelp_custraxi");
?>