<?php 
$openAI_status = 'active';
$wooStatus     = '';
if ( EH_CRM_WOO_STATUS ) { 
	$openAI_status = '';
	$wooStatus     = 'active';
}?>
<form method="post" >
	<div>
		<div class="" >
			<div>
				<div class="gap-3 align-items-center">
					<div class="panel-body">
						<ul id="myTabs" class="nav nav-pills nav-justified" role="tablist" data-tabs="tabs">
							<?php if ( EH_CRM_WOO_STATUS ) { ?>
							<li class=" <?php echo esc_html( $wooStatus ); ?>">
								<a href="#woocommerce_tab" data-toggle="tab" class="ticket_fields "><?php echo esc_attr__( 'WooCommerce', 'wsdesk' ); ?></a>
							</li>
							<?php } ?>
							<li class=" <?php echo esc_html( $openAI_status ); ?>">
								<a href="#gpt_tab" data-toggle="tab" class="ticket_fields "><?php echo esc_attr__( 'OpenAI - ChatGPT', 'wsdesk' ); ?>
									<sup class="text-success"><?php echo esc_attr__( '[Premium!]', 'wsdesk' ); ?></sup>
								</a>
							</li>
						</ul>
					</div>
					<div class="tab-content">
						<?php if ( EH_CRM_WOO_STATUS ) { ?>
						<div id="woocommerce_tab" class="tab-pane <?php echo esc_html( $wooStatus ); ?>">
							<?php include  EH_CRM_MAIN_VIEWS . 'settings/crm_woocommerce_settings.php' ; ?>
						</div>
						<?php } ?>
						<div id="gpt_tab" class="tab-pane <?php echo esc_html( $openAI_status ); ?>" style="margin-left : 20px;">
							<?php require  EH_CRM_MAIN_VIEWS . 'settings/chatgpt.php' ; ?>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>
</form>


<script>
	jQuery(document).ready(function() {
		if (jQuery('input[name="chatgpt_enabled"]').is(':checked')) {
			jQuery('.openai_api_key').removeClass('d-none');
		}

		jQuery('input[name="chatgpt_enabled"]').change(function() {
			if (jQuery(this).is(':checked')) {
			jQuery('.openai_api_key').removeClass('d-none');
			} else {
			jQuery('.openai_api_key').addClass('d-none');
			}
		});

		if (jQuery('input[name="customConfig_values"]').is(':checked')) {
			jQuery('.openai_config_values').removeClass('d-none');
		}

		jQuery('input[name="customConfig_values"]').change(function() {
			if (jQuery(this).is(':checked')) {
			jQuery('.openai_config_values').removeClass('d-none');
			} else {
			jQuery('.openai_config_values').addClass('d-none');
			}
		});
	});

</script>
