<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

//Save data
if ( !current_user_can( "manage_options" ) )  {
	wp_die( __( "You do not have sufficient permissions to access this page." ) );
	}
	
if (isset($_POST['btn-submit'])) {
	if ( isset( $_POST['_wpnonce-extract-text-from-image-etfi'] ) ) {
		check_admin_referer( 'extract-text-from-image-etfi', '_wpnonce-extract-text-from-image-etfi' );
	
	   if(isset($_POST['etfi_region'])){
		 update_option('etfi_region', sanitize_text_field($_POST['etfi_region']));
		}
		if(isset($_POST['etfi_version'])){
		 update_option('etfi_version', sanitize_text_field($_POST['etfi_version']));
		}
		if(isset($_POST['etfi_S3_KEY'])){
		 update_option('etfi_S3_KEY', sanitize_text_field($_POST['etfi_S3_KEY']));
		}
		if(isset($_POST['etfi_S3_SECRETE'])){
		 update_option('etfi_S3_SECRETE', sanitize_text_field($_POST['etfi_S3_SECRETE']));
		}
		show_message('<div class="notice notice-success is-dismissible"><p>'.esc_attr( 'Settings has been saved successfully', 'extract-text-from-image-etfi' ).'</p></div>'); 
	}
}
?>


<div class="wrap">
    <h1><?php esc_html_e( 'Configuration Settings', 'extract-text-from-image-etfi' );?></h1>
    <form id="frm-manu" method="post">
    <?php wp_nonce_field( 'extract-text-from-image-etfi', '_wpnonce-extract-text-from-image-etfi' ); ?>
        <table class="form-table">
            <tr scope="row">
                <th><label for="etfi_region"><?php esc_html_e( 'Region', 'extract-text-from-image-etfi' );?></label></th>
                <td>
                    <input id="etfi_region" class="regular-text" type="text" value="<?php echo sanitize_text_field(get_option('etfi_region')); ?>"  name="etfi_region" required="required"/>
                </td>
            </tr>
             <tr scope="row">
                <th><label for="etfi_version"><?php esc_html_e( 'Version', 'extract-text-from-image-etfi' );?></label></th>
                <td>
                    <input id="etfi_version" class="regular-text" type="text" value="<?php echo sanitize_text_field(get_option('etfi_version')); ?>" name="etfi_version" required="required"/>
                </td>
            </tr>
            <tr scope="row">
                <th><label for="etfi_S3_KEY"><?php esc_html_e( 'Access Key ID', 'extract-text-from-image-etfi' );?></label></th>
                <td>
                    <input id="etfi_S3_KEY" class="regular-text" type="text" value="<?php echo sanitize_text_field(get_option('etfi_S3_KEY')); ?>" name="etfi_S3_KEY" required="required"/>
                </td>
            </tr>
            <tr scope="row">
                <th><label for="etfi_S3_SECRETE"><?php esc_html_e( 'Secret Access Key', 'extract-text-from-image-etfi' );?></label></th>
                <td>
                    <input id="etfi_S3_SECRETE" class="regular-text" type="text" value="<?php echo sanitize_text_field(get_option('etfi_S3_SECRETE')); ?>" name="etfi_S3_SECRETE" required="required"/>
                </td>
            </tr>
            
        </table> 
         <p><input name="btn-submit" type="submit" value="<?php esc_html_e( 'Save Changes', 'extract-text-from-image-etfi' );?>" class="button-primary"/></p>       
</form>
<div style="margin-top:50px;">    
<h2><?php esc_html_e( 'Note: Use shortcode [etfi-extract-text] to display widget on any page or post.', 'extract-text-from-image-etfi' );?></h2>    
<h3><?php esc_html_e( 'Description:', 'extract-text-from-image-etfi' );?></h3>
<p><?php esc_html_e( 'Extract text easily from your images. Plugin uses Amazon Textract service which is a machine learning service that automatically extracts text, handwriting and data from images that goes beyond simple optical character recognition (OCR) to identify, understand, and extract data from forms and tables.', 'extract-text-from-image-etfi' );?>
</p>
<p><?php esc_html_e( 'To display an extract widget on any page or post use shortcode [etfi-extract-text]. You have to enter the required AWS credential in the plugin setting screen. Refer below links to get credentials from your AWS account', 'extract-text-from-image-etfi' );?></p>
<p><a href="<?php echo esc_url('https://aws.amazon.com/textract/'); ?>" target="_blank"><?php esc_html_e( 'https://aws.amazon.com/textract/', 'extract-text-from-image-etfi' );?></a></p>
<p><a href="<?php echo esc_url('https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html/'); ?>" target="_blank">
<?php esc_html_e( 'https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html/', 'extract-text-from-image-etfi' );?>
</a></p>
<p><a href="<?php echo esc_url('https://docs.aws.amazon.com/textract/latest/dg/security-iam.html/'); ?>" target="_blank">
<?php esc_html_e( 'https://docs.aws.amazon.com/textract/latest/dg/security-iam.html/', 'extract-text-from-image-etfi' );?>
</a></p>
<p><a href="<?php echo esc_url('https://drive.google.com/file/d/1znTnPv35_XHGShMzIdXwNlkRFWAOl-Gc/view?usp=sharing'); ?>" target="_blank">
<?php esc_html_e( 'https://drive.google.com/file/d/1znTnPv35_XHGShMzIdXwNlkRFWAOl-Gc/view?usp=sharing', 'extract-text-from-image-etfi' );?>
</a></p>
</div>
</div>


