<?php

namespace Webnestors\Wsn\Snippets;

class CheckoutDeliveryDateAndTime extends \Webnestors\Wsn\Snippet {
    public $delivery_start_time = "";

    public $delivery_end_time = "";

    public $delivery_time_slots = "";

    public $delivery_days_ahead = "";

    public $delivery_min_days = "";

    public $delivery_remove_sunday = 0;

    public $delivery_remove_monday = 0;

    public $delivery_remove_tuesday = 0;

    public $delivery_remove_wednesday = 0;

    public $delivery_remove_thursday = 0;

    public $delivery_remove_friday = 0;

    public $delivery_remove_saturday = 0;

    public function is_pro() : bool {
        return true;
    }

    public function tab() : string {
        return "checkout";
    }

    public function title() : string {
        return __( "Delivery Date and Time", "enhancements-for-woocommerce" );
    }

    public function description() : string {
        return __( "With this module your client can choose the delivery date and time wants the order to be delivered.", "enhancements-for-woocommerce" );
    }

    public function meta() : array {
        return [
            [
                "label"         => __( "Minimum Delivery Time", "enhancements-for-woocommerce" ),
                "description"   => __( "Choose the minimum time for delivery that the user is allowed to select.", "enhancements-for-woocommerce" ),
                "name"          => "delivery_start_time",
                "type"          => "select",
                "options"       => [
                    "06:00",
                    "07:00",
                    "08:00",
                    "09:00",
                    "10:00",
                    "11:00",
                    "12:00",
                    "13:00",
                    "14:00",
                    "15:00",
                    "16:00",
                    "17:00",
                    "18:00",
                    "19:00",
                    "20:00",
                    "21:00",
                    "22:00",
                    "23:00"
                ],
                "option_labels" => [
                    "At 06:00 am",
                    "At 07:00 am",
                    "At 08:00 am",
                    "At 09:00 am",
                    "At 10:00 am",
                    "At 11:00 am",
                    "At 12:00 am",
                    "At 13:00 pm",
                    "At 14:00 pm",
                    "At 15:00 pm",
                    "At 16:00 pm",
                    "At 17:00 pm",
                    "At 18:00 pm",
                    "At 19:00 pm",
                    "At 20:00 pm",
                    "At 21:00 pm",
                    "At 22:00 pm",
                    "At 23:00 pm"
                ],
            ],
            [
                "label"         => __( "Maximum Delivery Time", "enhancements-for-woocommerce" ),
                "description"   => __( "Choose the maximum time for delivery that the user is allowed to select.", "enhancements-for-woocommerce" ),
                "name"          => "delivery_end_time",
                "type"          => "select",
                "options"       => [
                    "06:00",
                    "07:00",
                    "08:00",
                    "09:00",
                    "10:00",
                    "11:00",
                    "12:00",
                    "13:00",
                    "14:00",
                    "15:00",
                    "16:00",
                    "17:00",
                    "18:00",
                    "19:00",
                    "20:00",
                    "21:00",
                    "22:00",
                    "23:00"
                ],
                "option_labels" => [
                    "At 06:00 am",
                    "At 07:00 am",
                    "At 08:00 am",
                    "At 09:00 am",
                    "At 10:00 am",
                    "At 11:00 am",
                    "At 12:00 am",
                    "At 13:00 pm",
                    "At 14:00 pm",
                    "At 15:00 pm",
                    "At 16:00 pm",
                    "At 17:00 pm",
                    "At 18:00 pm",
                    "At 19:00 pm",
                    "At 20:00 pm",
                    "At 21:00 pm",
                    "At 22:00 pm",
                    "At 23:00 pm"
                ],
            ],
            [
                "label"         => __( "Delivery Time Slots", "enhancements-for-woocommerce" ),
                "description"   => __( "Choose the gap between each time slot.", "enhancements-for-woocommerce" ),
                "name"          => "delivery_time_slots",
                "type"          => "select",
                "options"       => [
                    "15",
                    "30",
                    "45",
                    "60",
                    "90",
                    "120"
                ],
                "option_labels" => [
                    "15 minutes",
                    "30 minutes",
                    "45 minutes",
                    "60 minutes",
                    "90 minutes",
                    "120 minutes"
                ],
            ],
            [
                "label"       => __( "Maximum days", "enhancements-for-woocommerce" ),
                "description" => __( "The maximum amount of days in the future that the user is allowed to select for the delivery date. For example, 90.", "enhancements-for-woocommerce" ),
                "name"        => "delivery_days_ahead",
                "type"        => "number",
            ],
            [
                "label"       => __( "Minimum days before delivery date", "enhancements-for-woocommerce" ),
                "description" => __( "The minimum amount of days before the delivery date the user is allowed to select. For example, 0 for today, or 1 for tomorrow.", "enhancements-for-woocommerce" ),
                "name"        => "delivery_min_days",
                "type"        => "number",
            ],
            [
                "label" => __( "Disable Sundays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_sunday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Mondays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_monday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Tuesdays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_tuesday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Wednesdays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_wednesday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Thursdays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_thursday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Fridays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_friday",
                "type"  => "checkbox",
            ],
            [
                "label" => __( "Disable Saturdays", "enhancements-for-woocommerce" ),
                "name"  => "delivery_remove_saturday",
                "type"  => "checkbox",
            ]
        ];
    }

    public function tooltip() : ?string {
        ob_start();
        ?>
        <h1><strong><?php 
        echo esc_html( $this->title() );
        ?></strong></h1>
        <h3>Description</h3>
        <p>The Delivery Date & Time module adds customizable date and time selection fields to your WooCommerce checkout page. This feature allows customers to choose their preferred delivery date and time slot when placing an order, giving them more control over their delivery preferences.</p>
        <p>Store owners can configure available delivery days, time slots, lead times, and blackout dates. This helps manage customer expectations while ensuring deliveries are scheduled only during your operational hours and available time slots.</p>
        <h3>Settings</h3>
        <ul>
            <li><strong>Delivery Time:</strong> Select the start and end time of your delivery window</li>
            <li><strong>Time Slots:</strong> Define specific time windows when deliveries can be made</li>
            <li><strong>Delivery days ahead:</strong> Set maximum days ahead that the customer can choose</li>
            <li><strong>Minimum days to deliver:</strong> Set the minimum days ahead you want to deliver</li>
            <li><strong>Blackout Dates:</strong> Specify dates when delivery is not available (Sunday, Saturday, etc.)</li>
        </ul>
        <h3>Appearance</h3>
        <p>There is no need to add any css to the date and time selectors, they will be styled automatically.</p>
        <?php 
        return ob_get_clean();
    }

    public function run() {
    }

    private function get_delivery_date_range() {
    }

    private function generate_time_slots( $include_empty = true ) {
    }

    public function add_delivery_fields( $checkout ) {
    }

    public function validate_delivery_fields() {
    }

    public function save_delivery_fields( $order_id ) {
    }

    /**
     * @param \WC_Order $order
     */
    private function display_delivery_information( $order ) {
    }

    /**
     * @param \WC_Order $order
     */
    public function add_delivery_fields_to_emails( $order, $sent_to_admin = false, $plain_text = false ) {
    }

    public function add_delivery_fields_to_thankyou( $order_id ) {
    }

    public function show_delivery_fields_in_admin( $order ) {
    }

}
