<?php
/**
 * This template displays full width pages.
 *
 * @package vantage
 * @since vantage 1.0
 * @license GPL 2.0
 * 
 * Template Name: All Services
 */

get_header(); 

?>

<?php 


/* 
 $custom_query = new WP_Query( 
								array(
									'post_type' => array( 'dental-services' ),
									'post_status' => array('publish', 'draft', 'private')  ,
									'showposts' => '-1',	
									'orderby' => 'name',	
									'order' => 'ASC'									
								) 
							);
						if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post();
						$post_obj = get_post($post->ID);
						$post_obj->post_type = 'select-services'; // Set this to the slug of your custom post type.
						wp_update_post( $post_obj ); 
						
 endwhile; endif; wp_reset_query(); die; */  ?>	
<?php 

	/* $post_obj = get_post('26302');
	$post_obj->post_type = 'page'; // Set this to the slug of your custom post type.
	wp_update_post( $post_obj );  */
	
	?>

<div id="main-content">


	<div class="inside_pages">
	<div class="container" style="padding-top:0px !important;">
		<div id="content-area" class="clearfix">
			

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="position: relative;">
<div id="loading" style="position: fixed;left: 40%;display:none;"></div>

<?php 
global $post;

$current_user = wp_get_current_user();
  
?>
<div class="opacityy">
		<div class="entry-header">			
			<p>Below are the links to our new dental services pages, which are now available to replace the existing dental services pages on your website. To select which pages you would like added, simply click on the checkbox next to each page. You can preview each page by clicking on its title. Once you have selected all the pages you want, click on any of the Submit buttons to proceed.</p>
			
		</div><!-- .entry-header -->
				<div class="actions_b">
				<input type="button" class="check-all" value="Check All">
				<input type="button" class="submit" value="Submit">
				<div class="response blink"></div>
				</div>	
				<form action="" id="formdata" method="post">
									
					<div class="dental_s">						
						<?php 
						$catsArray = array(11, 8, 9, 10);
						$args = array(
						   'taxonomy' => 'selectservicescat',
						   'include' => $catsArray,
						   'orderby' => 'include',
						   'order'   => 'ASC',
						   'hide_empty' => false,
						   'exclude' => 24,
					    );
						
						
			
						$cats = get_terms($args);
						// loop through the categries
						foreach ($cats as $cat) {
							
							// setup the cateogory ID
							$cat_slug= $cat->slug;
							
							if($cat_slug == 'advanced-care')
							{
								$url = site_url().'/advanced-care';
							}
							else if($cat_slug == 'cosmetic')
							{
								$url = site_url().'/dental-services/cosmetic-dentistry-gaithersburg';
							} 
							else if($cat_slug == 'preventative')
							{
								$url = site_url().'/preventative-dentistry';
							} 
							else if($cat_slug == 'restorative')
							{
								$url = site_url().'/restorative-dentistry';
							}
							
							$custom_query = new WP_Query( 
								array(
									'posts_per_page' => -1,
									'post_type' => 'select-services',
									'showposts' => '-1',
									'post_status' => 'any',									
									'meta_key'       => 'orderNo',
									'orderby'        => 'meta_value_num',
									'order'          => 'ASC',		
									'tax_query' => array(
										array(
											'taxonomy' => 'selectservicescat',
											'field' => 'term_id',
											'terms' => $cat->term_id,
										)
									)
								)
							);
							
							$custom_query1 = new WP_Query( 
								array(
									'posts_per_page' => -1,
									'post_type' => 'select-services',
									'showposts' => '-1',
									'post_status' => 'publish',									
									'meta_key'       => 'orderNo',
									'orderby'        => 'meta_value_num',
									'order'          => 'ASC',										
									'tax_query' => array(
										array(
											'taxonomy' => 'selectservicescat',
											'field' => 'term_id',
											'terms' => $cat->term_id,
										)
									)
								)
							);
							
							if ( $custom_query1->have_posts() ) {
								$url = $url;							
							}
							else {
								$url = '#';
							}
							$aclass = '';
							if($url != '#')
							{
								$aclass = 'colorblue';
							}
							
							
							// Make a header for the cateogry
						echo '<div class="cat_divide">';
							echo "<h2><a href=".$url." class=".$aclass." target='_blank'>".$cat->name."</a></h2>";
							// create a custom wordpress query
						
							
	
	
						if ( $custom_query->have_posts() ) : 
						
						$count = 1;
						while ( $custom_query->have_posts() ) : $custom_query->the_post();
						
						?>						
							<div class="serv <?php /* echo 'bold'.$post->ID; */ /* if( has_term( 'indent', 'dentalservicescat', $post->ID ) ) { echo 'indentpost'; } */ ?> ">
							<input type="checkbox" class="ids" name="ids[]" <?php if(get_post_status( $post->ID ) == 'publish') echo 'checked="checked"'; ?> value="<?php echo $post->ID; ?>">
							<h3><a href="<?php echo get_post_permalink($post->ID); ?>" target="_blank"><?php the_title(); ?></a></h3>
							</div>	
						<?php 
							
						if($cat->name == 'Preventative' && $count == 6) { ?>
							<br/><br/>
							<h2> Additional Services </h2>
							<div class="serv">
								<input type="checkbox" class="ids" name="ids[]" <?php if(get_post_status('27090') == 'publish') echo 'checked="checked"'; ?> value="<?php echo '27090'; ?>">
								<h3><a href="<?php echo get_post_permalink('27090'); ?>" target="_blank">General Dentistry</a></h3>
							</div>	
							
							<div class="serv">
								<input type="checkbox" class="ids" name="ids[]" <?php if(get_post_status( '26794' ) == 'publish') echo 'checked="checked"'; ?> value="<?php echo '26794'; ?>">
								<h3><a href="<?php echo get_post_permalink('26794'); ?>" target="_blank">Pediatric Dentistry</a></h3>
							</div>
						<?php }	
						
						
						?>	
						<?php $count++; endwhile; endif;  wp_reset_query(); echo '</div>'; }    ?>
						
						
						
						

						
						
					</div>
					
										
				
					</form>
	<div class="actions_b">
		<input type="button" class="check-all" value="Check All">
		<input type="button" class="submit" value="Submit">
		<div class="response blink"></div>
	</div>
