“Stories, historias, iсторії, iστορίες”

Mon, Jan 1

Free Workshop

This immersive event celebrates the universal human experience through the lenses of history and ancestry, featuring a diverse array of photographers whose works capture the essence of different cultures and historical moments.

RSVP

Close up photo of white flowers on a grey background

Form Pengajuan Surat Online

if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}

// 1. Registrasi Custom Post Type (CPT) untuk Permohonan Surat
function kel_layanan_register_cpt() {
$labels = array(
‘name’ => ‘Permohonan Surat’,
‘singular_name’ => ‘Permohonan Surat’,
‘menu_name’ => ‘Layanan Kelurahan’,
‘add_new’ => ‘Tambah Baru’,
‘add_new_item’ => ‘Tambah Permohonan Baru’,
‘edit_item’ => ‘Edit Permohonan’,
‘new_item’ => ‘Permohonan Baru’,
‘view_item’ => ‘Lihat Permohonan’,
‘search_items’ => ‘Cari Permohonan’,
‘not_found’ => ‘Tidak ada permohonan ditemukan’,
‘not_found_in_trash’ => ‘Tidak ada permohonan di kotak sampah’,
);

$args = array(
‘labels’ => $labels,
‘public’ => false,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘permohonan-surat’ ),
‘capability_type’ => ‘post’,
‘has_archive’ => false,
‘hierarchical’ => false,
‘menu_position’ => 25,
‘menu_icon’ => ‘dashicons-clipboard’,
‘supports’ => array( ‘title’ ),
);

register_post_type( ‘kelurahan_surat’, $args );
}
add_action( ‘init’, ‘kel_layanan_register_cpt’ );

// 2. Meta Box Detail Permohonan di Admin
function kel_layanan_add_meta_boxes() {
add_meta_box(
‘kelurahan_detail_meta’,
‘Detail Permohonan Warga Kelurahan Teluk’,
‘kel_layanan_meta_box_callback’,
‘kelurahan_surat’,
‘normal’,
‘high’
);
}
add_action( ‘add_meta_boxes’, ‘kel_layanan_add_meta_boxes’ );

function kel_layanan_meta_box_callback( $post ) {
wp_nonce_field( ‘kel_save_meta_box’, ‘kel_meta_box_nonce’ );

$nik = get_post_meta( $post->ID, ‘_kelurahan_nik’, true );
$jenis_surat = get_post_meta( $post->ID, ‘_kelurahan_jenis_surat’, true );
$no_wa = get_post_meta( $post->ID, ‘_kelurahan_no_wa’, true );
$keperluan = get_post_meta( $post->ID, ‘_kelurahan_keperluan’, true );
$status = get_post_meta( $post->ID, ‘_kelurahan_status’, true );
$tracking_code = get_post_meta( $post->ID, ‘_kelurahan_tracking_code’, true );

if ( empty( $status ) ) $status = ‘Pending’;
if ( empty( $tracking_code ) ) {
$tracking_code = ‘TELUK-‘ . strtoupper( wp_generate_password( 6, false ) );
update_post_meta( $post->ID, ‘_kelurahan_tracking_code’, $tracking_code );
}
?>

$columns[‘cb’],
‘title’ => ‘Nama Pemohon’,
‘tracking_code’=> ‘Kode Tracking’,
‘nik’ => ‘NIK’,
‘jenis_surat’ => ‘Jenis Surat’,
‘status’ => ‘Status’,
‘date’ => $columns[‘date’],
);
}
add_filter( ‘manage_kelurahan_surat_posts_columns’, ‘kel_layanan_custom_columns’ );

