<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div id="kirilkirkov" class="wrap">
    <div class="create-client-page">
        <div class="header p-4 flex items-center space-between">
            <div class="flex items-center">
                <img class="logo" src="<?php echo esc_url(plugins_url('../../Assets/Img/logo.svg', __FILE__ )); ?>" alt="<?php echo esc_attr( 'WP Invoices' ) ?>" />
            </div>
            <h1 class="text-white uppercase text-sm font-lighter p-0">
                <?php esc_html_e('Send Document', 'kirilkirkov-pdf-invoice-manager' ); ?> <?php echo esc_html(sanitize_text_field($invoice['invoice_number'])); ?>
            </h1>
        </div>
        <div class="flex flex-wrap">
            <div class="w-full">
                <div class="section-body bg-white p-4">
                    
                <?php if($success === true) { ?>
                    <div class="alert alert-success w-full md:w-1/4 mx-auto mb-4">
                        <?php  esc_html_e('Email sended', 'kirilkirkov-pdf-invoice-manager' );  ?>
                    </div>
                    <?php } ?>

                    <?php if($success === false) { ?>
                    <div class="alert alert-danger w-full md:w-1/4 mx-auto mb-4">
                        <?php esc_html_e('There are errors received', 'kirilkirkov-pdf-invoice-manager' ); ?>
                    </div>
                    <?php } ?>
                    
                    <form class="w-full md:w-2/3 mx-auto p-0 md:p-4 rounded-sm" method="post" action="">
                        <?php wp_nonce_field('send_invoice_nonce', 'send_invoice_nonce'); ?>

                        <div class="form-row">  
                            <label><?php esc_html_e('Recepient(s) email(s) (one or multiple emails separated by comma)', 'kirilkirkov-pdf-invoice-manager' ) ?></label>
                            <input type="text" maxlength="255" value="<?php echo isset($client[$Config::INPUTS_PREFIX.'send_invoice_emails']) ? esc_attr(sanitize_text_field($client[$Config::INPUTS_PREFIX.'send_invoice_emails'])) : ''; ?>" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'send_invoice_emails'; ?>">
                            <p class="text-error m-0"><?php echo isset($errors[$Config::INPUTS_PREFIX.'send_invoice_emails']) ? esc_html(sanitize_text_field($errors[$Config::INPUTS_PREFIX.'send_invoice_emails'])) : ''; ?></p>
                            <p class="text-error m-0"><?php echo isset($errors[$Config::INPUTS_PREFIX.'send_invoice_mail_error']) ? esc_html(sanitize_text_field($errors[$Config::INPUTS_PREFIX.'send_invoice_mail_error'])) : ''; ?></p>
                        </div>

                        <div class="form-row">  
                            <label><?php esc_html_e('Email subject', 'kirilkirkov-pdf-invoice-manager' ) ?></label>
                            <input type="text" maxlength="255" value="<?php echo isset($client[$Config::INPUTS_PREFIX.'send_invoice_subject']) ? esc_attr(sanitize_text_field($client[$Config::INPUTS_PREFIX.'send_invoice_subject'])) : ''; ?>" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'send_invoice_subject'; ?>">
                            <p class="text-error m-0"><?php echo isset($errors[$Config::INPUTS_PREFIX.'send_invoice_subject']) ? esc_html(sanitize_text_field($errors[$Config::INPUTS_PREFIX.'send_invoice_subject'])) : ''; ?></p>
                        </div>

                        <div class="form-row">  
                            <label><?php esc_html_e('Email body', 'kirilkirkov-pdf-invoice-manager' ) ?></label>
                            <?php 
                                $kirilkirkovwipdf_content = isset($client[$Config::INPUTS_PREFIX.'send_invoice_body']) ? $client[$Config::INPUTS_PREFIX.'send_invoice_body'] : '';
                                wp_editor( $kirilkirkovwipdf_content, 'kkinv-send-email-msg-textarea', array('textarea_name' => $Config::INPUTS_PREFIX.'send_invoice_body') ); 
                            ?>
                            <p class="text-error m-0"><?php echo isset($errors[$Config::INPUTS_PREFIX.'send_invoice_body']) ? esc_html(sanitize_text_field($errors[$Config::INPUTS_PREFIX.'send_invoice_body'])) : ''; ?></p>
                        </div>
                        
                        <div class="flex items-center">  
                            <button class="button-primary" type="submit">
                                <?php esc_html_e('Send', 'kirilkirkov-pdf-invoice-manager' );  ?>
                            </button>
                        </div> 
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>