<?php
$b_gPath='/home1/bashro/public_html/itla.org.il/';
require_once($b_gPath.'wp-load.php');
require_once($b_gPath.'funcFile.php');
require_once($b_gPath.'myC/dbC.php');
require_once($b_gPath.'wp-content/themes/fortis7/dest-class.php');
require_once($b_gPath.'wp-content/themes/fortis7/bWeather-class.php');
$bashDB=new db();
$b_D= new bash_dest();
/*	var bashS_ID=decodeURIComponent(jQuery.urlParam('bash_id'));
	var bashS_PP=decodeURIComponent(jQuery.urlParam('bash_pp'));	
	var bashS_ID=decodeURIComponent(jQuery.urlParam('bash_sD'));
	var bashS_ID=decodeURIComponent(jQuery.urlParam('bash_fD'));	
	var bashS_ID=decodeURIComponent(jQuery.urlParam('bash_type'));	
	var bashS_ID=decodeURIComponent(jQuery.urlParam('bash_ob'));			
	if(dID!='null'){alert(dID);}
	
$doW_r=array(	
	'search_files'=>array(),
'search_img'=>array('f_type'=>array('gif','GIF','jpg','JPG','jpeg','JPEG','bmp','BMP','png','PNG')),
'search_pdf'=>array('f_type'=>array('pdf','PDF')),
'search_doc'=>array('f_type'=>array('doc','docx')),
'search_csv'=>array('f_type'=>array('csv','xls','xlsx')),
'search_ppt'=>array('f_type'=>array('ppt','pptx')),
'search_txt'=>array('f_type'=>array('txt')),
'search_event'=>array(''),
'search_questions'=>'',
'search_posts'=>'',
'search_users'=>'',
'search_other'=>''
);
*/
if( isset($_POST['doW']) ){
$back=array();
$tName=array();



	if ($_POST['doW']=='img'){
	}
//	elseif ($_POST['doW']=='file'){	}
//	elseif ($_POST['doW']=='guide'){	}
	elseif ($_POST['doW']=='get_O'){
//	echo $b_D->bs_getTheFiles($_POST['the_id'],is_user_logged_in(),$bs_type,1000,'','');
	echo json_encode($b_D->bs_getTheArrObj($_POST['the_id'],is_user_logged_in(),$_POST['the_type'],1000,$_POST['the_sDate'],$_POST['the_fDate']));

	}
	
	
	
	elseif ($_POST['doW']=='get_newO'){


	echo json_encode($b_D->bs_getTheArrNewObj(	$_POST['the_dataArr'],	is_user_logged_in(),1000));
	
	
//	echo json_encode($_POST['the_dataArr']['type']);

	}
	









	if ($_POST['doW']=='destComp'){
	$w=' WHERE post_title LIKE \''.$_POST['dVal'].'%\'  AND post_status=\'publish\' AND post_type=\'bash_destination\'';
	$resMe=$bashDB->select('*','wp_posts',$w,'');
		if($resMe!=false && $resMe!=''){		
			foreach($resMe as $i=>$a){
			$tName=$resMe[$i]['post_title'];
			$ii=$resMe[$i]['ID'];
			$back[$ii]=''.$tName.'';
			}
				echo json_encode($back);
		}
		else{
		echo json_encode(array(''=>'יעד לא נמצא'));
		}
	}
	else if ($_POST['doW']=='destComp_w'){
		$xtra_w_type=' AND meta_value>1';
		if($_POST['d_sType']=='goToDest' || $_POST['d_sType']=='goToDest2'){
		$xtra_w_type='';
		}
	$w=' WHERE post_title LIKE \''.$_POST['dVal'].'%\'  AND post_status=\'publish\' AND post_type=\'bash_destination\'';
	$jw=' wp_postmeta.post_id=wp_posts.ID AND meta_key=\'bash_dest_type\' '.$xtra_w_type.'';
	$jTBL2='';	$jOnWhere2='';
	$limit=' ORDER BY wp_posts.post_title';	
	$resMe=$bashDB->selectJ('*','wp_posts','wp_postmeta',$jw,$jTBL2,$jOnWhere2,$w,$limit);
		if($resMe!=false && $resMe!=''){		
			foreach($resMe as $i=>$a){
			$tName=$resMe[$i]['post_title'];
			$ii=$resMe[$i]['ID'];

			$d_w=' WHERE post_id='.$resMe[$i]['ID'].' AND (meta_key=\'bash_dest_father\' OR meta_key=\'bash_dest_en_name\' ) ';
			$d_resMe=$bashDB->select('*','wp_postmeta',$d_w,'');
			$tmpFatherID='';
			$tmpEN='';
			$tmpEN_father='';
			$dType=$resMe[$i]['meta_value'];
			$wUS='';
//build_w_city_side($dType,$dEN,$dFather_cust['bash_dest_en_name'][0],$wUS,$b_D->cleanName(get_the_title()));			
					foreach($d_resMe as $iii=>$vvv){
						if($d_resMe[$iii]['meta_key']=='bash_dest_en_name'){$tmpEN=$d_resMe[$iii]['meta_value'];}
						else if($d_resMe[$iii]['meta_key']=='bash_dest_father'){
						$tmpFatherID=$d_resMe[$iii]['meta_value'];
						if($tmpFatherID!=0 && $tmpFatherID!=''){
						$d_w2=' WHERE post_id='.$tmpFatherID.' AND (meta_key=\'bash_dest_father\' OR meta_key=\'bash_dest_en_name\' )';
						$d_resMe2=$bashDB->select('*','wp_postmeta',$d_w2,'');
							if($d_resMe2!=false){
								foreach($d_resMe2 as $it=>$vVal){
									if($d_resMe2[$it]['meta_key']=='bash_dest_en_name'){$tmpEN_father=$d_resMe2[$it]['meta_value'];}
									else if($d_resMe2[$it]['meta_key']=='bash_dest_father'){
										if($d_resMe2[$it]['meta_value']=='220'){
										$wUS='usa';
										}
									}
								}							
							}
						}
					}
				}
					
			$back[$ii]=$dType.','.$b_D->cleanName($tmpEN).','.$b_D->cleanName($tmpEN_father).','.$wUS.','.$b_D->cleanName($tName);
			//'destEN'=>,'.$b_D->cleanName($tName).' ('.$b_D->cleanName($tmpEN).', '.$b_D->cleanName($tmpEN_father).')';
			}
				echo json_encode($back);
		}
		else{
		echo json_encode(array(''=>'יעד לא נמצא'));
		}		
		
	}
	
	else if($_POST['doW']=='destComp_w_call'){
	$b_wather= new bash_weather();
	echo $b_wather->build_w_city_side($_POST['d_type'],$_POST['d_EN'],$_POST['d_fEN'],$_POST['d_us'],$_POST['d_he']);	
	}
	
}
?>

