<?php
if ( !class_exists( 'DTCustomerPostType' ) ) {

	class DTCustomerPostType {

		function __construct() {
			add_action ( 'init', array (
				$this,
				'dt_init'
			) );
			
			add_filter ( "cs_metabox_options", array(
				$this,
				"dt_customers_cs_metabox_options"
			) );
		}

		function dt_init() {
			$labels = array(
				'name' => __('Customers', 'dt-reservation-plugin' ),
				'singular_name' => __('Customer', 'dt-reservation-plugin' ),
				'menu_name' => __('Calendar', 'dt-reservation-plugin' ),
				'add_new' => __('Add Customer', 'dt-reservation-plugin' ),
				'add_new_item' => __('Add New Customer', 'dt-reservation-plugin' ),
				'edit' => __('Edit Customer', 'dt-reservation-plugin' ),
				'edit_item' => __('Edit Customer', 'dt-reservation-plugin' ),
				'new_item' => __('New Customer', 'dt-reservation-plugin' ),
				'view' => __('View Customer', 'dt-reservation-plugin' ),
				'view_item' => __('View Customer', 'dt-reservation-plugin' ),
				'search_items' => __('Search Customers', 'dt-reservation-plugin' ),
				'not_found' => __('No Customers found', 'dt-reservation-plugin' ),
				'not_found_in_trash' => __('No Customers found in Trash', 'dt-reservation-plugin' ),
				'parent_item_colon' => __('Parent Customer:', 'dt-reservation-plugin' ),
			);

			$args = array(
				'labels' => $labels,
				'hierarchical' => false,
				'description' => __('This is Custom Post type named as Customers','dt-reservation-plugin'),
				'supports' => array('title'),
				'public' => true,
				'show_ui' => true,
				'show_in_menu' => true,
				'show_in_admin_bar' => true,
				'menu_position' => 5,
				'show_in_rest' => true,
				'menu_icon' => 'dashicons-clipboard',
			);

			register_post_type('dt_customers', $args );
		}

		function dt_customers_cs_metabox_options( $options ) {

			$options[]    = array(
			  'id'        => '_info',
			  'title'     => esc_html__('Customer Options', 'dt-reservation-plugin'),
			  'post_type' => 'dt_customers',
			  'context'   => 'normal',
			  'priority'  => 'default',
			  'sections'  => array(
			
				array(
				  'name'  => 'general_section',
			
				  'fields' => array(
			
					array(
					  'id'    => 'emailid',
					  'type'  => 'text',
					  'title' => esc_html__('Email Id', 'dt-reservation-plugin'),
					  'attributes' => array( 
						'placeholder' => 'testmail@domain.com'
					  )
					),

					array(
					  'id'    => 'phone',
					  'type'  => 'text',
					  'title' => esc_html__('Phone', 'dt-reservation-plugin'),
					  'attributes' => array( 
						'placeholder' => '022-65265'
					  )
					),

				  ), // end: fields
				), // end: a section

			  ),
			);

			return $options;
		}
	}
}