function kel_layanan_custom_column_content( $column, $post_id ) {
switch ( $column ) {
case ‘tracking_code’:
echo ‘‘ . esc_html( get_post_meta( $post_id, ‘_kelurahan_tracking_code’, true ) ) . ‘‘;
break;
case ‘nik’:
echo esc_html( get_post_meta( $post_id, ‘_kelurahan_nik’, true ) );
break;
case ‘jenis_surat’:
echo esc_html( get_post_meta( $post_id, ‘_kelurahan_jenis_surat’, true ) );
break;
case ‘status’:
$status = get_post_meta( $post_id, ‘_kelurahan_status’, true ) ?: ‘Pending’;
$bg = ‘#ffba00’;
if ( $status == ‘Selesai’ ) $bg = ‘#28a745’;
elseif ( $status == ‘Diproses’ ) $bg = ‘#17a2b8’;
elseif ( $status == ‘Ditolak’ ) $bg = ‘#dc3545’;
echo ‘‘ . esc_html( $status ) . ‘‘;
break;
}
}
add_action( ‘manage_kelurahan_surat_posts_custom_column’, ‘kel_layanan_custom_column_content’, 10, 2 );

// 4. Shortcode Form Pengajuan

Form Pengajuan Surat Online


function kel_layanan_form_shortcode() {
ob_start();

if ( $_SERVER[‘REQUEST_METHOD’] == ‘POST’ && isset( $_POST[‘kel_submit_form’] ) ) {
if ( isset( $_POST[‘kel_form_nonce’] ) && wp_verify_nonce( $_POST[‘kel_form_nonce’], ‘kel_form_action’ ) ) {
$nama = sanitize_text_field( $_POST[‘nama’] );
$nik = sanitize_text_field( $_POST[‘nik’] );
$jenis_surat = sanitize_text_field( $_POST[‘jenis_surat’] );
$no_wa = sanitize_text_field( $_POST[‘no_wa’] );
$keperluan = sanitize_textarea_field( $_POST[‘keperluan’] );

if ( ! empty( $nama ) && ! empty( $nik ) && ! empty( $jenis_surat ) && ! empty( $no_wa ) ) {
$tracking_code = ‘TELUK-‘ . strtoupper( wp_generate_password( 6, false ) );

$post_id = wp_insert_post( array(
‘post_title’ => $nama,
‘post_type’ => ‘kelurahan_surat’,
‘post_status’ => ‘publish’,
) );

if ( $post_id ) {
update_post_meta( $post_id, ‘_kelurahan_nik’, $nik );
update_post_meta( $post_id, ‘_kelurahan_jenis_surat’, $jenis_surat );
update_post_meta( $post_id, ‘_kelurahan_no_wa’, $no_wa );
update_post_meta( $post_id, ‘_kelurahan_keperluan’, $keperluan );
update_post_meta( $post_id, ‘_kelurahan_status’, ‘Pending’ );
update_post_meta( $post_id, ‘_kelurahan_tracking_code’, $tracking_code );

echo ‘

‘;
echo ‘Permohonan Surat Berhasil Dikirim!
‘;
echo ‘Kode Tracking Anda: ‘ . esc_html($tracking_code) . ‘
‘;
echo ‘Simpan kode tracking ini untuk mengecek status surat Anda di menu “Cek Status”.‘;
echo ‘

‘;
}
}
}
}
?>

Form Pengajuan Surat Online Kelurahan Teluk







‘kelurahan_surat’,
‘posts_per_page’ => 1,
‘meta_query’ => array(
array(
‘key’ => ‘_kelurahan_tracking_code’,
‘value’ => $code,
‘compare’ => ‘=’
)
)
) );

if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$post_id = get_the_ID();
$result_data = array(
‘nama’ => get_the_title(),
‘jenis_surat’ => get_post_meta( $post_id, ‘_kelurahan_jenis_surat’, true ),
‘status’ => get_post_meta( $post_id, ‘_kelurahan_status’, true ),
‘tanggal’ => get_the_date( ‘d M Y’ ),
);
}
wp_reset_postdata();
}
}
?>

Cek Status Permohonan Surat

Cek

Detail Permohonan

Nama Pemohon:

Jenis Surat:

Tanggal Pengajuan:

Status:
‘ . esc_html( $st ) . ‘‘;
?>

Kode tracking tidak ditemukan. Pastikan Anda memasukkan kode dengan benar.