<script>
jQuery(document).ready(function() {
	
	jQuery('.submit').click(function() {
	jQuery(".opacityy").css('opacity','0.2');
	jQuery('#loading').show();
	jQuery('#loading').html('<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/giphy.gif" style="width:60px;height:auto;">');
	var form = jQuery("#formdata");
	jQuery.ajax({
		
		url: "<?php echo site_url(); ?>/postsupdate.php",
		type: "post",
		data: form.serialize(),
		success: function(data) {
			//alert(data);
			jQuery('#loading').hide('fast');
			jQuery(".opacityy").css('opacity','1');
			jQuery('.response').text(data);
			jQuery('.response').html('Services Updated');
			jQuery('.response').css('display','block');
			jQuery(".blink").animate({
				opacity:"0.5"
			  }, 1000, function() {
				jQuery(".blink").animate({
					opacity:"1"
				}, 1000).fadeOut(400);
			  }); 
			  
			 location.reload();	
		}
	});
	
	});
	
	jQuery(".check-all").click(function() {
    if (jQuery(this).val() == 'Check All') {
        jQuery('.ids').prop('checked',true); 
        jQuery(this).val('Uncheck All');
    } else {
        jQuery('.ids').removeAttr('checked');
        jQuery(this).val('Check All');
    }

});
	
});
</script>
	
	<style>
	
.deleteicon {
    display: flex;
    justify-content: flex-end;
    flex: 1;
	cursor: pointer;
}

.serv1.suggested {
    display: block;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}	
	.deletediv {
    clear: both;
    float: left;
    width: 100%;
}
	
.entry-header p {
    font-size: 17px;
}	
	
.serv1 input[type="text"] {
    float: left;
    width: 100%;
    padding: 7px;
    margin-bottom: 10px;
}
.serv1 h3 {
    float: left;
    width: 100%;
    display: block;
    font-size: 18px;
}
.dental_s a {
	text-decoration: underline;
    color: #0c71c3 !important;
}
header.entry-header {
    padding-top: 30px;
}
.suggested_serv {
	 padding-top: 0px;
}
a.colorblue {
    color: #0c71c3;
}	
.container {
    width: 89%;
    max-width: 95% !important;
    margin: auto;
}	
	
	#main-content .container {
    padding-top: 20px !important;
}	
	.dental_s, .services_s {
		float: left;
		width: auto;     gap: 70px;
		display: flex;
	}
	
	.serv {
    width: 100%;
    float: none;
    margin-bottom: 25px;
    display: flex;
}
		
	input.ids {
    width: 16px;
    margin-right: 7px;
    height: 20px;
}	
	
	.blink {    display: block;
    float: left;
    width: 100%;
    padding: 10px;
    font-size: 20px;
    color: green;}
	
	article.post, article.page {
     margin-bottom: 0px;
    padding-bottom: 0px;
    border-bottom: none;
}

.inside_page, .inside_page_custom {
    padding-bottom: 40px;
}
#response {
    -moz-animation: cssAnimation 0s ease-in 5s forwards;
    /* Firefox */
    -webkit-animation: cssAnimation 0s ease-in 5s forwards;
    /* Safari and Chrome */
    -o-animation: cssAnimation 0s ease-in 5s forwards;
    /* Opera */
    animation: cssAnimation 0s ease-in 5s forwards;
    -webkit-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
}

.actions_b {display:block;margin-bottom:20px;    clear: both; width:100%;}

.bold316 h3, .bold582 h3 , .bold661 h3 , .bold705 h3 , .bold694 h3 , .bold589 h3 , .bold587 h3 , .bold672 h3  {font-weight:bold;}
	
.serv.indentpost {
    padding-left: 25px;
}	

h3 {
    float: left;
    margin: 3px 0;
    font-size: 16px;
    font-weight: normal;
    line-height: normal;
    padding: 0;
}

	</style>
	



</article><!-- #post-<?php the_ID(); ?> -->
</div>			
		</div> <!-- #content-area -->
		</div> <!-- .container -->
		</div>

</div> <!-- #main-content -->

<?php get_footer(); ?>