
<div class="mwp-hmbkp-schedule-settings">
	<?php
	if ( 'mainwp_hmbkp_edit_schedule' === $_GET['action'] && 'mainwp_hmbkp_edit_schedule_settings' === $_GET['mainwp_hmbkp_panel'] ) {
		require( MAINWP_HMBKP_PLUGIN_PATH . 'admin/schedule-form.php' );
	}
	?>

	<?php
	// Show the service form if we are viewing one
	foreach ( MAINWP\BackUpWordPress\Services::get_services( $schedule ) as $service ) :
		?>

	<?php if ( 'mainwp_hmbkp_edit_schedule' === $_GET['action'] && 'mainwp_hmbkp_edit_schedule_settings_' . $service->get_slug() === $_GET['mainwp_hmbkp_panel'] ) { ?>

			<h3><?php echo esc_html( $service->name ); ?></h3>

			<?php
			$mainwp_hmbkp_form_errors = mainwp_hmbkp_get_settings_errors();

			if ( ! empty( $mainwp_hmbkp_form_errors ) ) :
				?>

				<div id="hmbkp-warning" class="error settings-error">

					<?php foreach ( $mainwp_hmbkp_form_errors as $error ) { ?>
						<p><strong><?php echo esc_html( $error ); ?></strong></p>
			<?php } ?>

				</div>

				<?php
			endif;

			?>

			<form method="post" action="<?php echo admin_url( 'admin-post.php' ); ?>">

				<input type="hidden" name="mainwp_hmbkp_schedule_id" value="<?php echo esc_attr( $schedule->get_id() ); ?>" />
				<input type="hidden" name="action" value="mainwp_hmbkp_edit_schedule_services_submit" />

				<?php wp_nonce_field( 'hmbkp-edit-schedule-services', 'hmbkp-edit-schedule-services-nonce' ); ?>

				<?php $service->form(); ?>

		<?php submit_button( __( 'Done', 'mainwp-backupwordpress-extension' ) ); ?>

			</form>

			<?php break; ?>

		<?php } ?>

<?php endforeach; ?>

</div>
