<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
// ob_start();
?>
<center>
	<h3><?php esc_html_e( 'Initiate Ticket', 'wsdesk' ); ?></h3>
	<div class="crm-form-element">
		<span class="help-block" style="text-align: center"><?php esc_html_e( 'Start ticket with specified number', 'wsdesk' ); ?></span>
		<span style="display: inline-flex;">
			<input type="number" oninput="this.value = !!this.value && Math.abs(this.value) >= 0 ? Math.abs(this.value) : null" min="0" name="initiate_number" id="initiate_number" placeholder="Starting Number" class="form-control" style="height: auto;width: 100%;margin-right: 10px;padding: 5px;">
			<button type="button" id="start_initiate_ticket" class="btn btn-primary"><?php esc_html_e( 'Set Number', 'wsdesk' ); ?></button>
		</span>
	</div>
	<span class="crm-divider"></span>
	<div class="col-md-12" style="margin-bottom: 20px;">
		<div class="col-md-4">
			<div class="crm-form-element">
				<span class="help-block" style="text-align: center"><?php esc_html_e( 'Delete all tickets in trash', 'wsdesk' ); ?></span>
				<span style="display: inline-flex;">
					<button type="button" id="empty_trash" class="btn btn-primary btn-lg"><?php esc_html_e( 'Empty Trash', 'wsdesk' ); ?></button>
				</span>
			</div>
		</div>
		<div class="col-md-4">
			<div class="crm-form-element">
				<span class="help-block" style="text-align: center"><?php esc_html_e( 'Restore all tickets from trash', 'wsdesk' ); ?></span>
				<span style="display: inline-flex;">
					<button type="button" id="restore_trash" class="btn btn-primary btn-lg"><?php esc_html_e( 'Restore Trash', 'wsdesk' ); ?></button>
				</span>
			</div>
		</div>
		<div class="col-md-4">
			<div class="crm-form-element">
				<span class="help-block" style="text-align: center"><?php esc_html_e( 'Delete all scheduled trigger cache', 'wsdesk' ); ?></span>
				<span style="display: inline-flex;">
					<button type="button" id="empty_scheduled_trigger" class="btn btn-primary btn-lg"><?php esc_html_e( 'Clear Now', 'wsdesk' ); ?></button>
				</span>
			</div>
		</div>
	</div>
	<span class="crm-divider"></span>
	<form id="backup_wsdesk" method="POST" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>">
		<h3><?php esc_html_e( 'Backup Data (JSON)', 'wsdesk' ); ?></h3>
		<div class="crm-form-element">
			<div class="col-md-12">
				<span class="help-block"><?php esc_html_e( 'Specify the data to be Backup if needed?', 'wsdesk' ); ?></span>
				<input type="checkbox" name="backup_data_values[]" id="backup_data_values" value="settings" checked=""> <?php esc_html_e( 'Settings', 'wsdesk' ); ?>
				<input type="checkbox" name="backup_data_values[]" id="backup_data_values" value="tickets" checked=""> <?php esc_html_e( 'Tickets', 'wsdesk' ); ?>
				<input type="checkbox" name="backup_data_values[]" id="backup_data_values" value="archive_tickets" checked=""> <?php esc_html_e( 'Archive Tickets', 'wsdesk' ); ?>
				<input type="hidden" name="action" value="eh_crm_backup_data">
				<input type="hidden" name="nonce" value="<?php echo esc_html( wp_create_nonce( 'wsdesk_nonce' ) ); ?>">
			</div>
		</div>
		<div class="crm-form-element">
			<div class="col-md-12">
				<span class="help-block"><?php esc_html_e( 'Specify the date range for tickets Backup if needed?', 'wsdesk' ); ?></span>
				<input type="text" id="backup_date_range_start" placeholder="Start Date" name="backup_date_range_start"> -
				<input type="text" id="backup_date_range_end" placeholder="End Date" name="backup_date_range_end">
			</div>
		</div>
		<div class="crm-form-element">
			<div class="col-md-12" id="download_backup_button">
				<span class="help-block" style="text-align: center"><?php esc_html_e( 'Backing Up of WSDesk Data may require some time.', 'wsdesk' ); ?></span>
				<span class="help-block" style="text-align: center"><?php esc_html_e( 'Please note that attachments cannot be taken as backup.', 'wsdesk' ); ?></span>
				<button type="button" id="backup_data" data-loading-text="<?php esc_html_e( 'Preparing Data...', 'wsdesk' ); ?>" class="btn btn-primary btn-lg"><?php esc_html_e( 'Start Backup', 'wsdesk' ); ?></button>
			</div>
		</div>
	</form>
	<span class="crm-divider"></span>
	<h3><?php esc_html_e( 'Restore Data (JSON)', 'wsdesk' ); ?></h3>
	<div class="crm-form-element">
		<span class="help-block" style="text-align: center"><?php esc_html_e( 'WSDesk Restore Data File', 'wsdesk' ); ?></span>
		<input type="file" name="restore_file" accept=".json" id="restore_file" class="form-control" style="height: auto;width: 50%;padding: 5px;">
	</div>
	<div class="crm-form-element">
		<div class="col-md-12">
			<span class="help-block" style="text-align: center"><?php esc_html_e( 'Restoring WSDesk Data may take some time.', 'wsdesk' ); ?></span>
			<button type="button" id="restore_data" data-loading-text="<?php esc_html_e( 'Restoring Data...', 'wsdesk' ); ?>" class="btn btn-primary btn-lg"><?php esc_html_e( 'Start Restore', 'wsdesk' ); ?></button>
		</div>
	</div>

</center>
<?php
// return ob_get_clean();
