<?php	
		global $wpdb, $post;
		global $current_user;	
		wp_enqueue_style('wp-iv_directories-myaccount-style-11', wp_iv_directories_URLPATH . 'admin/files/css/iv-bootstrap.css');
		wp_enqueue_script('iv_directories-myaccount-style-12', wp_iv_directories_URLPATH . 'admin/files/js/bootstrap.min.js');

		// Save action   iv_directories_meta_save  
		//*************************	plugin file *********
			
 		 $iv_directories_approve= get_post_meta( $post->ID,'iv_directories_approve', true );
		 $iv_directories_current_author= $post->post_author;
		 $curr_post_id=$post->ID;
		 
 		?>
 
 <div class="bootstrap-wrapper">
 	<div class="welcome-panel container-fluid">
   
                             
                 
						<div class="row">
							<div class="col-md-12">							
								<div class=" row form-group ">
									<label for="text" class=" col-md-5 control-label"><?php _e('Image Gallery','ivdirectories'); ?> 
										<button type="button" onclick="edit_gallery_image('gallery_image_div');"  class="btn btn-xs green-haze"><?php _e('Add Images','ivdirectories'); ?></button>
									 </label>						
								</div>
								<div class=" row form-group ">	
											<!--
										<div class="col-md-12" id="gallery_image_div">
											
											<a  href="javascript:void(0);" onclick="edit_gallery_image('gallery_image_div');"  >									
											<?php  echo '<img src="'. wp_iv_directories_URLPATH.'assets/images/gallery_icon.png">'; ?>			
											</a>
															
										</div>
											-->
											<?php
											$gallery_ids=get_post_meta($curr_post_id ,'image_gallery_ids',true);
											$gallery_ids_array = array_filter(explode(",", $gallery_ids));
											?>
										<input type="hidden" name="gallery_image_ids" id="gallery_image_ids" value="<?php echo $gallery_ids; ?>">
										
										<div class="col-md-12" id="gallery_image_div">
											<?php
												if(sizeof($gallery_ids_array)>0){ 
													foreach($gallery_ids_array as $slide){	
														
												?>
												<div id="gallery_image_div<?php echo $slide;?>" class="col-md-2"><img  class="img-responsive"  src="<?php echo wp_get_attachment_url( $slide ); ?>"><button type="button" onclick="remove_gallery_image('gallery_image_div<?php echo $slide;?>', <?php echo $slide;?>);"  class="btn btn-xs btn-danger">Remove</button> </div>
												<?php
													}
												 }
												?>
												
										</div>									
								</div>
							

						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('Address','ivdirectories'); ?></label>							
							<div class=" "> 
								<input type="text" class="form-control" name="address" id="address" value="<?php echo get_post_meta($post->ID,'address',true); ?>" placeholder="<?php _e('Enter address Here','ivdirectories'); ?>">
							</div>
														
						</div>
						
						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('City','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="city" id="city" value="<?php echo get_post_meta($post->ID,'city',true); ?>" placeholder="<?php _e('Enter city ','ivdirectories'); ?>">
						</div>
						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('Zipcode','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="postcode" id="postcode" value="<?php echo get_post_meta($post->ID,'postcode',true); ?>" placeholder="<?php _e('Enter Zipcode ','ivdirectories'); ?>">
						</div>
						

						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('State','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="state" id="state" value="<?php echo get_post_meta($post->ID,'state',true); ?>" placeholder="<?php _e('Enter State ','ivdirectories'); ?>">
						</div>
						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('Country','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="country" id="country" value="<?php echo get_post_meta($post->ID,'country',true); ?>" placeholder="<?php _e('Enter Country ','ivdirectories'); ?>">
						</div>
						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('Latitude','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="latitude" id="latitude" value="<?php echo get_post_meta($post->ID,'latitude',true); ?>" placeholder="<?php _e('Enter latitude ','ivdirectories'); ?>">
						</div>
						<div class=" form-group">
							<label for="text" class=" control-label"><?php _e('Longitude','ivdirectories'); ?></label>							
							
								<input type="text" class="form-control" name="longitude" id="longitude" value="<?php echo get_post_meta($post->ID,'longitude',true); ?>" placeholder="<?php _e('Enter longitude ','ivdirectories'); ?>">
						</div>
												
					
						<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapsethirty2">
									  <?php _e('Awards','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapsethirty2">
									   <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapsethirty2" class="panel-collapse collapse">
									<div class="panel-body">
									<?php
										// video, event ,  award
										//if($this->check_write_access('award')){												
										?>	
												
									  <div id="awards">
												
												<?php	$aw=0;	 
													   for($i=0;$i<20;$i++){
														 		  
														   if(get_post_meta($post->ID,'_award_title_'.$i,true)!='' || get_post_meta($post->ID,'_award_description_'.$i,true) || get_post_meta($post->ID,'_award_year_'.$i,true)|| get_post_meta($post->ID,'_award_image_id_'.$i,true) ){?>
															   
															   
															   <div id="award">
																   <div id="award_delete_<?php echo $i; ?>">
																   
																	<div class=" form-group">
																		<span class="pull-right"  > 
																		<button type="button" onclick="award_delete(<?php echo $i; ?>);"  class="btn btn-xs btn-danger">X</button>
																		</span>
																		<label for="text" class=" control-label"><?php _e('Award Title','ivdirectories'); ?>
																			
																		</label>
																		
																		<div class="  "> 
																			<input type="text" class="form-control" name="award_title[]" id="award_title[]" value="<?php echo get_post_meta($post->ID,'_award_title_'.$i,true); ?>" placeholder="<?php _e('Enter award title','ivdirectories'); ?>">
																		</div>																
																	</div>		
																	<div class=" form-group">
																		<label for="text" class=" control-label"><?php _e('Award Description','ivdirectories'); ?></label>
																		
																		<div class="  "> 
																			<input type="text" class="form-control" name="award_description[]" id="award_description[]" value="<?php echo get_post_meta($post->ID,'_award_description_'.$i,true); ?>" placeholder="<?php _e('Enter Award Description','ivdirectories'); ?>">
																		</div>																
																	</div>
																	<div class=" form-group">
																		<label for="text" class=" control-label"><?php _e('Year(s) for which award was received','ivdirectories'); ?></label>
																		
																		<div class="  "> 
																			<input type="text" class="form-control" name="award_year[]" id="award_year[]" value="<?php echo get_post_meta($post->ID,'_award_year_'.$i,true); ?>" placeholder="<?php _e('Enter Award Year','ivdirectories'); ?>">
																		</div>																
																	</div>	
																	<div class=" form-group " style="margin-top:10px">
																		<label for="text" class=" col-md-5 control-label"><?php _e('Award Image','ivdirectories'); ?>  </label>
																		<div class="col-md-4" id="award_image_div">
																			<?php 
																				if(get_post_meta($post->ID,'_award_image_id_'.$i,true)!=''){?>
																					<a  href="javascript:void(0);" onclick="award_post_image(this);"  >		
																					<img src="<?php echo wp_get_attachment_url( get_post_meta($post->ID,'_award_image_id_'.$i,true) ); ?> "  class="img-responsive">
																					<input type="hidden" name="award_image_id[]" id="award_image_id[]" value="<?php echo get_post_meta($post->ID,'_award_image_id_'.$i,true); ?>">
																					</a>
																				<?php
																				}else{?>
																						<a  href="javascript:void(0);" onclick="award_post_image(this);"  >									
																						<?php  echo '<img width="100px" src="'. wp_iv_directories_URLPATH.'assets/images/image-add-icon.png">'; ?>			
																						</a>																					
																			<?php		
																				}																		
																			?>
																							
																		</div>						
																	</div>
																</div>		
															</div>	
															 <div class="clearfix"></div>	 
															  <hr>
															 		
																	
															<?php
															$aw++;	
															}				 
														
														}
													?>
															<div id="awardmain">
															<div class=" form-group">
																<label for="text" class=" control-label"><?php _e('Award Title','ivdirectories'); ?></label>
																
																<div class="  "> 
																	<input type="text" class="form-control" name="award_title[]" id="award_title[]" value="" placeholder="<?php _e('Enter award title','ivdirectories'); ?>">
																</div>																
															</div>		
															<div class=" form-group">
																<label for="text" class=" control-label"><?php _e('Award Description','ivdirectories'); ?></label>
																
																<div class="  "> 
																	<input type="text" class="form-control" name="award_description[]" id="award_description[]" value="" placeholder="<?php _e('Enter Award Description','ivdirectories'); ?>">
																</div>																
															</div>
															<div class=" form-group">
																<label for="text" class=" control-label"><?php _e('Year(s) for which award was received','ivdirectories'); ?></label>
																
																<div class="  "> 
																	<input type="text" class="form-control" name="award_year[]" id="award_year[]" value="" placeholder="<?php _e('Enter Award Year','ivdirectories'); ?>">
																</div>																
															</div>	
															<div class=" form-group " style="margin-top:10px">
																<label for="text" class=" col-md-5 control-label"><?php _e('Award Image','ivdirectories'); ?>  </label>
																<div class="col-md-4" id="award_image_div">
																	<a  href="javascript:void(0);" onclick="award_post_image(this);"  >									
																	<?php  echo '<img width="100px" src="'. wp_iv_directories_URLPATH.'assets/images/image-add-icon.png">'; ?>			
																	</a>				
																</div>						
															</div>	
															</div>	
													
																																
											
									 </div>
											<div class=" row  form-group ">
												<div class="col-md-12" >	
												<button type="button" onclick="add_award_field();"  class="btn btn-xs green-haze"><?php _e('Add More','ivdirectories'); ?></button>
												</div>
											</div>
											
									
									
											<?php
											//}
											?>
									
								  </div>
								  
								</div>
					  </div>
					
				
										
										
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
									  <?php _e('Contact Info','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour">
									  <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseFour" class="panel-collapse collapse">
								  <div class="panel-body">											
									<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Phone','ivdirectories'); ?></label>						
											<div class="  "> 
												<input type="text" class="form-control" name="phone" id="phone" value="<?php echo get_post_meta($post->ID,'phone',true); ?>" placeholder="<?php _e('Enter Phone Number','ivdirectories'); ?>">
											</div>																
									</div>
									<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Fax','ivdirectories'); ?></label>
											
											<div class="  "> 
												<input type="text" class="form-control" name="fax" id="fax" value="<?php echo get_post_meta($post->ID,'fax',true); ?>" placeholder="<?php _e('Enter Fax Number','ivdirectories'); ?>">
											</div>																
									</div>	
									<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Email Address','ivdirectories'); ?></label>
											
											<div class="  "> 
												<input type="text" class="form-control" name="contact-email" id="contact-email" value="<?php echo get_post_meta($post->ID,'contact-email',true); ?>" placeholder="<?php _e('Enter Email Address','ivdirectories'); ?>">
											</div>																
									</div>
									<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Web Site','ivdirectories'); ?></label>
											
											<div class="  "> 
												<input type="text" class="form-control" name="contact_web" id="contact_web" value="<?php echo get_post_meta($post->ID,'contact_web',true); ?>" placeholder="<?php _e('Enter Web Site','ivdirectories'); ?>">
											</div>																
									</div>
									
									
								  </div>
								</div>
					  </div>
					
					
					<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
									  <?php _e('Videos','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
									   <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseThree" class="panel-collapse collapse">
								  <div class="panel-body">	
									  <?php
											// video, event , coupon , vip_badge
										 if($this->check_write_access('video')){
											
										?>										
										<div class=" form-group">
											
												<label for="text" class=" control-label"><?php _e('Youtube','ivdirectories'); ?></label>
												
												<div class="  "> 
													<input type="text" class="form-control" name="youtube" id="youtube" value="<?php echo get_post_meta($post->ID,'youtube',true); ?>" placeholder="<?php _e('Enter Youtube video ID, e.g : bU1QPtOZQZU ','ivdirectories'); ?>">
												</div>																
										</div>
										<div class=" form-group">
												<label for="text" class=" control-label"><?php _e('Vimeo','ivdirectories'); ?></label>
												
												<div class="  "> 
													<input type="text" class="form-control" name="vimeo" id="vimeo" value="<?php echo get_post_meta($post->ID,'vimeo',true); ?>" placeholder="<?php _e('Enter vimeo ID, e.g : 134173961','ivdirectories'); ?>">
												</div>																
										</div>
										<?php
										}else{
												_e('Please upgrade your account to add video ','ivdirectories');
										}
										?>
									
								  </div>
								</div>
					  </div>
					<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseFive">
									  <?php _e('Social Profiles','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseFive">
									   <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseFive" class="panel-collapse collapse">
								  <div class="panel-body">											
										
										<div class="form-group">
										<label class="control-label">FaceBook</label>
										<input type="text" name="facebook" id="facebook" value="<?php echo get_post_meta($post->ID,'facebook',true); ?>" class="form-control"/>
									  </div>
									  <div class="form-group">
										<label class="control-label">Linkedin</label>
										<input type="text" name="linkedin" id="linkedin" value="<?php echo get_post_meta($post->ID,'linkedin',true); ?>" class="form-control"/>
									  </div>
									  <div class="form-group">
										<label class="control-label">Twitter</label>
										<input type="text" name="twitter" id="twitter" value="<?php echo get_post_meta($post->ID,'twitter',true); ?>" class="form-control"/>
									  </div>
									  <div class="form-group">
										<label class="control-label">Google+ </label>
										<input type="text" name="gplus" id="gplus" value="<?php echo get_post_meta($post->ID,'gplus',true); ?>"  class="form-control"/>
									  </div>
									   <div class="form-group">
										<label class="control-label">Instagram </label>
										<input type="text" name="instagram" id="instagram" value="<?php echo get_post_meta($post->ID,'instagram',true); ?>"  class="form-control"/>
									  </div>
									  
						  									
										
								  </div>
								</div>
					  </div>
					
					
					<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
									  <?php _e('Additional Info','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
									 <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseTwo" class="panel-collapse collapse">
								  <div class="panel-body">											
										<?php							
											
											
											$default_fields = array();
												$field_set=get_option('iv_directories_fields' );
											if($field_set!=""){ 
													$default_fields=get_option('iv_directories_fields' );
											}else{															
													$default_fields['business_type']='Business Type';
													$default_fields['main_products']='Main Products';
													$default_fields['number_of_employees']='Number Of Employees';
													$default_fields['main_markets']='Main Markets';
													$default_fields['total_annual_sales_volume']='Total Annual Sales Volume';	
											}
											if(sizeof($field_set)<1){																
													$default_fields['business_type']='Business Type';
													$default_fields['main_products']='Main Products';
													$default_fields['number_of_employees']='Number Of Employees';
													$default_fields['main_markets']='Main Markets';
													$default_fields['total_annual_sales_volume']='Total Annual Sales Volume';
											 }							
																	
														
										$i=1;							
										foreach ( $default_fields as $field_key => $field_value ) { ?>	
												 <div class="form-group">
													<label class="control-label"><?php echo _e($field_value, 'wp_iv_directories'); ?></label>
													<input type="text" placeholder="<?php echo 'Enter '.$field_value;?>" name="<?php echo $field_key;?>" id="<?php echo $field_key;?>"  class="form-control" value="<?php echo get_post_meta($post->ID,$field_key,true); ?>"/>
												  </div>
										
										<?php
										}
										?>			
										
								  </div>
								</div>
					  </div>
					
					
						  <div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									  <?php _e('Opening Time','ivdirectories'); ?> 
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									  <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseOne" class="panel-collapse collapse">
								  <div class="panel-body">	
								  <?php					
										$opeing_days = get_post_meta($post->ID ,'_opening_time',true);
										if($opeing_days!=''){?>						
											
											<?php	
												$i=1;
												if(sizeof($opeing_days)>0){
													foreach($opeing_days as $key => $item){
														$day_time = explode("|", $item);	
														echo '<div id="old_days'. $i .'">
															<div class="col-md-4"><h5>'.$key.'</h5></div> <div class="col-md-7"> <h5>: '.$day_time[0].' - '.$day_time[1].'</h5></div><div class="col-md-1"> <button type="button" onclick="remove_old_day('.$i.');"  class="btn btn-xs btn-danger">X</button> 												
															 </div>
															<input type="hidden" name="day_name[]" id="day_name[]" value="'.$key.'">
															<input type="hidden" name="day_value1[]" id="day_value1[]" value="'.$day_time[0].'">
															<input type="hidden" name="day_value2[]" id="day_value2[]" value="'.$day_time[1].'">
															</div>
															';
														$i++;
													}	
												}										
										}
									 ?>		
									<div id="day_field_div">
										<div class=" row form-group " id="day-row1" >									
											<div class=" col-md-4"> 
											<select name="day_name[]" id="day_name[]" class="form-control">	
											<option value=""></option> 
											<option value="<?php _e('Monday','ivdirectories'); ?> "> <?php _e('Monday','ivdirectories'); ?>  </option> 
											<option value="<?php _e('Tuesday','ivdirectories'); ?>"><?php _e('Tuesday','ivdirectories'); ?></option> 
											<option value="<?php _e('Wednesday','ivdirectories'); ?>"><?php _e('Wednesday','ivdirectories'); ?></option> 
											<option value="<?php _e('Thursday','ivdirectories'); ?>"><?php _e('Thursday','ivdirectories'); ?></option> 
											<option value="<?php _e('Friday','ivdirectories'); ?>"><?php _e('Friday','ivdirectories'); ?></option> 
											<option value="<?php _e('Saturday','ivdirectories'); ?>"><?php _e('Saturday','ivdirectories'); ?></option> 
											<option value="<?php _e('Sunday','ivdirectories'); ?>"><?php _e('Sunday','ivdirectories'); ?></option> 
											</select>
											</div>		
											<div  class=" col-md-4">
												<input type="text" placeholder="<?php _e('12:00 AM','ivdirectories'); ?> " name="day_value1[]" id="day_value1[]"  class="form-control" />
																							
											</div>
											<div  class="col-md-4">
											<input type="text" placeholder="<?php _e('12:00 PM','ivdirectories'); ?> " name="day_value2[]" id="day_value2[]"  class="form-control" />																							
											</div>
											
										</div>
									</div>	
											
									<div class=" row  form-group ">
										<div class="col-md-12" >	
										<button type="button" onclick="add_day_field();"  class="btn btn-xs green-haze"><?php _e('Add More','ivdirectories'); ?></button>
										</div>
									</div>	
								  </div>
								</div>
					  </div>
					<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseSix">
									  <?php _e('Event','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseSix">
									  <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseSix" class="panel-collapse collapse">
								  <div class="panel-body">											
										<?php
											// video, event , coupon , vip_badge , booking
										 if($this->check_write_access('event')){
											
										?>		
										<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Event Title','ivdirectories'); ?></label>
												<input type="text" class="form-control" name="event-title" id="event-title" value="<?php echo get_post_meta($post->ID,'event_title',true); ?>" placeholder="<?php _e('Enter Title Here','ivdirectories'); ?>">							
										</div>	
										<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Event Detail','ivdirectories'); ?></label>
												<?php
													$settings_a = array(															
														'textarea_rows' =>10,	
														'editor_class' => 'form-control'															 
														);
													$content_client = get_post_meta($post->ID,'event_detail',true);//$content;//get_option( 'iv_directories_signup_email');
													$editor_id = 'event-detail';
													//wp_editor( $content_client, $editor_id,$settings_a );	
																						
													?>
													<textarea id="event-detail" name="event-detail"  rows="4" class="form-control" > <?php echo $content_client; ?> </textarea>
											
												
												
										</div>
										<div class=" row form-group " style="margin-top:10px">
											<label for="text" class=" col-md-5 control-label"><?php _e('Event Image','ivdirectories'); ?>  </label>
										
											<div class="col-md-4" id="event_image_div">										
												
											
													<?php
													
													if(get_post_meta($post->ID,'_event_image_id',true)!=''){
															$event_image_src= wp_get_attachment_url( get_post_meta($post->ID,'_event_image_id',true) );
															?>
															<img  class="img-responsive"  src="<?php echo $event_image_src; ?>">
																														
													
													<?php		
													}else{ ?>
															<a  href="javascript:void(0);" onclick="event_post_image('event_image_div');"  >									
															<?php  echo '<img width="100px" src="'. wp_iv_directories_URLPATH.'assets/images/image-add-icon.png">'; ?>	
															</a>
															
																
															
													<?php
													}
													?>			
											</div>
										
											<div class="col-md-3" id="event_image_edit">	
													<?php
													
													if(get_post_meta($post->ID,'_event_image_id',true)!=''){
															
															?>															
															<button type="button" onclick="event_post_image('event_image_div');"  class="btn btn-xs green-haze">Edit</button> &nbsp;<button type="button" onclick="remove_event_image('event_image_div');"  class="btn btn-xs green-haze">Remove</button>
															
													
													<?php		
													}else{ ?>
															<button type="button" onclick="event_post_image('event_image_div');"  class="btn btn-xs green-haze"><?php _e('Add','ivdirectories'); ?></button>
													<?php
													}
													?>		
											</div>	
											
											<input type="hidden" name="event_image_id" id="event_image_id" value="<?php echo get_post_meta($post->ID,'_event_image_id',true); ?>" >
											
																				
										</div>	
										<?php
										}else{
												_e('Please upgrade your account to add event ','ivdirectories');
										}
										?>
								  </div>
								
								</div>
					  </div>
					<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapsenine">
									  <?php _e('Booking','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapsenine">
									  <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapsenine" class="panel-collapse collapse">
								  <div class="panel-body">	
									  <?php
											// video, event , coupon , vip_badge , booking
										 if($this->check_write_access('booking')){
											
										?>	
											 <div class="form-group">
												<label class="control-label"><?php _e('Booking Detail','ivdirectories'); ?>  </label>
												
												<?php
													$settings_booking = array(															
														'textarea_rows' =>2,	
														'editor_class' => 'form-control'															 
														);
													$content_client = get_post_meta($post->ID,'booking_detail',true);
													$editor_id = 'booking_detail';
													//wp_editor( $content_client, $editor_id, $settings_booking );	
													
													$booking_shortcode = get_post_meta($post->ID,'booking',true);									
													?>
												<textarea id="booking_detail" name="booking_detail"  rows="4" class="form-control" > <?php echo $content_client; ?> </textarea>
										  </div>
										  <div class="form-group">
												<label class="control-label"><?php _e('Or, Booking Shortcode','ivdirectories'); ?>  </label>
												<input type="text" name="booking" id="booking"  placeholder="e.g : [events_calendar long_events=1]" class="form-control" value="<?php echo $booking_shortcode; ?>" />
										  </div>
										  <?php
										}else{
												_e('Please upgrade your account to add booking detail ','ivdirectories');
										}
										?>
								  </div>
								</div>
					  </div>
					
						<div class="clearfix"></div>	
					<div class="panel panel-default">
								<div class="panel-heading">
								  <h4 class="panel-title col-lg-10">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseSeven1">
									  <?php _e('Deal/Coupon','ivdirectories'); ?>
									</a>
								  </h4>
									<h4 class="panel-title" style="text-align:right;color:blue;font-size:12px;">
									<a data-toggle="collapse" data-parent="#accordion" href="#collapseSeven1">
									   <?php _e('[ Edit ]','ivdirectories'); ?> 
									</a>
								  </h4>
								</div>
								<div id="collapseSeven1" class="panel-collapse collapse">
								  <div class="panel-body">											
										
										<div class=" form-group">
											
											<label for="text" class="control-label"><?php _e('Title','ivdirectories'); ?></label>
												<input type="text" class="form-control" name="deal-title" id="deal-title" value="<?php  echo get_post_meta($post->ID,'deal_title',true);?>" placeholder="<?php _e('Enter Title Here','ivdirectories'); ?>">							
										</div>	
												<?php
												$currencyCode= get_option('_iv_directories_api_currency');
												?>
										<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Deals/Coupon Amount '.$currencyCode,'ivdirectories'); ?></label>
												
												<input type="text" class="form-control" name="deal-amount" id="deal-amount" value="<?php  echo get_post_meta($post->ID,'deal_amount',true);?>" placeholder="<?php _e('Enter Deals or Coupon Amount on '.$currencyCode.' [ No currency, Only Number]','ivdirectories'); ?>">							
										</div>
									
										<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Paypal Email Address [Amount will deposit here]','ivdirectories'); ?></label>
												<input type="text" class="form-control" name="deal-paypal" id="deal-paypal" value="<?php  echo get_post_meta($post->ID,'deal_paypal',true);?>" placeholder="<?php _e('Enter Your Paypal Email Address','ivdirectories'); ?>">							
										</div>
										
										<div class=" form-group">
											<label for="text" class=" control-label"><?php _e('Detail','ivdirectories'); ?></label>
													<?php
														$settings_a = array(															
															'textarea_rows' =>10,	
															'editor_class' => 'form-control'															 
															);
														$content_client =get_post_meta($post->ID,'deal_detail',true);
														$editor_id = 'deal-detail';
														wp_editor( $content_client, $editor_id,$settings_a );	
																							
														?>
													
										</div>
									
										<div class="row form-group " >
											<label for="text" class=" col-md-5 control-label" ><?php _e('Deal/Coupon Image','ivdirectories'); ?></label>
										
											<div class="col-md-4" id="deal_image_div" >
												
												<?php													
													if(get_post_meta($post->ID,'_deal_image_id',true)!=''){
															$deal_image_src= wp_get_attachment_url( get_post_meta($post->ID,'_deal_image_id',true) );
															?>
															<img  class="img-responsive"  src="<?php echo $deal_image_src; ?>">
																														
													
													<?php		
													}else{ ?>
															<a  href="javascript:void(0);" onclick="deal_post_image('deal_image_div');"  >									
															<?php  echo '<img width="100px" src="'. wp_iv_directories_URLPATH.'assets/images/image-add-icon.png">'; ?>	
															</a>
															
																
															
													<?php
													}
													?>							
											</div>
											
											<input type="hidden" name="deal_image_id" id="deal_image_id" value="<?php echo get_post_meta($post->ID,'_deal_image_id',true);  ?>">
											
											<div class="col-md-3" id="deal_image_edit">													
												<?php
													
													if(get_post_meta($post->ID,'_deal_image_id',true)!=''){
															
															?>															
															<button type="button" onclick="deal_post_image('deal_image_div');"  class="btn btn-xs green-haze">Edit</button> &nbsp;<button type="button" onclick="remove_deal_image('deal_image_div');"  class="btn btn-xs green-haze">Remove</button>
															
													
													<?php		
													}else{ ?>
															<button type="button" onclick="deal_post_image('deal_image_div');"  class="btn btn-xs green-haze"><?php _e('Add','ivdirectories'); ?></button>
													<?php
													}
													?>	
												
											</div>									
										</div>	
										
						
								
						 </div>
								
								
								</div>
					  </div>
						
															 
						
						  </div>
						</div>
			                     
                 <input type="hidden" name="listing_data_submit" id="listing_data_submit" value="yes">
                 
          <!-- END PROFILE CONTENT -->

   
	</div>
 </div>         
	 <script>
				 
		 
		 
function iv_save_post (){
	tinyMCE.triggerSave();	
	var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
	var loader_image = '<img src="<?php echo wp_iv_directories_URLPATH. "admin/files/images/loader.gif"; ?>" />';
				jQuery('#update_message').html(loader_image);
				var search_params={
					"action"  : 	"iv_directories_update_wp_post",	
					"form_data":	jQuery("#edit_post").serialize(), 
				};
				jQuery.ajax({					
					url : ajaxurl,					 
					dataType : "json",
					type : "post",
					data : search_params,
					success : function(response){
						if(response.code=='success'){
								var url = "<?php echo get_permalink(); ?>?&profile=all-post";    						
								jQuery(location).attr('href',url);	
						}
						//jQuery('#update_message').html('<div class="alert alert-info alert-dismissable"><a class="panel-close close" data-dismiss="alert">x</a>'+response.msg +'.</div>');
						
					}
				});
	
	}
function add_day_field(){
	var main_opening_div =jQuery('#day-row1').html(); 
	jQuery('#day_field_div').append('<div class="clearfix"></div><div class=" row form-group" >'+main_opening_div+'</div>');

}
function  remove_post_image	(profile_image_id){
	jQuery('#'+profile_image_id).html('');
	jQuery('#feature_image_id').val(''); 
	jQuery('#post_image_edit').html('<button type="button" onclick="edit_post_image(\'post_image_div\');"  class="btn btn-xs green-haze">Add</button>');  

}
function  remove_event_image	(profile_image_id){
	jQuery('#'+profile_image_id).html('');
	jQuery('#event_image_id').val(''); 
	jQuery('#event_image_edit').html('<button type="button" onclick="event_post_image(\'event_image_div\');"  class="btn btn-xs green-haze">Add</button>');  

}
function  remove_deal_image	(profile_image_id){
	jQuery('#'+profile_image_id).html('');
	jQuery('#deal_image_id').val(''); 
	jQuery('#deal_image_edit').html('<button type="button" onclick="deal_post_image(\'deal_image_div\');"  class="btn btn-xs green-haze">Add</button>');  

}	
 function edit_post_image(profile_image_id){	
				var image_gallery_frame;

               // event.preventDefault();
                image_gallery_frame = wp.media.frames.downloadable_file = wp.media({
                    // Set the title of the modal.
                    title: "<?php _e( 'Set Feature Image ', 'ivdirectories' ); ?>",
                    button: {
                        text: "<?php _e( 'Set Feature Image', 'ivdirectories' ); ?>",
                    },
                    multiple: false,
                    displayUserSettings: true,
                });                
                image_gallery_frame.on( 'select', function() {
                    var selection = image_gallery_frame.state().get('selection');
                    selection.map( function( attachment ) {
                        attachment = attachment.toJSON();
                        if ( attachment.id ) {
							jQuery('#'+profile_image_id).html('<img  class="img-responsive"  src="'+attachment.sizes.thumbnail.url+'">');
							jQuery('#feature_image_id').val(attachment.id ); 
							jQuery('#post_image_edit').html('<button type="button" onclick="edit_post_image(\'post_image_div\');"  class="btn btn-xs green-haze">Edit</button> &nbsp;<button type="button" onclick="remove_post_image(\'post_image_div\');"  class="btn btn-xs green-haze">Remove</button>');  
						   
						}
					});
                   
                });               
				image_gallery_frame.open(); 
				
	}
function event_post_image(profile_image_id){	
				var image_gallery_frame;

               // event.preventDefault();
                image_gallery_frame = wp.media.frames.downloadable_file = wp.media({
                    // Set the title of the modal.
                    title: "<?php _e( 'Set Event Image ', 'ivdirectories' ); ?>",
                    button: {
                        text: "<?php _e( 'Set Event Image', 'ivdirectories' ); ?>",
                    },
                    multiple: false,
                    displayUserSettings: true,
                });                
                image_gallery_frame.on( 'select', function() {
                    var selection = image_gallery_frame.state().get('selection');
                    selection.map( function( attachment ) {
                        attachment = attachment.toJSON();
                        if ( attachment.id ) {
							jQuery('#'+profile_image_id).html('<img  class="img-responsive"  src="'+attachment.sizes.thumbnail.url+'">');
							jQuery('#event_image_id').val(attachment.id ); 
							jQuery('#event_image_edit').html('<button type="button" onclick="event_post_image(\'event_image_div\');"  class="btn btn-xs green-haze">Edit</button> &nbsp;<button type="button" onclick="remove_event_image(\'event_image_div\');"  class="btn btn-xs green-haze">Remove</button>');  
						   
						}
					});
                   
                });               
				image_gallery_frame.open(); 
				
	}
function deal_post_image(profile_image_id){	
				var image_gallery_frame;

               // event.preventDefault();
                image_gallery_frame = wp.media.frames.downloadable_file = wp.media({
                    // Set the title of the modal.
                    title: "<?php _e( 'Set Deal/Coupon Image ', 'ivdirectories' ); ?>",
                    button: {
                        text: "<?php _e( 'Set Deal/Coupon Image', 'ivdirectories' ); ?>",
                    },
                    multiple: false,
                    displayUserSettings: true,
                });                
                image_gallery_frame.on( 'select', function() {
                    var selection = image_gallery_frame.state().get('selection');
                    selection.map( function( attachment ) {
                        attachment = attachment.toJSON();
                        if ( attachment.id ) {
							jQuery('#'+profile_image_id).html('<img  class="img-responsive"  src="'+attachment.sizes.thumbnail.url+'">');
							jQuery('#deal_image_id').val(attachment.id ); 
							jQuery('#deal_image_edit').html('<button type="button" onclick="deal_post_image(\'deal_image_div\');"  class="btn btn-xs green-haze">Edit</button> &nbsp;<button type="button" onclick="remove_deal_image(\'deal_image_div\');"  class="btn btn-xs green-haze">Remove</button>');  
						   
						}
					});
                   
                });               
				image_gallery_frame.open(); 
				
	}			
 function edit_gallery_image(profile_image_id){
				
				var image_gallery_frame;
				var hidden_field_image_ids = jQuery('#gallery_image_ids').val();
               // event.preventDefault();
                image_gallery_frame = wp.media.frames.downloadable_file = wp.media({
                    // Set the title of the modal.
                    title: "<?php _e( 'Gallery Images ', 'ivdirectories' ); ?>",
                    button: {
                        text: "<?php _e( 'Gallery Images', 'ivdirectories' ); ?>",
                    },
                    multiple: true,
                    displayUserSettings: true,
                });                
                image_gallery_frame.on( 'select', function() {
                    var selection = image_gallery_frame.state().get('selection');
                    selection.map( function( attachment ) {
                        attachment = attachment.toJSON();
                        console.log(attachment);
                        if ( attachment.id ) {
							jQuery('#'+profile_image_id).append('<div id="gallery_image_div'+attachment.id+'" class="col-md-3"><img  class="img-responsive"  src="'+attachment.sizes.thumbnail.url+'"><button type="button" onclick="remove_gallery_image(\'gallery_image_div'+attachment.id+'\', '+attachment.id+');"  class="btn btn-xs btn-danger">Remove</button> </div>');
							
							hidden_field_image_ids=hidden_field_image_ids+','+attachment.id ;
							jQuery('#gallery_image_ids').val(hidden_field_image_ids); 
							
							//jQuery('#gallery_image_edit').html('');  
						   
						}
					});
                   
                });               
				image_gallery_frame.open(); 

 }			

function  remove_gallery_image(img_remove_div,rid){	
	var hidden_field_image_ids = jQuery('#gallery_image_ids').val();	
	hidden_field_image_ids =hidden_field_image_ids.replace(rid, '');	
	jQuery('#'+img_remove_div).remove();
	jQuery('#gallery_image_ids').val(hidden_field_image_ids); 
	//jQuery('#gallery_gallery_edit').html('');  

}	
function remove_old_day(div_id){
	jQuery('#old_days'+div_id).remove();
}
function award_delete(id_delete){
	
	jQuery('#award_delete_'+id_delete).remove();
	
}
function add_award_field(){
	var main_award_div =jQuery('#awardmain').html(); 
	jQuery('#awards').append('<div class="clearfix"></div><hr>'+main_award_div+'');
}
function award_post_image(awardthis){	
				var image_gallery_frame;
               // event.preventDefault();
                image_gallery_frame = wp.media.frames.downloadable_file = wp.media({
                    // Set the title of the modal.
                    title: "<?php _e( 'Set award Image ', 'ivdirectories' ); ?>",
                    button: {
                        text: "<?php _e( 'Set award Image', 'ivdirectories' ); ?>",
                    },
                    multiple: false,
                    displayUserSettings: true,
                });                
                image_gallery_frame.on( 'select', function() {
                    var selection = image_gallery_frame.state().get('selection');
                    selection.map( function( attachment ) {
                        attachment = attachment.toJSON();
                        if ( attachment.id ) {		
													
							jQuery(awardthis).html('<img  class="img-responsive"  src="'+attachment.sizes.thumbnail.url+'"><input type="hidden" name="award_image_id[]" id="award_image_id[]" value="'+attachment.id+'">');
							
							
						}
					});                   
                });               
				image_gallery_frame.open(); 				
	}	

</script>	  
