Commit 8ba4c02c by felix

每日一更

parent f70c78cc
......@@ -36,14 +36,22 @@ class House {
'city_id' => $_POST['baseCity'],
'district_id' => $_POST['baseAreaId'],
'plate_id' => $_POST["basePlateId"],
"room_id" => $_POST["baseRoom"],
'room_id' => $_POST['baseRoom'],
"location" => $_POST["location"],
"property_money" => $_POST["property_money"],
'community_name' => $_POST["community_name"],
);
$wpdb->query("START TRANSACTION");
if(isset($_POST['houseId'])){
$result = House::data_update($_POST['houseId'],$insert_tospur_house_array);
$wpdb->query("COMMIT");
if($result != 203){
$wpdb->query("ROLLBACK");
print_r($wpdb->last_error);;
echo "新房房源修改失败";
}else{
$wpdb->query("COMMIT");
echo "新房房源修改成功";
}
}else{
$result = House::data_insert($insert_tospur_house_array);
if($result != 200){
......@@ -63,10 +71,12 @@ class House {
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(1);
Timber::render("newhouse.html",$context);
}
......@@ -74,6 +84,7 @@ class House {
global $wpdb;
$data = $_POST["data"];
$wpdb->update(Config::TOSPUR_HOUSE_TABLE,$insert_tospur_house_array,array("id" => $houseId));
$result = 203;
$exist_ids = array();
if(isset($_POST['exists'])){
foreach($_POST['exists'] as $id => $item){
......@@ -112,12 +123,20 @@ class House {
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
InsertDao::addRecommend($houseId,$data);
$res = InsertDao::addRecommend($houseId,$data);
if($res == 504){
$result = $res;
}
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
InsertDao::addRecConsultant($houseId,$data);
$res = InsertDao::addRecConsultant($houseId,$data);
if($res == 505){
$result = $res;
}
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
public static function data_insert($insert_tospur_house_array){
......@@ -151,4 +170,12 @@ class House {
}
return 200;
}
public static function getCurrentRole(){
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$roles = $current_user->roles;
return $roles[0];
}
}
\ No newline at end of file
......@@ -57,26 +57,28 @@ class newHouseList extends WP_List_Table
function get_columns()
{
$columns = array(
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
'id' =>'ID',
'name' => '楼盘名',
'address' => '地址',
'average_price' => '单价',
'developer' => '开发商',
'check_in_time' => '入住时间',
'room_id' => '建筑类型',
'property_age' => '产权年限',
'decoration' => '装修状况',
'covered_area' => '建筑面积',
'volume_rate' => '容积率',
'status' => '状态',
'greening_rate' => '绿化率',
'households' => '规划户数',
'parking_spaces' => '车位数',
'property_management' => '物业公司',
'property_money' => '物业费'
);
if( current_user_can('administrator') ) {
$columns = array(
'cb' => '<input type="checkbox" />'
);
}
$columns['id']= 'ID';
$columns['name']= '楼盘名';
$columns['address']= '地址';
$columns['average_price']= '单价';
$columns['developer']= '开发商';
$columns['check_in_time']= '入住时间';
$columns['room_id']= '建筑类型';
$columns['property_age']= '产权年限';
$columns['decoration']= '装修状况';
$columns['covered_area']= '建筑面积';
$columns['volume_rate']= '容积率';
$columns['greening_rate']= '绿化率';
$columns['households']= '规划户数';
$columns['parking_spaces']= '车位数';
$columns['property_management']= '物业公司';
$columns['property_money']= '物业费';
$columns['status']= '状态';
return $columns;
}
......@@ -260,154 +262,30 @@ add_action( 'wp_ajax_nopriv_searchListCity', 'SearchDao::ajax_searchListCity');
function newHouseList()
{
$newHouseList = new newHouseList();
$newHouseList->prepare_items();
?>
<div class="wrap">
<h2>新房列表</h2>
<form id="scores-filter" method="POST">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>"/>
<select id="listCity" name="listCity">
<option value="0"> 城市</option>
</select>
<select id="listDistrict" name="listDistrict">
<option value="0">区域</option>
</select>
<select id="listPlate" name="listPlate">
<option value="0">板块</option>
</select>
<select id="totalPrice" name="totalPrice">
<option value ="">价格</option>
</select>
<select id="buildProperty" name="buildProperty">
<option value="0">房型</option>
</select>
<select id="room" name="room">
<option value="0">类型</option>
</select>
<select id="acreage" name="acreage">
<option value ="">面积</option>
</select>
<select name="status" name="status">
<option value="-1">状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">下架</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" name="searchText">
<input type="submit" id="submit" class="button action" value="搜索">
<!-- Now we can render the completed list table -->
<?php $newHouseList->display() ?>
</form>
</div>
<script>
(function ($) {
$(document).ready(function(){
//获取城市信息AJAX
var listCity = $("#listCity");
var room = $("#room");
var buildProperty =$("#buildProperty");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity",
success:function(data){
addOption(data,listCity)
}
})
//获取类型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchRoom",
success:function(data){
addOption(data,room)
}
})
//获取房型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchBuildProperty",
success:function(data){
addOption(data,buildProperty)
}
})
$("#listCity").change(function(){
var listCityId = $("#listCity").val();
var district =$("#listDistrict");
var acreage =$("#acreage");
var totalPrice = $("#totalPrice");
$('#listDistrict').find('option:not(:first-child)').remove();
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId,
success:function(json){
addOption(json,district);
}
});
//面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#acreage").append(Option);
}
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#totalPrice").append(Option);
}
}
});
})
$("#listDistrict").change(function(){
var listCityId = $("#listCity").val();
var listDistrict = $("#listDistrict").val();
var listPlate = $("#listPlate");
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId+"&districtId="+listDistrict,
success:function(json){
addOption(json,listPlate);
}
});
})
$contest = array();
$contest['page'] = $_REQUEST['page'];
if(isset($_POST['hasSearch'])){
$bpRes = SearchDao::searchBuildProperty();
foreach($bpRes as $val){
if($val->id == $_POST['buildProperty']){
$contest['buildProperty'] = $val->value;
$contest['buildPropertyId'] = $val->id;
}
}
$contest['options']= SearchDao::searchForCDP($_POST['listCity'],$_POST['listDistrict'],$_POST['listPlate']);
$contest['totalPrice'] = $_POST['totalPrice'];
$contest['acreage'] = $_POST['acreage'];
$contest['characteristic'] = $_POST['characteristic'];
$contest['status'] = $_POST['status'];
$contest['hasSearch'] = $_POST['hasSearch'];
function addOption(json,select){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
});
})(jQuery);
</script>
<?php
}
Timber::render("newHouseList.html",$contest);
}
?>
\ No newline at end of file
function addNewHouseTable(){
$newHouseList = new newHouseList();
$newHouseList->prepare_items();
$newHouseList->display();
}
?>
......@@ -35,6 +35,9 @@ class RentHouse{
'periphery' => $_POST['periphery'],
'status' =>$_POST['status'],
'creattime' => date("Y-m-d H:i:s"),
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
'house_type' => 2
);
if($type==3){
......@@ -69,10 +72,12 @@ class RentHouse{
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
Timber::render("rentHouse.html",$context);
}
......@@ -84,7 +89,7 @@ class RentHouse{
$uploadedfile = $_FILES['files'];
//房源与类型以及面积信息
$data = $_POST["data"];
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE flat="' .$_POST['flat'] . '" and suite="' . $_POST["suite"] . '" and house_type=2', OBJECT);
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=2', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
......@@ -135,5 +140,12 @@ class RentHouse{
InsertDao::addHouseTag($_POST['mark'],$houseId);
return $result;
}
public static function getCurrentRole(){
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$roles = $current_user->roles;
return $roles[0];
}
}
......@@ -34,6 +34,9 @@ class SecHandHouse{
'periphery' => $_POST['periphery'],
'status' =>$_POST['status'],
'creattime' => date("Y-m-d H:i:s"),
'owner_name'=>$_POST['owner_name'],
'owner_phone'=>$_POST['owner_phone'],
"location" => $_POST["location"],
'house_type' => 1
);
if($type==2){
......@@ -53,7 +56,7 @@ class SecHandHouse{
$result = SecHandHouse::secHouseData_insert($insert_tospur_house_array);
if ($result != 200) {
$wpdb->query("ROLLBACK");
print_r($wpdb->last_error);
print_r($wpdb->last_error);;
echo "二手房房源新增失败";
} else {
$wpdb->query("COMMIT");
......@@ -68,10 +71,12 @@ class SecHandHouse{
$context["plate"] = SearchDao::searchCity($context['result']->city_id,$context['result']->district_id);
$context["mark"] = SearchDao::searchHouseTag($_GET['id']);
}
$context['role'] = SecHandHouse::getCurrentRole();
$context["city"] = SearchDao::searchCity();
$context["buildProperty"] = SearchDao::searchBuildProperty();
$context["room"] = SearchDao::searchRoom();
$context["photoType"] = SearchDao::searchPhotoType();
$context["status"] = searchDao::searchStatusType(2);
Timber::render("secHandHouse.html",$context);
}
......@@ -84,7 +89,7 @@ class SecHandHouse{
//房源与类型以及面积信息
$data = $_POST["data"];
//获取新房信息,存入tospur_house表
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE flat="' .$_POST['flat'] . '" and suite="' . $_POST["suite"] . '" and house_type=1', OBJECT);
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=1', OBJECT);
if(!$res){
$houseId = InsertDao::insert_tospur_house($params);
......@@ -137,5 +142,13 @@ class SecHandHouse{
return $result;
}
public static function getCurrentRole(){
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
$roles = $current_user->roles;
return $roles[0];
}
}
<div class="wrap">
<h2>新房列表</h2>
<form id="scores-filter" method="POST">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="{{page}}"/>
<input type="hidden" name="hasSearch" value="1"/>
<select id="listCity" name="listCity">
{% if hasSearch and options.cityName %}
<option value="{{options.cityId}}"> {{options.cityName}}</option>
{% else %}
<option value="0"> 城市</option>
{% endif %}
</select>
<select id="listDistrict" name="listDistrict">
{% if hasSearch and options.districtName %}
<option value="{{options.districtId}}"> {{options.districtName}}</option>
{% else %}
<option value="0">区域</option>
{% endif %}
</select>
<select id="listPlate" name="listPlate">
{% if hasSearch and options.districtName and options.plateName %}
<option value="{{options.plateId}}">{{options.plateName}}</option>
{% else %}
<option value="0">板块</option>
{% endif %}
</select>
<select id="totalPrice" name="totalPrice">
<option value ="">价格</option>
</select>
<select id="buildProperty" name="buildProperty">
{% if hasSearch and buildProperty %}
<option value="{{buildPropertyId}}"> {{buildProperty}}</option>
{% else %}
<option value="0"> 房型</option>
{% endif %}
</select>
<select id="acreage" name="acreage">
<option value ="">面积</option>
</select>
<select name="status" name="status">
<option value="-1">状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">下架</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" name="searchText">
<input type="submit" id="submit" class="button action" value="搜索">
<!-- Now we can render the completed list table -->
{{function("addNewHouseTable")}}
</form>
</div>
<script>
(function ($) {
$(document).ready(function(){
//获取城市信息AJAX
var listCity = $("#listCity");
var room = $("#room");
var buildProperty =$("#buildProperty");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity",
success:function(data){
addOption(data,listCity)
}
})
//获取类型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchRoom",
success:function(data){
addOption(data,room)
}
})
//获取房型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchBuildProperty",
success:function(data){
addOption(data,buildProperty)
}
})
$("#listCity").change(function(){
var listCityId = $("#listCity").val();
var district =$("#listDistrict");
var acreage =$("#acreage");
var totalPrice = $("#totalPrice");
$('#listDistrict').find('option:not(:first-child)').remove();
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId,
success:function(json){
addOption(json,district);
}
});
//面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#acreage").append(Option);
}
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#totalPrice").append(Option);
}
}
});
})
$("#listDistrict").change(function(){
var listCityId = $("#listCity").val();
var listDistrict = $("#listDistrict").val();
var listPlate = $("#listPlate");
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId+"&districtId="+listDistrict,
success:function(json){
addOption(json,listPlate);
}
});
})
function addOption(json,select){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
});
})(jQuery);
</script>
\ No newline at end of file
......@@ -58,6 +58,10 @@
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="regular-text code"></td>
</tr>
<tr>
<th><label for="mainHouse">主力户型</label></th>
<td>
<div id="preview">
......@@ -230,6 +234,18 @@
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
{% for item in status %}
<option value={{item.status_id}}>{{item.status_name}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
<input type="text" name="type" value="1" hidden="hidden">
......
......@@ -18,6 +18,16 @@
<th><label for="mark">标签:</label></th>
<td> <input name="mark" id="mark" type="text" value="{{mark}}" class="regular-text code"></td>
</tr>
{% if not houseId %}
<tr>
<th><label for="owner_name">业主姓名</label></th>
<td> <input name="owner_name" id="owner_name" type="text" value="" class="regular-text code"></td>
</tr>
<tr>
<th><label for="owner_phone">业主电话</label></th>
<td> <input name="owner_phone" id="owner_phone" type="text" value="" class="regular-text code"></td>
</tr>
{% endif %}
<tr>
<th><label for="rent">租金</label></th>
<td> <input name="rent" id="rent" type="text" value="{{result.rent}}" class="regular-text code"></td>
......@@ -102,6 +112,10 @@
</select>
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="regular-text code"></td>
</tr>
</tbody>
</table>
<h2 class="title">位置及周边</h2>
......@@ -182,17 +196,18 @@
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
<option value="-1"> 状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">下架</option>
{% for item in status %}
<option value={{item.status_id}}>{{item.status_name}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
<input type="text" name="type" value="3" hidden="hidden">
......
<div class="wrap">
<h2>租房房列表</h2>
<form id="scores-filter" method="POST">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="{{page}}"/>
<input type="hidden" name="hasSearch" value="1"/>
<select id="listCity" name="listCity">
{% if hasSearch and options.cityName %}
<option value="{{options.cityId}}"> {{options.cityName}}</option>
{% else %}
<option value="0"> 城市</option>
{% endif %}
</select>
<select id="listDistrict" name="listDistrict">
{% if hasSearch and options.districtName %}
<option value="{{options.districtId}}"> {{options.districtName}}</option>
{% else %}
<option value="0">区域</option>
{% endif %}
</select>
<select id="listPlate" name="listPlate">
{% if hasSearch and options.districtName and options.plateName %}
<option value="{{options.plateId}}">{{options.plateName}}</option>
{% else %}
<option value="0">板块</option>
{% endif %}
</select>
<select id="totalPrice" name="totalPrice">
<option value ="">价格</option>
</select>
<select id="buildProperty" name="buildProperty">
{% if hasSearch and buildProperty %}
<option value="{{buildPropertyId}}"> {{buildProperty}}</option>
{% else %}
<option value="0"> 房型</option>
{% endif %}
</select>
<select id="acreage" name="acreage">
<option value ="">面积</option>
</select>
<select name="status" name="status">
<option value="-1">状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">自售</option>
<option value="3">他售</option>
<option value="4">无效</option>
<option value="5">重激活</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" name="searchText">
<input type="submit" id="submit" class="button action" value="搜索">
<!-- Now we can render the completed list table -->
{{function("addRentTable")}}
</form>
</div>
<script>
(function ($) {
$(document).ready(function(){
//获取城市信息AJAX
var listCity = $("#listCity");
var room = $("#room");
var buildProperty =$("#buildProperty");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity",
success:function(data){
addOption(data,listCity)
}
})
//获取类型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchRoom",
success:function(data){
addOption(data,room)
}
})
//获取房型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchBuildProperty",
success:function(data){
addOption(data,buildProperty)
}
})
$("#listCity").change(function(){
var listCityId = $("#listCity").val();
var district =$("#listDistrict");
var acreage =$("#acreage");
var totalPrice = $("#totalPrice");
$('#listDistrict').find('option:not(:first-child)').remove();
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId,
success:function(json){
addOption(json,district);
}
});
//面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#acreage").append(Option);
}
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#totalPrice").append(Option);
}
}
});
})
$("#listDistrict").change(function(){
var listCityId = $("#listCity").val();
var listDistrict = $("#listDistrict").val();
var listPlate = $("#listPlate");
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId+"&districtId="+listDistrict,
success:function(json){
addOption(json,listPlate);
}
});
})
function addOption(json,select){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
});
})(jQuery);
</script>
......@@ -18,6 +18,16 @@
<th><label for="housename">标签:</label></th>
<td> <input name="mark" id="mark" type="text" value="{{mark}}" class="regular-text code"></td>
</tr>
{% if not houseId %}
<tr>
<th><label for="owner_name">业主姓名</label></th>
<td> <input name="owner_name" id="owner_name" type="text" value="" class="regular-text code"></td>
</tr>
<tr>
<th><label for="owner_phone">业主电话</label></th>
<td> <input name="owner_phone" id="owner_phone" type="text" value="" class="regular-text code"></td>
</tr>
{% endif %}
<tr>
<th><label for="total_price">售价</label></th>
<td> <input name="total_price" id="total_price" type="text" value="{{result.total_price}}" class="regular-text code"></td>
......@@ -101,6 +111,11 @@
</select>
</td>
</tr>
<tr>
<th><label for="location">地域坐标</label></th>
<td> <input name="location" id="location" type="text" value="{{result.location}}" class="regular-text code"></td>
</tr>
</tbody>
</table>
<h2 class="title">位置及周边</h2>
......@@ -189,24 +204,24 @@
</button>
</td>
</tr>
{% if role == 'administrator' %}
<tr>
<th><label for="from">状态</label></th>
<td>
<select id="status" name="status">
<option value="-1"> 状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">下架</option>
{% for item in status %}
<option value={{item.status_id}}>{{item.status_name}}</option>
{% endfor %}
</select>
</td>
</tr>
{% endif %}
</tbody>
</table>
<input type="text" name="type" value="2" hidden="hidden">
{% if houseId %}
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
<input type="submit" id="submit" class="button action">
</form>
......
<div class="wrap">
<h2>二手房列表</h2>
<form id="scores-filter" method="POST">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="{{page}}"/>
<input type="hidden" name="hasSearch" value="1"/>
<select id="listCity" name="listCity">
{% if hasSearch and options.cityName %}
<option value="{{options.cityId}}"> {{options.cityName}}</option>
{% else %}
<option value="0"> 城市</option>
{% endif %}
</select>
<select id="listDistrict" name="listDistrict">
{% if hasSearch and options.districtName %}
<option value="{{options.districtId}}"> {{options.districtName}}</option>
{% else %}
<option value="0">区域</option>
{% endif %}
</select>
<select id="listPlate" name="listPlate">
{% if hasSearch and options.districtName and options.plateName %}
<option value="{{options.plateId}}">{{options.plateName}}</option>
{% else %}
<option value="0">板块</option>
{% endif %}
</select>
<select id="totalPrice" name="totalPrice">
<option value ="">价格</option>
</select>
<select id="buildProperty" name="buildProperty">
{% if hasSearch and buildProperty %}
<option value="{{buildPropertyId}}"> {{buildProperty}}</option>
{% else %}
<option value="0"> 房型</option>
{% endif %}
</select>
<select id="acreage" name="acreage">
<option value ="">面积</option>
</select>
<select id="characteristic" name="characteristic">
<option value ="">特色</option>
<option value ="">满5</option>
<option value ="">唯一住房</option>
</select>
<select name="status" name="status">
<option value="-1">状态</option>
<option value="0">未审核</option>
<option value="1">审核</option>
<option value="2">自售</option>
<option value="3">他售</option>
<option value="4">无效</option>
<option value="5">重激活</option>
</select>
<input type="text" placeholder="请出入楼盘名/地段名搜索" name="searchText">
<input type="submit" id="submit" class="button action" value="搜索">
<!-- Now we can render the completed list table -->
{{function("addSecTable")}}
</form>
</div>
<script>
(function ($) {
$(document).ready(function(){
//获取城市信息AJAX
var listCity = $("#listCity");
var room = $("#room");
var buildProperty =$("#buildProperty");
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity",
success:function(data){
addOption(data,listCity)
}
})
//获取类型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchRoom",
success:function(data){
addOption(data,room)
}
})
//获取房型信息AJAX
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchBuildProperty",
success:function(data){
addOption(data,buildProperty)
}
})
$("#listCity").change(function(){
var listCityId = $("#listCity").val();
var district =$("#listDistrict");
var acreage =$("#acreage");
var totalPrice = $("#totalPrice");
$('#listDistrict').find('option:not(:first-child)').remove();
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId,
success:function(json){
addOption(json,district);
}
});
//面积
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchArea&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#acreage").append(Option);
}
}
});
//城市联动房子价格
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=searchUnitPriceRange&cityId="+listCityId,
success:function(json){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": value}).append(value);
$("#totalPrice").append(Option);
}
}
});
})
$("#listDistrict").change(function(){
var listCityId = $("#listCity").val();
var listDistrict = $("#listDistrict").val();
var listPlate = $("#listPlate");
$('#listPlate').find('option:not(:first-child)').remove();
$.ajax({
type: "GET",
url: "/tospur/wp-admin/admin-ajax.php",
data: "action=serachCity&cityId="+listCityId+"&districtId="+listDistrict,
success:function(json){
addOption(json,listPlate);
}
});
})
function addOption(json,select){
for(var i = 0; i <=json.length-1; i++){
var id = json[i]["id"];
var value = json[i]["value"];
var Option = $("<option>").attr({"value": id}).append(value);
select.append(Option);
}
}
});
})(jQuery);
</script>
......@@ -148,107 +148,110 @@ class SearchDao
}
}
public static function ajax_searchHouse()
{
$house_result = SearchDao::searchHouse(
array(
'cityId' => $_POST['cityId'],
'districtId' => $_POST['districtId'],
'plateId' => $_POST['plateId'],
'buildPropertyId' => $_POST['buildPropertyId'],
'roomId' => $_POST['roomId'],
'acreage' => $_POST['acreage'],
'totalPrice' => $_POST['totalPrice'],
'rentalPrice' => $_POST['rentalPrice'],
'searchText' => $_POST['searchText'],
'houseType' => $_POST['houseType'],
'index' => $_POST['index']
)
);
$array = SearchDao::get_house_image_and_tags($house_result);
wp_send_json($array);
}
public static function searchHouse($array)
{
global $wpdb;
$params = array();
$buildpropertySql = null;
$orderbySql = null;
if ($array['houseType'] == 0) {
$buildpropertySql = " left join (select buildproperty_id,house_area,image_id,house_id as bph_id from a_district_area) ada on th.id = ada.bph_id".
" left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql = " group by ada.bph_id order by th.creattime DESC";
}else if ($array['houseType'] == 1||$array['houseType'] == 2) {
$buildpropertySql = " left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on th.buildproperty_id = dbp.bp_value";
$orderbySql = " order by th.creattime DESC";
}
$sql = "select * from tospur_house th".
$buildpropertySql.
" left join dic_city dc on th.plate_id = dc.plateId".
" left join (select id as rid,value as r_value,literal from dic_room) dr on th.room_id = dr.r_value".
" where 1=1 and status = 1";
if ($array['cityId'] > -1) {
$params[] = $array['cityId'];
$sql = $sql . " and cityId=%d";
}
if ($array['districtId'] > -1) {
$params[] = $array['districtId'];
$sql = $sql . " and districtId=%d";
}
if ($array['plateId'] > -1) {
$params[] = $array['plateId'];
$sql = $sql . " and plateId=%d";
}
if ($array['buildPropertyId'] > -1) {
$params[] = $array['buildPropertyId'];
$sql = $sql . " and buildproperty_id=%d";
}
if ($array['roomId'] > -1) {
$params[] = $array['roomId'];
$sql = $sql . " and room_id=%d";
}
if ($array['acreage'] > -1) {
$areaArray = explode("-", $array['acreage']);
$params[] = $areaArray[0];
$params[] = $areaArray[1];
$sql = $sql . " and covered_area between %d and %d";
}
if ($array['totalPrice'] > -1) {
$priceArray = explode("-", $array['totalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and total_price between %d and %d";
}
if ($array['rentalPrice'] > -1) {
$priceArray = explode("-", $array['rentalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and rent between %d and %d";
}
if ($array['searchText'] != null) {
$params[] = "%" . $array['searchText'] . "%";
$sql = $sql . " and name like %s";
}
if ($array['houseType'] > -1) {
$params[] = $array['houseType'];
$sql = $sql . " and house_type = %d";
}
if ($array['userType'] > -1 && $array['userId'] > -1) {
$params[] = $array['userType'];
$params[] = $array['userId'];
$sql = $sql . " and id in (select house_id from a_house_user where user_type = %d and user_id = %d)";
}
$sql = $sql . $orderbySql;
if ($array['index'] > -1) {
$params[] = $array['index'];
$sql = $sql . " limit %d,10";
}
$result = $wpdb->get_results($wpdb->prepare($sql, $params));
return $result;
}
public static function ajax_searchHouse()
{
$house_result = SearchDao::searchHouse(
array(
'cityId' => $_POST['cityId'],
'districtId' => $_POST['districtId'],
'plateId' => $_POST['plateId'],
'buildPropertyId' => $_POST['buildPropertyId'],
'roomId' => $_POST['roomId'],
'acreage' => $_POST['acreage'],
'totalPrice' => $_POST['totalPrice'],
'rentalPrice' => $_POST['rentalPrice'],
'searchText' => $_POST['searchText'],
'houseType' => $_POST['houseType'],
'userType' => $_POST['userType'],
'userId' => $_POST['userId'],
'index' => $_POST['index']
)
);
$array = SearchDao::get_house_image_and_tags($house_result);
wp_send_json($array);
}
public static function searchHouse($array)
{
global $wpdb;
$params = array();
$buildpropertySql = null;
$orderbySql = null;
if ($array['houseType'] == 0) {
$buildpropertySql = " left join (select buildproperty_id,house_area,image_id,house_id as bph_id from a_district_area) ada on th.id = ada.bph_id".
" left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql = " group by ada.bph_id order by th.creattime DESC";
}else if ($array['houseType'] == 1||$array['houseType'] == 2) {
$buildpropertySql = " left join (select value as bp_value,literal as bp_literal from dic_buildproperty) dbp on th.buildproperty_id = dbp.bp_value";
$orderbySql = " order by th.creattime DESC";
}
$sql = "select * from tospur_house th".
$buildpropertySql.
" left join dic_city dc on th.plate_id = dc.plateId".
" left join (select id as rid,value as r_value,literal from dic_room) dr on th.room_id = dr.r_value".
" where 1=1";
if ($array['cityId'] > -1) {
$params[] = $array['cityId'];
$sql = $sql . " and cityId=%d";
}
if ($array['districtId'] > -1) {
$params[] = $array['districtId'];
$sql = $sql . " and districtId=%d";
}
if ($array['plateId'] > -1) {
$params[] = $array['plateId'];
$sql = $sql . " and plateId=%d";
}
if ($array['buildPropertyId'] > -1) {
$params[] = $array['buildPropertyId'];
$sql = $sql . " and buildproperty_id=%d";
}
if ($array['roomId'] > -1) {
$params[] = $array['roomId'];
$sql = $sql . " and room_id=%d";
}
if ($array['acreage'] > -1) {
$areaArray = explode("-", $array['acreage']);
$params[] = $areaArray[0];
$params[] = $areaArray[1];
$sql = $sql . " and covered_area between %d and %d";
}
if ($array['totalPrice'] > -1) {
$priceArray = explode("-", $array['totalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and total_price between %d and %d";
}
if ($array['rentalPrice'] > -1) {
$priceArray = explode("-", $array['rentalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and rent between %d and %d";
}
if ($array['houseType'] > -1) {
$params[] = $array['houseType'];
$sql = $sql . " and house_type = %d";
}
if ($array['userType'] > -1 && $array['userId'] > -1) {
$params[] = $array['userType'];
$params[] = $array['userId'];
$sql = $sql . " and id in (select house_id from a_house_user where user_type = %d and user_id = %d)";
}
if ($array['searchText'] != null) {
$params[] = '%'.$array['searchText'].'%';
$params[] = '%'.$array['searchText'].'%';
$sql = $sql . " and (name like '%s' or address like '%s')";
}
$sql = $sql . $orderbySql;
if ($array['index'] > -1) {
$params[] = $array['index'];
$sql = $sql . " limit %d,10";
}
$result = $wpdb->get_results($wpdb->prepare($sql, $params));
return $result;
}
public static function ajax_searchPhotoType()
{
......@@ -439,5 +442,37 @@ class SearchDao
}
return implode(",",$tags);
}
public static function searchStatusType($statusType){
global $wpdb;
$sql="select status_type,status_id,status_name from tospur_status where status_type = %d";
$results = $wpdb->get_results($wpdb->prepare($sql,$statusType));
return $results;
}
public static function searchForCDP($cityId=null,$districtId=null,$plateId=null){
global $wpdb;
$selectName = "";
$where = " where 1=1 ";
$params = array();
if($cityId != 0){
$where .= " and cityId = %d";
$selectName = "cityId,cityName";
$params[] = $cityId;
}
if($districtId != 0){
$where .= " and districtId = %d";
$selectName = "cityId,cityName,districtId,districtName";
$params[] = $districtId;
}
if($plateId != 0){
$where .= " and plateId = %d";
$selectName = "cityId,cityName,districtId,districtName,plateId,plateName";
$params[] = $plateId;
}
$result = $wpdb->get_row($wpdb->prepare('select ' . $selectName . ' from ' . Config::DIC_CITY_TABLE . $where,$params));
return $result;
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ add_action('init', 'tospur_init');
function tospur_init()
{
require_once(PLUGIN_DIR . 'Config.php');
require_once(PLUGIN_DIR . 'Tools/TCSync.php');
require_once(PLUGIN_DIR . 'Tools/Image.php');
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
......@@ -131,12 +132,12 @@ function update_consultant()
function reset_menu()
{
add_menu_page("sync", "同步数据", "manage_options", "1", "do_sync");
add_menu_page('nesHouseList','新房列表', 'activate_plugins', 'newHouseList', 'newHouseList', 'dashicons-menu', 6);
add_submenu_page('newHouseList', 'newHouse_title', '添加新房', 'activate_plugins', 'newHouse', 'House::init_view');
add_menu_page('secHandHouseList','二手房列表', 'activate_plugins', 'secHandHouseList', 'secHandHouseList', 'dashicons-menu', 7);
add_submenu_page('secHandHouseList', 'newHouse_title', '添加二手房', 'activate_plugins', 'secHandHouse', 'SecHandHouse::secHandHouse_html');
add_menu_page('rentHouseList','租房列表', 'activate_plugins', 'rentHouseList', 'rentHouseList', 'dashicons-menu', 8);
add_submenu_page('rentHouseList', 'rentHouse_title', '添加租房', 'activate_plugins', 'rentHouse', 'RentHouse::rentHouse_html');
add_menu_page('nesHouseList','新房列表', 'moderate_comments', 'newHouseList', 'newHouseList', 'dashicons-menu', 6);
add_submenu_page('newHouseList', '添加新房', '添加新房', 'moderate_comments', 'newHouse', 'House::init_view');
add_menu_page('secHandHouseList','二手房列表', 'moderate_comments', 'secHandHouseList', 'secHandHouseList', 'dashicons-menu', 7);
add_submenu_page('secHandHouseList', '添加二手房', '添加二手房', 'moderate_comments', 'secHandHouse', 'SecHandHouse::secHandHouse_html');
add_menu_page('rentHouseList','租房列表', 'moderate_comments', 'rentHouseList', 'rentHouseList', 'dashicons-menu', 8);
add_submenu_page('rentHouseList', '添加租房', '添加租房', 'moderate_comments', 'rentHouse', 'RentHouse::rentHouse_html');
//移除更新信息
remove_action( 'admin_notices', 'update_nag', 3 );
global $menu;
......@@ -172,7 +173,7 @@ function reset_menu()
function do_sync()
{
//TCSync::user_sync();
//TCSync::organization_sync();
TCSync::user_sync();
TCSync::organization_sync();
TCSync::other_sync();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment