<?php
/**
 * This file displays import export configuration tab.
 *
 * @package object-data-sync-for-salesforce\Helper\view
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use MoSfSyncSalesforce\Helper\Plugin_Constants;
use MoSfSyncSalesforce\Services\Utils;

/**
 * Displays plugin import export configuration tab view.
 *
 * @return void
 */
function mo_sf_sync_import_export_configuration() {  ?>
	<div class="mo-sf-sync-tab-content">
	<?php
	Utils::mo_sf_sync_show_message();
	Utils::mo_sf_sync_show_feedback_message();
	?>
		<div class="mo-sf-sync-tab-content-tile mo-sf-mt-4">
			<h1 class="mo-sf-form-head">Import / Export Configuration</h1>
			<div class="mo-sf-sync-config-section">
				<div class="mo-sf-sync-config-section-header">
					<h2 class="mo-sf-sync-secondary-title">Keep Configuration Intact</h2>
                    <form name="f" method="post" id="settings_intact">
                        <?php wp_nonce_field( 'mo_sf_sync_keep_settings_on_deletion' ); ?>
                        <input type="hidden" name="option" value="mo_sf_sync_keep_settings_on_deletion" />
                        <label class="mo-sf-sync-switch">
                            <input type="checkbox" name="mo_sf_sync_keep_settings_on_deletion" <?php echo checked( get_option( 'mo_sf_sync_keep_settings_on_deletion' ) ? true : false ); ?> onchange="document.getElementById('settings_intact').submit();" />
                            <span class="mo-sf-sync-slider round"></span>
                        </label>
                    </form>
				</div>

				<div class="mo-sf-sync-note-box">
					<h4>Notes</h4>
					<ul>
						<li>Enable this to preserve your plugin settings after plugin deletion.</li>
						<li class="mo-sf-sync-rec-note">Recommended before upgrading to the Premium version.</li>
					</ul>
				</div>
			</div>

			<div class="mo-sf-sync-config-section">
				<div class="mo-sf-sync-config-section-header">
					<h2 class="mo-sf-sync-secondary-title">Export Plugin Configuration</h2>
                    <form method="post" name="mo_export" id="mo_export">
                        <?php
                        wp_nonce_field( 'mo_sf_sync_export_configuration' );
                        ?>
                        <input type="hidden" name="option" value="mo_sf_sync_export_configuration" />
                        <button class="mo-sf-btn-cstm mo-sf-sync-config-btn" type="submit"> 
                            Export
							<?php
							Utils::mo_sf_sync_render_image(
								'file-export.svg',
								array(
									'alt'   => 'Export',
									'class' => 'mo-sf-sync-config-btn-img',
								)
							);
							?>
                        </button>
                    </form>
				</div>
				<div class="mo-sf-sync-note-box">
					<h4>Notes</h4>
					<ul>
						<li>Export your configuration before major updates or migrations.</li>
						<li>Helps you migrate settings easily to another WordPress instance/environment.</li>
						<li>Keep exported files in a safe location.</li>
						<li>To import exported configurations, go to <strong>Import/Export Tab &gt; Import Configuration</strong>.</li>
					</ul>
				</div>
			</div>

			<div class="mo-sf-sync-config-section">
				<div class="mo-sf-sync-config-section-header mo-sf-sync-config-import-section">
					<h2 class="mo-sf-sync-secondary-title">Import Configuration</h2>
                    <form method="post" id="import_config" name="import_config" enctype="multipart/form-data">
					    <div class="mo-sf-sync-import-group">
                            <?php wp_nonce_field( 'mo_sf_sync_import_configuration' ); ?>
                            <input type="hidden" name="option" value="mo_sf_sync_import_configuration" />
                            <input type="file" name="configuration_file" id="configuration_file" class="mo_sf_sync_config_file_input">
                            <button class="mo-sf-btn-cstm mo-sf-sync-config-btn">
                                Import
								<?php
								Utils::mo_sf_sync_render_image(
									'file-export.svg',
									array(
										'alt'   => 'Import',
										'class' => 'mo-sf-sync-config-btn-img',
									)
								);
								?>
                            </button>
                        </div>
                    </form>
				</div>
				
				<div class="mo-sf-sync-note-box">
					<h4>Notes</h4>
					<ul>
						<li>Helps you import your configuration from another WordPress instance/environment.</li>
						<li>To export configurations, go to <strong>Import/Export Tab &gt; Export Configuration</strong>.</li>
						<li>The import includes the following:</li>
						<ul class="mo-sf-sync-note-box-ul">
                            <li>Manage Application Configurations</li>
                            <li>Object Mappings</li>
                            <li>Advanced Sync Options</li>
						</ul>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<?php
}
