<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<table class="form-table">
    <tr valign="top">
        <th scope="row" class="align-middle">
            <div class="th-div">
                <span class="mr-5"><?php esc_html_e( 'My Company', 'kirilkirkov-pdf-invoice-manager' ); ?></span>
                <a class="show-info" data-info="<?php esc_attr_e( 'Your company information which you wants to show in invoices', 'kirilkirkov-pdf-invoice-manager' ) ?>" href="javascript:;"></a>
            </div>
        </th>
        <td colspan="2">
            <div class="mb-4">
                <div>
                    <label><?php esc_html_e( 'Company Logo (shown in the invoices, format PNG or JPG only)', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                </div>
                <input type="file" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'logo_file'; ?>" />
                <div>
                    <?php 
                        $kirilkirkovwipdf_logo_file = '';
                        $kirilkirkovwipdf__logo_file = get_option( $Config::INPUTS_PREFIX.'logo_file' );
                        if($kirilkirkovwipdf__logo_file) {
                            $kirilkirkovwipdf__logo_file = json_decode($kirilkirkovwipdf__logo_file, true);
                            if(json_last_error() === JSON_ERROR_NONE) {
                                $kirilkirkovwipdf_logo_file = $kirilkirkovwipdf__logo_file['url'];
                            }
                        }
                    ?>
                    <?php if(filter_var($kirilkirkovwipdf_logo_file, FILTER_VALIDATE_URL)) { ?>
                    <img height="100" src="<?php echo esc_attr($kirilkirkovwipdf_logo_file); ?>" alt="<?php esc_attr_e( 'Company Logo', 'kirilkirkov-pdf-invoice-manager' ); ?>">
                    <?php } ?>
                </div>
                <div>
                    <?php 
                        $kirilkirkovwipdf_hide_logo_from_invoices = get_option($Config::INPUTS_PREFIX.'hide_logo_from_invoices');
                    ?>
                    <input type="hidden" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'hide_logo_from_invoices'; ?>" value="0" />
                    <label>
                        <input type="checkbox" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'hide_logo_from_invoices'; ?>" value="1" <?php echo $kirilkirkovwipdf_hide_logo_from_invoices && (int)$kirilkirkovwipdf_hide_logo_from_invoices === 1 ? 'checked' : ''; ?>>
                        <?php esc_html_e( 'Hide logo from invoices', 'kirilkirkov-pdf-invoice-manager' ); ?>
                    </label>
                </div>
            </div>
            <div class="mb-4">
                <label><?php esc_html_e( 'Name', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_name" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_name' ))); ?>" />
            </div>
            <div class="mb-4">
                <?php 
                    $kirilkirkovwipdf_vat_registered = get_option($Config::INPUTS_PREFIX.'company_vat_registered');
                ?>
                <input type="hidden" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'company_vat_registered'; ?>" value="0" />
                <label>
                    <input type="checkbox" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'company_vat_registered'; ?>" value="1" <?php echo $kirilkirkovwipdf_vat_registered && (int)$kirilkirkovwipdf_vat_registered === 1 ? 'checked' : ''; ?>>
                    <?php esc_html_e( 'VAT Registration', 'kirilkirkov-pdf-invoice-manager' ); ?>
                </label>
            </div>
            <div class="mb-4">
                <label><?php esc_html_e( 'Vat Number', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_vat_number" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_vat_number' ))); ?>" />
            </div>
            <div class="mb-4">
                <label><?php esc_html_e( 'Address', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_address" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_address' ))); ?>" />
            </div>
            <div class="mb-4">
                <label><?php esc_html_e( 'City', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_city" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_city' ))); ?>" />
            </div>
            <div class="mb-4">
                <label><?php esc_html_e( 'Accountable Person', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_accountable_person" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_accountable_person' ))); ?>" />
            </div>
            <div>
                <label><?php esc_html_e( 'Zip Code', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>company_zip_code" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'company_zip_code' ))); ?>" />
            </div>
        </td>
    </tr>

</table>
<input type="hidden" name="page_options" value="<?php echo esc_attr(sanitize_text_field($Config::COMPANY_INPUT_GROUP)); ?>" />
<?php settings_fields($Config::COMPANY_INPUT_GROUP); ?>