Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tospur
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
felix
tospur
Commits
99b3aec2
Commit
99b3aec2
authored
Aug 19, 2015
by
felix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
每日一更
parent
8256ba90
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
2105 additions
and
144 deletions
+2105
-144
wp-content/plugins/tospur/Admin/House.php
+171
-45
wp-content/plugins/tospur/Admin/newHouseList.php
+2
-9
wp-content/plugins/tospur/Admin/rentHouse.php
+203
-0
wp-content/plugins/tospur/Admin/rentHouseList.php
+402
-0
wp-content/plugins/tospur/Admin/secHandHouse.php
+93
-31
wp-content/plugins/tospur/Admin/secHandHouseList.php
+403
-0
wp-content/plugins/tospur/Admin/views/newhouse.html
+81
-27
wp-content/plugins/tospur/Admin/views/rentHouse.html
+521
-0
wp-content/plugins/tospur/Admin/views/secHandHouse.html
+59
-31
wp-content/plugins/tospur/Config.php
+3
-0
wp-content/plugins/tospur/Dao/InsertDao.php
+3
-0
wp-content/plugins/tospur/Dao/SearchDao.php
+151
-0
wp-content/plugins/tospur/Tools/Core.php
+7
-0
wp-content/plugins/tospur/index.php
+3
-1
wp-content/themes/tospur/views/index.html
+3
-0
No files found.
wp-content/plugins/tospur/Admin/House.php
View file @
99b3aec2
<?php
require_once
(
PLUGIN_DIR
.
'Dao/SearchDao.php'
);
require_once
(
PLUGIN_DIR
.
'Tools/Image.php'
);
require_once
(
PLUGIN_DIR
.
'Tools/Core.php'
);
class
House
{
public
static
function
init_view
(){
wp_enqueue_script
(
'jquery-ui'
);
...
...
@@ -10,64 +11,185 @@ class House {
global
$wpdb
;
$type
=
$_POST
[
"type"
];
$context
=
array
();
$context
[
'siteUrl'
]
=
get_site_url
();
if
(
$type
==
1
){
$insert_tospur_house_array
=
array
(
'name'
=>
$_POST
[
'housename'
],
'average_price'
=>
$_POST
[
'average_price'
],
'latest_news'
=>
$_POST
[
'latest_news'
],
'address'
=>
$_POST
[
'address'
],
'traffic'
=>
$_POST
[
'traffic'
],
'periphery'
=>
$_POST
[
'periphery'
],
'developer'
=>
$_POST
[
'developers'
],
'check_in_time'
=>
$_POST
[
'check_in_time'
],
'property_age'
=>
$_POST
[
'property_age'
],
'decoration'
=>
$_POST
[
'decoration'
],
'covered_area'
=>
$_POST
[
'covered_area'
],
'volume_rate'
=>
$_POST
[
'volume_rate'
],
'greening_rate'
=>
$_POST
[
'greening_rate'
],
'households'
=>
$_POST
[
'households'
],
'parking_spaces'
=>
$_POST
[
'parking_spaces'
],
'property_management'
=>
$_POST
[
'property_management'
],
'overview'
=>
$_POST
[
'overview'
],
'city_id'
=>
$_POST
[
'baseCity'
],
'district_id'
=>
$_POST
[
'baseAreaId'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
"room_id"
=>
$_POST
[
"baseRoom"
],
"property_money"
=>
$_POST
[
"property_money"
],
'community_name'
=>
$_POST
[
"community_name"
],
);
$wpdb
->
query
(
"START TRANSACTION"
);
$result
=
House
::
data_insert
();
if
(
$result
!=
200
){
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"新增房源失败"
;
}
else
{
if
(
isset
(
$_POST
[
'houseId'
])){
$result
=
House
::
data_update
(
$_POST
[
'houseId'
],
$insert_tospur_house_array
);
$wpdb
->
query
(
"COMMIT"
);
echo
"新增房源成功"
;
}
else
{
$result
=
House
::
data_insert
(
$insert_tospur_house_array
);
if
(
$result
!=
200
){
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"新增房源失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"新增房源成功"
;
}
}
exit
;
}
else
{
$context
=
array
();
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"room"
]
=
SearchDao
::
searchRoom
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
Timber
::
render
(
"newhouse.html"
,
$context
);
}
else
if
(
isset
(
$_GET
[
'edit'
])){
$context
[
'houseId'
]
=
$_GET
[
'id'
];
$context
=
array_merge
(
$context
,
SearchDao
::
getDetailInfo
(
$_GET
[
'id'
],
"edit"
));
$context
[
"district"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
);
$context
[
"plate"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
,
$context
[
'result'
]
->
district_id
);
}
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"room"
]
=
SearchDao
::
searchRoom
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
Timber
::
render
(
"newhouse.html"
,
$context
);
}
public
static
function
data_update
(
$houseId
,
$insert_tospur_house_array
){
global
$wpdb
;
$wpdb
->
update
(
Config
::
TOSPUR_HOUSE_TABLE
,
$insert_tospur_house_array
,
array
(
"id"
=>
$houseId
));
$exist_ids
=
array
();
foreach
(
$_POST
[
'exists'
]
as
$id
=>
$item
){
$wpdb
->
update
(
Config
::
A_DISTRICT_AREA_TABLE
,
array
(
"buildproperty_id"
=>
$item
[
'buildProperty'
],
"house_area"
=>
$item
[
'housearea'
]
),
array
(
"image_id"
=>
$id
));
$exist_ids
[]
=
$id
;
}
$old_exists_ids
=
explode
(
","
,
$_POST
[
'exists_ids'
]);
$delete_ids
=
array
();
foreach
(
array_diff
(
$old_exists_ids
,
$exist_ids
)
as
$key
=>
$id
){
$delete_ids
[]
=
$id
;
}
$delete_ids
=
implode
(
","
,
$delete_ids
);
$wpdb
->
query
(
"delete from "
.
Config
::
A_DISTRICT_AREA_TABLE
.
" where house_id =
{
$houseId
}
and image_id in (
{
$delete_ids
}
);"
);
$wpdb
->
query
(
"delete from "
.
Config
::
A_HOUSE_IMAGE_TABLE
.
" where house_id =
{
$houseId
}
and image_id in (
{
$delete_ids
}
);"
);
House
::
addMainImage
(
$houseId
);
$exists_photo_ids
=
array
();
foreach
(
$_POST
[
'exists_photo'
]
as
$id
=>
$item
){
$wpdb
->
update
(
Config
::
TOSPUR_IMAGE_TABLE
,
array
(
"image_type"
=>
$item
[
'type'
],
),
array
(
"id"
=>
$id
));
$exists_photo_ids
[]
=
$id
;
}
$old_exists_photo_ids
=
explode
(
","
,
$_POST
[
'exists_photo_ids'
]);
$delete_photo_ids
=
array
();
foreach
(
array_diff
(
$old_exists_photo_ids
,
$exists_photo_ids
)
as
$key
=>
$id
){
$delete_photo_ids
[]
=
$id
;
}
$delete_photo_ids
=
implode
(
","
,
$delete_photo_ids
);
$wpdb
->
query
(
"delete from "
.
Config
::
A_HOUSE_IMAGE_TABLE
.
" where house_id =
{
$houseId
}
and image_id in (
{
$delete_photo_ids
}
);"
);
}
p
ublic
static
function
data_insert
(
){
p
rivate
static
function
addMainImage
(
$houseid
){
global
$wpdb
;
date_default_timezone_set
(
"Etc/GMT-8"
);;
//图片信息
$uploadedfile
=
$_FILES
[
'files'
];
$data
=
$_POST
[
"data"
];
print_r
(
$data
);
//主力房源的图片与房子信息关联插入数据库
if
(
isset
(
$uploadedfile
[
"name"
])){
foreach
(
$uploadedfile
[
"name"
]
as
$key
=>
$value
)
{
$uploadParam
=
array
(
"name"
=>
$uploadedfile
[
"name"
][
$key
],
"type"
=>
$uploadedfile
[
"type"
][
$key
],
"tmp_name"
=>
$uploadedfile
[
"tmp_name"
][
$key
],
"error"
=>
$uploadedfile
[
"error"
][
$key
],
"size"
=>
$uploadedfile
[
"size"
][
$key
]
);
//因为file提交过来有一个空的数组,所以这里判断在filename不为空的情况下,再做后续操作
if
(
$uploadParam
[
"name"
]
!=
""
)
{
//上传图片
if
(
!
function_exists
(
'wp_handle_upload'
))
{
require_once
(
ABSPATH
.
'wp-admin/includes/file.php'
);
}
$overrides
=
array
(
'test_form'
=>
false
);
$movefile
=
wp_handle_upload
(
$uploadParam
,
$overrides
);
$str
=
preg_replace
(
'#^https?://#'
,
''
,
$movefile
[
"url"
]);
$length
=
strpos
(
$str
,
"/"
,
strpos
(
$str
,
"/"
)
+
1
);
$url
=
substr
(
$str
,
$length
);
if
(
$movefile
&&
!
isset
(
$movefile
[
'error'
]))
{
$uploadFileName
=
end
(
explode
(
"/"
,
$url
));
//上传成功后将图片信息存入tospur_image表
$insert_image_array
=
array
(
'name'
=>
$uploadFileName
,
'path'
=>
$url
,
'creattime'
=>
date
(
"Y-m-d H:i:s"
),
'alt'
=>
""
,
'image_type'
=>
$data
[
$key
][
"type"
]
);
$imagePath
=
get_home_path
()
.
$url
;
Image
::
makeImage
(
$uploadFileName
,
$imagePath
);
//插入图片表
$imgRes
=
$wpdb
->
insert
(
'tospur_image'
,
$insert_image_array
);
if
(
!
$imgRes
)
{
return
501
;
}
//获取插入图片的id
$imgid
=
$wpdb
->
insert_id
;
//房源类型、面积与图片关联表
if
(
$data
[
$key
][
"type"
]
==
"0"
){
$houseTypeArea
=
array
(
'house_id'
=>
$houseid
,
"buildproperty_id"
=>
$data
[
"
$key
"
][
"buildProperty"
],
"house_area"
=>
$data
[
"
$key
"
][
"housearea"
],
"image_id"
=>
$imgid
);
$houseTypeAreaRes
=
$wpdb
->
insert
(
'a_district_area'
,
$houseTypeArea
);
if
(
!
$houseTypeAreaRes
)
{
return
502
;
}
}
//将房源id与图片id储存到关联表中
$house_img_array
=
array
(
'house_id'
=>
$houseid
,
'image_id'
=>
$imgid
,
);
$houseImgRes
=
$wpdb
->
insert
(
'a_house_image'
,
$house_img_array
);
if
(
!
$houseImgRes
)
{
return
503
;
}
}
else
{
return
$movefile
[
'error'
];
}
}
}
}
}
public
static
function
data_insert
(
$insert_tospur_house_array
){
global
$wpdb
;
//房源与类型以及面积信息
$data
=
$_POST
[
"data"
];
//获取新房信息,存入tospur_house表
$insert_tospur_house_array
=
array
(
'name'
=>
$_POST
[
'housename'
],
'average_price'
=>
$_POST
[
'average_price'
],
'latest_news'
=>
$_POST
[
'event'
],
'address'
=>
$_POST
[
'address'
],
'traffic'
=>
$_POST
[
'traffic'
],
'periphery'
=>
$_POST
[
'periphery'
],
'developer'
=>
$_POST
[
'developers'
],
'check_in_time'
=>
$_POST
[
'check_in_time'
],
'property_age'
=>
$_POST
[
'property_age'
],
'decoration'
=>
$_POST
[
'decoration'
],
'covered_area'
=>
$_POST
[
'acreage'
],
'volume_rate'
=>
$_POST
[
'volume_rate'
],
'greening_rate'
=>
$_POST
[
'greening_rate'
],
'households'
=>
$_POST
[
'households'
],
'parking_spaces'
=>
$_POST
[
'parking_spaces'
],
'property_management'
=>
$_POST
[
'property_management'
],
'overview'
=>
$_POST
[
'overview'
],
'city_id'
=>
$_POST
[
'baseCity'
],
'district_id'
=>
$_POST
[
'baseAreaId'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
"room_id"
=>
$_POST
[
"baseRoom"
],
"property_money"
=>
$_POST
[
"property_money"
],
'creattime'
=>
date
(
"Y-m-d H:i:s"
),
'user_id'
=>
get_current_user_id
(),
'community_name'
=>
$_POST
[
"community_name"
],
'house_type'
=>
0
);
$insert_tospur_house_array
[
'user_id'
]
=
get_current_user_id
();
$insert_tospur_house_array
[
'creattime'
]
=
date
(
"Y-m-d H:i:s"
);
$insert_tospur_house_array
[
'house_type'
]
=
0
;
$res
=
$wpdb
->
get_results
(
'SELECT * FROM tospur_house WHERE name="'
.
$_POST
[
'housename'
]
.
'" and address="'
.
$_POST
[
'address'
]
.
'"'
,
OBJECT
);
if
(
!
$res
)
{
$houseRes
=
$wpdb
->
insert
(
'tospur_house'
,
$insert_tospur_house_array
);
...
...
@@ -75,7 +197,11 @@ class House {
return
500
;
}
$houseid
=
$wpdb
->
insert_id
;
$house_number
=
"xf"
.
str_pad
(
$insert_tospur_house_array
[
'city_id'
],
6
,
'0'
,
STR_PAD_LEFT
)
.
str_pad
(
$houseid
,
6
,
'0'
,
STR_PAD_LEFT
);
if
(
!
SearchDao
::
setHouseNumber
(
$houseid
,
$insert_tospur_house_array
[
'house_type'
],
$insert_tospur_house_array
[
'city_id'
])){
return
510
;
}
//图片信息
$uploadedfile
=
$_FILES
[
'files'
];
//主力房源的图片与房子信息关联插入数据库
if
(
isset
(
$uploadedfile
[
"name"
])){
foreach
(
$uploadedfile
[
"name"
]
as
$key
=>
$value
)
{
...
...
wp-content/plugins/tospur/Admin/newHouseList.php
View file @
99b3aec2
...
...
@@ -39,15 +39,8 @@ class newHouseList extends WP_List_Table
case
'parking_spaces'
:
case
'property_management'
:
case
'property_money'
:
return
$item
[
$column_name
];
case
'valid'
:
if
(
$item
[
$column_name
])
{
return
'<button data-valid="0" data-score-id="'
.
$item
[
'id'
]
.
'">设为无效</button>'
;
}
else
{
return
'<button data-valid="1" data-score-id="'
.
$item
[
'id'
]
.
'">设为有效</button>'
;
}
default
:
return
print_r
(
$item
,
true
);
//Show the whole array for troubleshooting purposes
return
'<a href="'
.
admin_url
()
.
'admin.php?page=newHouse&edit=true&id='
.
$item
[
'id'
]
.
'">'
.
$item
[
$column_name
]
.
'</a>'
;
}
}
...
...
@@ -173,7 +166,7 @@ class newHouseList extends WP_List_Table
$sql
=
"select * from tospur_house th
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
where 1=1 "
;
where 1=1
and house_type=0
"
;
if
(
$_POST
[
"listCity"
]
!=
0
){
$sql
=
$sql
.
" and city_id="
.
$_POST
[
"listCity"
];
}
...
...
wp-content/plugins/tospur/Admin/rentHouse.php
0 → 100644
View file @
99b3aec2
<?php
require_once
(
PLUGIN_DIR
.
'Dao/SearchDao.php'
);
require_once
(
PLUGIN_DIR
.
'Dao/InsertDao.php'
);
require_once
(
PLUGIN_DIR
.
'Tools/Image.php'
);
class
RentHouse
{
//二手房信息
public
static
function
rentHouse_html
(){
wp_enqueue_script
(
'bootstrapjs'
);
wp_enqueue_style
(
'bootstrapcss'
);
global
$wpdb
;
$type
=
$_POST
[
"type"
];
$context
=
array
();
//获取新房信息,存入tospur_house表
$insert_tospur_house_array
=
array
(
'name'
=>
$_POST
[
'housename'
],
'house_number'
=>
$_POST
[
'house_number'
],
'rent'
=>
$_POST
[
'rent'
],
'buildproperty_id'
=>
$_POST
[
'buildproperty_id'
],
'covered_area'
=>
$_POST
[
'covered_area'
],
'floor'
=>
$_POST
[
'floor'
],
'faceto'
=>
$_POST
[
'faceto'
],
'decoration'
=>
$_POST
[
'decoration'
],
'age'
=>
$_POST
[
'age'
],
'matching_facilities'
=>
$_POST
[
'matching_facilities'
],
'flat'
=>
$_POST
[
'flat'
],
'suite'
=>
$_POST
[
"suite"
],
'overview'
=>
$_POST
[
'overview'
],
'city_id'
=>
$_POST
[
'baseCity'
],
'district_id'
=>
$_POST
[
'baseAreaId'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
'address'
=>
$_POST
[
'address'
],
'community_name'
=>
$_POST
[
'community_name'
],
'traffic'
=>
$_POST
[
'traffic'
],
'periphery'
=>
$_POST
[
'periphery'
],
'status'
=>
$_POST
[
'status'
],
'house_type'
=>
2
);
if
(
$type
==
3
){
$wpdb
->
query
(
"START TRANSACTION"
);
if
(
isset
(
$_POST
[
'houseId'
])){
$result
=
RentHouse
::
data_update
(
$_POST
[
'houseId'
],
$insert_tospur_house_array
);
if
(
$result
!=
202
){
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"租房房源修改失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"租房房源修改成功"
;
}
}
else
{
$result
=
RentHouse
::
rentHouseData_insert
(
$insert_tospur_house_array
);
if
(
$result
!=
200
)
{
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"租房房源新增失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"租房房源新增成功"
;
}
}
exit
;
}
else
if
(
isset
(
$_GET
[
'edit'
])){
$context
[
'houseId'
]
=
$_GET
[
'id'
];
$context
=
array_merge
(
$context
,
SearchDao
::
getDetailInfo
(
$_GET
[
'id'
]));
$context
[
"district"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
);
$context
[
"plate"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
,
$context
[
'result'
]
->
district_id
);
}
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"room"
]
=
SearchDao
::
searchRoom
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
Timber
::
render
(
"rentHouse.html"
,
$context
);
}
public
static
function
rentHouseData_insert
(
$params
)
{
global
$wpdb
;
//图片信息
$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
);
if
(
!
$res
){
$houseId
=
InsertDao
::
insert_tospur_house
(
$params
);
//主力房源的图片与房子信息关联插入数据库
if
(
isset
(
$uploadedfile
[
"name"
])){
foreach
(
$uploadedfile
[
"name"
]
as
$key
=>
$value
)
{
$uploadParam
=
array
(
"name"
=>
$uploadedfile
[
"name"
][
$key
],
"type"
=>
$uploadedfile
[
"type"
][
$key
],
"tmp_name"
=>
$uploadedfile
[
"tmp_name"
][
$key
],
"error"
=>
$uploadedfile
[
"error"
][
$key
],
"size"
=>
$uploadedfile
[
"size"
][
$key
]
);
//因为file提交过来有一个空的数组,所以这里判断在filename不为空的情况下,再做后续操作
if
(
$uploadParam
[
"name"
]
!=
""
)
{
//上传图片
if
(
!
function_exists
(
'wp_handle_upload'
))
{
require_once
(
ABSPATH
.
'wp-admin/includes/file.php'
);
}
$overrides
=
array
(
'test_form'
=>
false
);
$movefile
=
wp_handle_upload
(
$uploadParam
,
$overrides
);
$str
=
preg_replace
(
'#^https?://#'
,
''
,
$movefile
[
"url"
]);
$length
=
strpos
(
$str
,
"/"
,
strpos
(
$str
,
"/"
)
+
1
);
$url
=
substr
(
$str
,
$length
);
if
(
$movefile
&&
!
isset
(
$movefile
[
'error'
]))
{
//上传成功后将图片信息存入tospur_image表
$insert_image_array
=
array
(
'name'
=>
$uploadParam
[
"name"
],
'path'
=>
$url
,
'creattime'
=>
date
(
"Y-m-d H:i:s"
),
'alt'
=>
""
,
'image_type'
=>
$data
[
$key
][
"type"
]
);
//插入图片表
$imgId
=
InsertDao
::
insert_tospur_image
(
$insert_image_array
);
$house_img_array
=
array
(
'house_id'
=>
$houseId
,
'image_id'
=>
$imgId
,
);
$houseImgRes
=
InsertDao
::
insert_a_house_image
(
$house_img_array
);
}
else
{
return
$movefile
[
'error'
];
echo
"插入图片失败"
;
}
}
}
}
//插入推荐房源id与添加新房id到关联表a_house_recommend
if
(
isset
(
$data
[
"recommend"
])){
foreach
(
$data
[
"recommend"
]
as
$value
){
$a_house_recommendArray
=
array
(
"house_id"
=>
$houseId
,
"recommend_id"
=>
$value
);
$a_house_recommendRes
=
InsertDao
::
insert_a_house_recommend
(
$a_house_recommendArray
);
if
(
$a_house_recommendRes
==
504
){
echo
"推荐房源信息插入失败"
;
}
}
}
//插入推荐置业顾问user_id与新房id到关联表a_house_recommend
if
(
$data
[
"recConsultant"
]){
foreach
(
$data
[
"recConsultant"
]
as
$val
){
$a_house_userArray
=
array
(
"user_id"
=>
$val
,
"house_id"
=>
$houseId
,
"user_type"
=>
1
);
$a_house_userRes
=
InsertDao
::
insert_a_house_user
(
$a_house_userArray
);
if
(
$a_house_userRes
==
505
){
echo
"推荐置业顾问信息插入失败"
;
}
}
}
}
else
{
return
508
;
}
return
200
;
}
public
static
function
data_update
(
$houseId
,
$params
){
global
$wpdb
;
$data
=
$_POST
[
"data"
];
$res
=
$wpdb
->
update
(
Config
::
TOSPUR_HOUSE_TABLE
,
$params
,
array
(
"id"
=>
$houseId
));
if
(
$res
){
if
(
$data
[
"recConsultant"
]){
foreach
(
$data
[
"recConsultant"
]
as
$val
){
$a_house_userArray
=
array
(
"user_id"
=>
$val
,
"house_id"
=>
$houseId
,
"user_type"
=>
1
);
$a_house_userRes
=
$wpdb
->
update
(
Config
::
A_HOUSE_USER_TABLE
,
$a_house_userArray
,
array
(
"house_id"
=>
$houseId
));
if
(
!
$a_house_userRes
){
return
513
;
}
}
}
if
(
isset
(
$data
[
"recommend"
])){
$delRes
=
$wpdb
->
delete
(
Config
::
A_HOUSE_RECOMMEND_TABLE
,
array
(
'house_id'
=>
$houseId
));
if
(
$delRes
){
foreach
(
$data
[
"recommend"
]
as
$value
){
$a_house_recommendArray
=
array
(
"house_id"
=>
$houseId
,
"recommend_id"
=>
$value
);
$a_house_recommendRes
=
InsertDao
::
insert_a_house_recommend
(
$a_house_recommendArray
);
}
}
}
}
else
{
return
512
;
}
return
202
;
}
}
wp-content/plugins/tospur/Admin/rentHouseList.php
0 → 100644
View file @
99b3aec2
<?php
if
(
!
class_exists
(
'WP_List_Table'
))
{
require_once
(
ABSPATH
.
'wp-admin/includes/class-wp-list-table.php'
);
}
class
rentHouseList
extends
WP_List_Table
{
function
__construct
()
{
global
$status
,
$page
;
//Set parent defaults
parent
::
__construct
(
array
(
'singular'
=>
'rentHouseList'
,
//singular name of the listed records
'plural'
=>
'rentHouseList'
,
//plural name of the listed records
'ajax'
=>
false
//does this table support ajax?
));
}
function
column_default
(
$item
,
$column_name
)
{
switch
(
$column_name
)
{
case
'id'
:
case
'name'
:
case
'community_name'
:
case
'rent'
:
case
'buildproperty_id'
:
case
'covered_area'
:
case
'floor'
:
case
'faceto'
:
case
'decoration'
:
case
'age'
:
case
'matching_facilities'
:
case
'flat'
:
case
'suite'
:
case
'user_id'
:
case
'status'
:
$handle
=
$item
[
'name'
];
if
(
$handle
==
0
)
{
return
'<a href="'
.
admin_url
()
.
'admin.php?page=rentHouse&edit=true&id='
.
$item
[
'id'
]
.
'">'
.
$item
[
$column_name
]
.
'</a>'
;
}
else
{
return
$item
[
$column_name
];
}
default
:
return
print_r
(
$item
,
true
);
//Show the whole array for troubleshooting purposes
}
}
function
column_cb
(
$item
)
{
return
sprintf
(
'<input type="checkbox" name="%1$s[]" value="%2$s" />'
,
/*$1%s*/
$this
->
_args
[
'singular'
],
//Let's simply repurpose the table's singular label ("score")
/*$2%s*/
$item
[
'id'
]
//The value of the checkbox should be the record's id
);
}
function
get_columns
()
{
$columns
=
array
(
'cb'
=>
'<input type="checkbox" />'
,
//Render a checkbox instead of text
'id'
=>
'ID'
,
'name'
=>
'租房标题'
,
'community_name'
=>
'小区名称'
,
'rent'
=>
'元/月'
,
'buildproperty_id'
=>
'户型'
,
'covered_area'
=>
'面积'
,
'floor'
=>
'楼层'
,
'faceto'
=>
'朝向'
,
'decoration'
=>
'装修状况'
,
'age'
=>
'年代'
,
'matching_facilities'
=>
'配套设施'
,
'flat'
=>
'楼号'
,
'suite'
=>
'室'
,
'user_id'
=>
'置业顾问'
,
'status'
=>
'状态'
);
return
$columns
;
}
function
get_sortable_columns
()
{
$sortable_columns
=
array
(
'id'
=>
array
(
'id'
,
false
),
'name'
=>
array
(
'name'
,
false
),
'community_name'
=>
array
(
'community_name'
,
false
),
'rent'
=>
array
(
'rent'
,
false
),
'buildproperty_id'
=>
array
(
'buildproperty_id'
,
false
),
'covered_area'
=>
array
(
'covered_area'
,
false
),
'floor'
=>
array
(
'floor'
,
false
),
'faceto'
=>
array
(
'faceto'
,
false
),
'decoration'
=>
array
(
'decoration'
,
false
),
'age'
=>
array
(
'age'
,
false
),
'matching_facilities'
=>
array
(
'matching_facilities'
,
false
),
'flat'
=>
array
(
'flat'
,
false
),
'suite'
=>
array
(
'suite'
,
false
),
'user_id'
=>
array
(
'user_id'
,
false
),
'status'
=>
array
(
'status'
,
false
)
);
return
$sortable_columns
;
}
function
get_bulk_actions
()
{
$actions
=
array
(
'noCheck'
=>
'未审核'
,
'check'
=>
'审核'
,
'stopSale'
=>
'下架'
);
return
$actions
;
}
function
process_bulk_action
()
{
$action
=
$this
->
current_action
();
if
(
$action
)
{
$string
=
null
;
$status
=
null
;
switch
(
$action
)
{
case
'noCheck'
:
$id
=
$_POST
[
'renthouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
0
;
}
break
;
case
'check'
:
$id
=
$_POST
[
'renthouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
1
;
}
break
;
case
'stopSale'
:
$id
=
$_POST
[
'renthouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
2
;
}
break
;
}
global
$wpdb
;
$result
=
$wpdb
->
query
(
'update tospur_house SET status='
.
$status
.
' where id in '
.
$string
);
}
}
function
prepare_items
()
{
global
$wpdb
;
$per_page
=
10
;
$columns
=
$this
->
get_columns
();
$hidden
=
array
();
$sortable
=
$this
->
get_sortable_columns
();
$this
->
_column_headers
=
array
(
$columns
,
$hidden
,
$sortable
);
$this
->
process_bulk_action
();
//$data = $this->example_data;
$sql
=
"select * from tospur_house th
left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id
left join(select id as consul_id,name as consul_name from tospur_consultant) tc on ahu.aus_id = tc.consul_id
left join(select value,literal from dic_buildproperty) db on th.buildproperty_id = db.value
where 1=1 and house_type=2"
;
if
(
$_POST
[
"listCity"
]
!=
0
){
$sql
=
$sql
.
" and city_id="
.
$_POST
[
"listCity"
];
}
if
(
$_POST
[
"listDistrict"
]
!=
0
){
$sql
=
$sql
.
" and district_id="
.
$_POST
[
"listDistrict"
];
}
if
(
$_POST
[
"listPlate"
]
!=
0
){
$sql
=
$sql
.
" and plate_id="
.
$_POST
[
"listPlate"
];
}
if
(
$_POST
[
"buildProperty"
]
!=
0
){
$sql
=
$sql
.
" and buildproperty_id="
.
$_POST
[
"buildProperty"
];
}
if
(
isset
(
$_POST
[
"status"
])
&&
$_POST
[
"status"
]
!=-
1
){
$sql
=
$sql
.
" and status="
.
$_POST
[
"status"
];
}
if
(
$_POST
[
"acreage"
]
!=
NULL
){
$areaArray
=
explode
(
"-"
,
$_POST
[
'acreage'
]);
$sql
=
$sql
.
" and covered_area between "
.
$areaArray
[
0
]
.
" and "
.
$areaArray
[
1
];
}
if
(
$_POST
[
"searchText"
]
!=
NULL
){
$sql
=
$sql
.
" and name like '%"
.
$_POST
[
'searchText'
]
.
"%'"
;
}
$result
=
$wpdb
->
get_results
(
$sql
);
$data
=
array
();
foreach
(
$result
as
$key
=>
$value
)
{
$data
[
$key
]
=
array
(
'id'
=>
$value
->
id
,
'name'
=>
$value
->
name
,
'community_name'
=>
$value
->
community_name
,
'rent'
=>
$value
->
rent
,
'buildproperty_id'
=>
$value
->
literal
,
'covered_area'
=>
$value
->
covered_area
,
'floor'
=>
$value
->
floor
,
'faceto'
=>
$value
->
faceto
,
'decoration'
=>
$value
->
decoration
,
'age'
=>
$value
->
age
,
'matching_facilities'
=>
$value
->
matching_facilities
,
'flat'
=>
$value
->
flat
,
'suite'
=>
$value
->
suite
,
'user_id'
=>
$value
->
consul_name
,
);
if
(
$value
->
status
==
0
){
$data
[
$key
][
'status'
]
=
"未审核"
;
}
else
if
(
$value
->
status
==
1
){
$data
[
$key
][
'status'
]
=
"审核"
;
}
else
if
(
$value
->
status
==
2
){
$data
[
$key
][
'status'
]
=
"下架"
;
}
}
function
usort_reorder
(
$a
,
$b
)
{
$orderby
=
(
!
empty
(
$_REQUEST
[
'orderby'
]))
?
$_REQUEST
[
'orderby'
]
:
'valid'
;
//If no sort, default to title
$order
=
(
!
empty
(
$_REQUEST
[
'order'
]))
?
$_REQUEST
[
'order'
]
:
'desc'
;
//If no order, default to asc
$result
=
strcmp
(
$a
[
$orderby
],
$b
[
$orderby
]);
//Determine sort order
return
(
$order
===
'asc'
)
?
$result
:
-
$result
;
//Send final sort direction to usort
}
usort
(
$data
,
'usort_reorder'
);
$current_page
=
$this
->
get_pagenum
();
$total_items
=
count
(
$data
);
$data
=
array_slice
(
$data
,
((
$current_page
-
1
)
*
$per_page
),
$per_page
);
$this
->
items
=
$data
;
$this
->
set_pagination_args
(
array
(
'total_items'
=>
$total_items
,
//WE have to calculate the total number of items
'per_page'
=>
$per_page
,
//WE have to determine how many items to show on a page
'total_pages'
=>
ceil
(
$total_items
/
$per_page
)
//WE have to calculate the total number of pages
));
}
}
add_action
(
'wp_ajax_updateList'
,
'newHouseList::prepare_items'
);
add_action
(
'wp_ajax_nopriv_updateList'
,
'newHouseList::prepare_items'
);
add_action
(
'wp_ajax_searchListCity'
,
'SearchDao::ajax_searchListCity'
);
add_action
(
'wp_ajax_nopriv_searchListCity'
,
'SearchDao::ajax_searchListCity'
);
function
rentHouseList
()
{
$rentHouseList
=
new
rentHouseList
();
$rentHouseList
->
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=
"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
$rentHouseList
->
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);
}
});
})
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
}
?>
\ No newline at end of file
wp-content/plugins/tospur/Admin/secHandHouse.php
View file @
99b3aec2
...
...
@@ -9,35 +9,7 @@ class SecHandHouse{
wp_enqueue_style
(
'bootstrapcss'
);
global
$wpdb
;
$type
=
$_POST
[
"type"
];
if
(
$type
==
2
){
$wpdb
->
query
(
"START TRANSACTION"
);
$result
=
SecHandHouse
::
secHouseData_insert
();
if
(
$result
!=
200
){
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"二手房房源新增失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"二手房房源新增成功"
;
}
exit
;
}
else
{
$context
=
array
();
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
Timber
::
render
(
"secHandHouse.html"
,
$context
);
}
}
public
static
function
secHouseData_insert
()
{
global
$wpdb
;
//图片信息
$uploadedfile
=
$_FILES
[
'files'
];
//房源与类型以及面积信息
$data
=
$_POST
[
"data"
];
//获取新房信息,存入tospur_house表
$context
=
array
();
$insert_tospur_house_array
=
array
(
'name'
=>
$_POST
[
'housename'
],
'house_number'
=>
$_POST
[
'house_number'
],
...
...
@@ -52,15 +24,66 @@ class SecHandHouse{
'flat'
=>
$_POST
[
'flat'
],
'suite'
=>
$_POST
[
"suite"
],
'overview'
=>
$_POST
[
'overview'
],
'city_id'
=>
$_POST
[
'baseCity'
],
'district_id'
=>
$_POST
[
'baseAreaId'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
'address'
=>
$_POST
[
'address'
],
'community_name'
=>
$_POST
[
'community_name'
],
'traffic'
=>
$_POST
[
'traffic'
],
'periphery'
=>
$_POST
[
'periphery'
],
'status'
=>
$_POST
[
'status'
],
'house_type'
=>
1
);
$res
=
$wpdb
->
get_results
(
'SELECT * FROM tospur_house WHERE flat="'
.
$_POST
[
'flat'
]
.
'" and suite="'
.
$_POST
[
"suite"
]
.
'" and house_type=1'
,
OBJECT
);
if
(
$type
==
2
){
$wpdb
->
query
(
"START TRANSACTION"
);
if
(
isset
(
$_POST
[
'houseId'
])){
$result
=
SecHandHouse
::
data_update
(
$_POST
[
'houseId'
],
$insert_tospur_house_array
);
if
(
$result
!=
201
){
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"二手房房源修改失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"二手房房源修改成功"
;
}
}
else
{
$result
=
SecHandHouse
::
secHouseData_insert
(
$insert_tospur_house_array
);
if
(
$result
!=
200
)
{
$wpdb
->
query
(
"ROLLBACK"
);
print_r
(
$wpdb
->
last_error
);;
echo
"二手房房源新增失败"
;
}
else
{
$wpdb
->
query
(
"COMMIT"
);
echo
"二手房房源新增成功"
;
}
}
exit
;
}
else
if
(
isset
(
$_GET
[
'edit'
])){
$context
[
'houseId'
]
=
$_GET
[
'id'
];
$context
=
array_merge
(
$context
,
SearchDao
::
getDetailInfo
(
$_GET
[
'id'
]));
$context
[
"district"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
);
$context
[
"plate"
]
=
SearchDao
::
searchCity
(
$context
[
'result'
]
->
city_id
,
$context
[
'result'
]
->
district_id
);
}
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"room"
]
=
SearchDao
::
searchRoom
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
Timber
::
render
(
"secHandHouse.html"
,
$context
);
}
public
static
function
secHouseData_insert
(
$params
)
{
global
$wpdb
;
//图片信息
$uploadedfile
=
$_FILES
[
'files'
];
//房源与类型以及面积信息
$data
=
$_POST
[
"data"
];
//获取新房信息,存入tospur_house表
$res
=
$wpdb
->
get_results
(
'SELECT * FROM tospur_house WHERE name="'
.
$params
[
'name'
]
.
'" flat="'
.
$_POST
[
'flat'
]
.
'" and suite="'
.
$_POST
[
"suite"
]
.
'" and house_type=1'
,
OBJECT
);
if
(
!
$res
){
$houseId
=
InsertDao
::
insert_tospur_house
(
$
insert_tospur_house_array
);
$houseId
=
InsertDao
::
insert_tospur_house
(
$
params
);
//主力房源的图片与房子信息关联插入数据库
if
(
isset
(
$uploadedfile
[
"name"
])){
foreach
(
$uploadedfile
[
"name"
]
as
$key
=>
$value
)
{
...
...
@@ -138,5 +161,44 @@ class SecHandHouse{
}
return
200
;
}
public
static
function
data_update
(
$houseId
,
$params
){
global
$wpdb
;
$data
=
$_POST
[
"data"
];
$res
=
$wpdb
->
update
(
Config
::
TOSPUR_HOUSE_TABLE
,
$params
,
array
(
"id"
=>
$houseId
));
if
(
$res
){
if
(
$data
[
"recConsultant"
]){
foreach
(
$data
[
"recConsultant"
]
as
$val
){
$a_house_userArray
=
array
(
"user_id"
=>
$val
,
"house_id"
=>
$houseId
,
"user_type"
=>
1
);
$a_house_userRes
=
$wpdb
->
update
(
Config
::
A_HOUSE_USER_TABLE
,
$a_house_userArray
,
array
(
"house_id"
=>
$houseId
));
if
(
!
$a_house_userRes
){
return
511
;
}
}
}
if
(
isset
(
$data
[
"recommend"
])){
$delRes
=
$wpdb
->
delete
(
Config
::
A_HOUSE_RECOMMEND_TABLE
,
array
(
'house_id'
=>
$houseId
));
if
(
$delRes
){
foreach
(
$data
[
"recommend"
]
as
$value
){
$a_house_recommendArray
=
array
(
"house_id"
=>
$houseId
,
"recommend_id"
=>
$value
);
$a_house_recommendRes
=
InsertDao
::
insert_a_house_recommend
(
$a_house_recommendArray
);
$wpdb
->
show_errors
();
$wpdb
->
print_error
();
}
}
}
}
else
{
return
510
;
}
return
201
;
}
}
wp-content/plugins/tospur/Admin/secHandHouseList.php
0 → 100644
View file @
99b3aec2
<?php
if
(
!
class_exists
(
'WP_List_Table'
))
{
require_once
(
ABSPATH
.
'wp-admin/includes/class-wp-list-table.php'
);
}
class
secHandHouseList
extends
WP_List_Table
{
function
__construct
()
{
global
$status
,
$page
;
//Set parent defaults
parent
::
__construct
(
array
(
'singular'
=>
'secHandHouseList'
,
//singular name of the listed records
'plural'
=>
'secHandHouseLists'
,
//plural name of the listed records
'ajax'
=>
false
//does this table support ajax?
));
}
function
column_default
(
$item
,
$column_name
)
{
switch
(
$column_name
)
{
case
'id'
:
case
'name'
:
case
'community_name'
:
case
'total_price'
:
case
'buildproperty_id'
:
case
'covered_area'
:
case
'floor'
:
case
'faceto'
:
case
'decoration'
:
case
'age'
:
case
'flat'
:
case
'suite'
:
case
'user_id'
:
case
'status'
:
default
:
return
'<a href="'
.
admin_url
()
.
'admin.php?page=secHandHouse&edit=true&id='
.
$item
[
'id'
]
.
'">'
.
$item
[
$column_name
]
.
'</a>'
;
}
}
function
column_cb
(
$item
)
{
return
sprintf
(
'<input type="checkbox" name="%1$s[]" value="%2$s" />'
,
/*$1%s*/
$this
->
_args
[
'singular'
],
//Let's simply repurpose the table's singular label ("score")
/*$2%s*/
$item
[
'id'
]
//The value of the checkbox should be the record's id
);
}
function
get_columns
()
{
$columns
=
array
(
'cb'
=>
'<input type="checkbox" />'
,
//Render a checkbox instead of text
'id'
=>
'ID'
,
'name'
=>
'二手房标题'
,
'community_name'
=>
'小区名称'
,
'total_price'
=>
'总价'
,
'buildproperty_id'
=>
'户型'
,
'covered_area'
=>
'面积'
,
'floor'
=>
'楼层'
,
'faceto'
=>
'朝向'
,
'decoration'
=>
'装修状况'
,
'age'
=>
'年代'
,
'flat'
=>
'楼号'
,
'suite'
=>
'室'
,
'user_id'
=>
'置业顾问'
,
'status'
=>
'状态'
);
// if (current_user_can('Administrator')) {
// $columns['cb'] = '<input type="checkbox" />';
// }
return
$columns
;
}
function
get_sortable_columns
()
{
$sortable_columns
=
array
(
'id'
=>
array
(
'id'
,
false
),
'name'
=>
array
(
'name'
,
false
),
'community_name'
=>
array
(
'community_name'
,
false
),
'total_price'
=>
array
(
'total_price'
,
false
),
'buildproperty_id'
=>
array
(
'buildproperty_id'
,
false
),
'covered_area'
=>
array
(
'covered_area'
,
false
),
'floor'
=>
array
(
'floor'
,
false
),
'faceto'
=>
array
(
'faceto'
,
false
),
'decoration'
=>
array
(
'decoration'
,
false
),
'age'
=>
array
(
'age'
,
false
),
'flat'
=>
array
(
'flat'
,
false
),
'suite'
=>
array
(
'suite'
,
false
),
'user_id'
=>
array
(
'user_id'
,
false
),
'status'
=>
array
(
'status'
,
false
)
);
return
$sortable_columns
;
}
function
get_bulk_actions
()
{
$actions
=
array
(
'noCheck'
=>
'未审核'
,
'check'
=>
'审核'
,
'stopSale'
=>
'下架'
);
return
$actions
;
}
function
process_bulk_action
()
{
$action
=
$this
->
current_action
();
if
(
$action
)
{
$string
=
null
;
$status
=
null
;
switch
(
$action
)
{
case
'noCheck'
:
$id
=
$_POST
[
'sechandhouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
0
;
}
break
;
case
'check'
:
$id
=
$_POST
[
'sechandhouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
1
;
}
break
;
case
'stopSale'
:
$id
=
$_POST
[
'sechandhouselist'
];
if
(
$id
)
{
$string
=
'('
.
implode
(
','
,
array_map
(
'intval'
,
$id
))
.
')'
;
$status
=
2
;
}
break
;
}
global
$wpdb
;
$result
=
$wpdb
->
query
(
'update tospur_house SET status='
.
$status
.
' where id in '
.
$string
);
}
}
function
prepare_items
()
{
global
$wpdb
;
$per_page
=
10
;
$columns
=
$this
->
get_columns
();
$hidden
=
array
();
$sortable
=
$this
->
get_sortable_columns
();
$this
->
_column_headers
=
array
(
$columns
,
$hidden
,
$sortable
);
$this
->
process_bulk_action
();
//$data = $this->example_data;
$sql
=
"select * from tospur_house th
left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id
left join(select id as consul_id,name as consul_name from tospur_consultant) tc on ahu.aus_id = tc.consul_id
left join(select value,literal from dic_buildproperty) db on th.buildproperty_id = db.value
where 1=1 and house_type=1"
;
if
(
$_POST
[
"listCity"
]
!=
0
){
$sql
=
$sql
.
" and city_id="
.
$_POST
[
"listCity"
];
}
if
(
$_POST
[
"listDistrict"
]
!=
0
){
$sql
=
$sql
.
" and district_id="
.
$_POST
[
"listDistrict"
];
}
if
(
$_POST
[
"listPlate"
]
!=
0
){
$sql
=
$sql
.
" and plate_id="
.
$_POST
[
"listPlate"
];
}
if
(
$_POST
[
"buildProperty"
]
!=
0
){
$sql
=
$sql
.
" and buildproperty_id="
.
$_POST
[
"buildProperty"
];
}
if
(
isset
(
$_POST
[
"status"
])
&&
$_POST
[
"status"
]
!=-
1
){
$sql
=
$sql
.
" and status="
.
$_POST
[
"status"
];
}
if
(
$_POST
[
"totalPrice"
]
!=
NULL
){
$priceArray
=
explode
(
"-"
,
$_POST
[
'totalPrice'
]);
$sql
=
$sql
.
" and average_price between "
.
$priceArray
[
0
]
.
" and "
.
$priceArray
[
1
];
}
if
(
$_POST
[
"acreage"
]
!=
NULL
){
$areaArray
=
explode
(
"-"
,
$_POST
[
'acreage'
]);
$sql
=
$sql
.
" and covered_area between "
.
$areaArray
[
0
]
.
" and "
.
$areaArray
[
1
];
}
if
(
$_POST
[
"searchText"
]
!=
NULL
){
$sql
=
$sql
.
" and name like '%"
.
$_POST
[
'searchText'
]
.
"%'"
;
}
$result
=
$wpdb
->
get_results
(
$sql
);
$data
=
array
();
foreach
(
$result
as
$key
=>
$value
)
{
$data
[
$key
]
=
array
(
'id'
=>
$value
->
id
,
'name'
=>
$value
->
name
,
'community_name'
=>
$value
->
community_name
,
'total_price'
=>
$value
->
total_price
,
'buildproperty_id'
=>
$value
->
literal
,
'covered_area'
=>
$value
->
covered_area
,
'floor'
=>
$value
->
floor
,
'faceto'
=>
$value
->
faceto
,
'decoration'
=>
$value
->
decoration
,
'age'
=>
$value
->
age
,
'flat'
=>
$value
->
flat
,
'suite'
=>
$value
->
suite
,
'user_id'
=>
$value
->
consul_name
,
);
if
(
$value
->
status
==
0
){
$data
[
$key
][
'status'
]
=
"未审核"
;
}
else
if
(
$value
->
status
==
1
){
$data
[
$key
][
'status'
]
=
"审核"
;
}
else
if
(
$value
->
status
==
2
){
$data
[
$key
][
'status'
]
=
"下架"
;
}
}
function
usort_reorder
(
$a
,
$b
)
{
$orderby
=
(
!
empty
(
$_REQUEST
[
'orderby'
]))
?
$_REQUEST
[
'orderby'
]
:
'valid'
;
//If no sort, default to title
$order
=
(
!
empty
(
$_REQUEST
[
'order'
]))
?
$_REQUEST
[
'order'
]
:
'desc'
;
//If no order, default to asc
$result
=
strcmp
(
$a
[
$orderby
],
$b
[
$orderby
]);
//Determine sort order
return
(
$order
===
'asc'
)
?
$result
:
-
$result
;
//Send final sort direction to usort
}
usort
(
$data
,
'usort_reorder'
);
$current_page
=
$this
->
get_pagenum
();
$total_items
=
count
(
$data
);
$data
=
array_slice
(
$data
,
((
$current_page
-
1
)
*
$per_page
),
$per_page
);
$this
->
items
=
$data
;
$this
->
set_pagination_args
(
array
(
'total_items'
=>
$total_items
,
//WE have to calculate the total number of items
'per_page'
=>
$per_page
,
//WE have to determine how many items to show on a page
'total_pages'
=>
ceil
(
$total_items
/
$per_page
)
//WE have to calculate the total number of pages
));
}
}
add_action
(
'wp_ajax_updateList'
,
'newHouseList::prepare_items'
);
add_action
(
'wp_ajax_nopriv_updateList'
,
'newHouseList::prepare_items'
);
add_action
(
'wp_ajax_searchListCity'
,
'SearchDao::ajax_searchListCity'
);
add_action
(
'wp_ajax_nopriv_searchListCity'
,
'SearchDao::ajax_searchListCity'
);
function
secHandHouseList
()
{
$secHandHouseList
=
new
secHandHouseList
();
$secHandHouseList
->
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=
"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>
</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
$secHandHouseList
->
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
);
}
});
})
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
}
?>
\ No newline at end of file
wp-content/plugins/tospur/Admin/views/newhouse.html
View file @
99b3aec2
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改新房房源":"添加新房房源" %}
<meta
charset=
"utf-8"
>
<title>
添加新房房源
</title>
<title>
{{title}}
</title>
</head>
<body>
<h2
class=
"title"
>
添加新房房源
</h2>
<h2
class=
"title"
>
{{title}}
</h2>
<form
action=
""
method=
"POST"
enctype=
"multipart/form-data"
>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label
for=
"housename"
>
楼盘名
</label></th>
<td>
<input
name=
"housename"
id=
"housename"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"housename"
id=
"housename"
type=
"text"
value=
"
{{result.name}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"community_name"
>
小区名
</label></th>
<td>
<input
name=
"community_name"
id=
"community_name"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"community_name"
id=
"community_name"
type=
"text"
value=
"
{{result.community_name}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"average_price"
>
均价
</label></th>
<td>
<input
name=
"average_price"
id=
"average_price"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"average_price"
id=
"average_price"
type=
"text"
value=
"
{{result.average_price}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
event
"
>
最新动态
</label></th>
<td><textarea
name=
"
event"
rows=
"4"
cols=
"40"
class=
"large-text code"
>
</textarea></td>
<th><label
for=
"
latest_news
"
>
最新动态
</label></th>
<td><textarea
name=
"
latest_news"
rows=
"4"
cols=
"40"
class=
"large-text code"
>
{{result.latest_news}}
</textarea></td>
</tr>
<tr>
<th><label
for=
"from"
>
所属地区
</label></th>
...
...
@@ -31,14 +32,24 @@
<select
id=
"baseCity"
name=
"baseCity"
>
<option
value=
""
>
城市
</option>
{% for item in city %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
<option
{{
item
.
id =
=
result
.
city_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<select
id=
"baseAreaId"
name=
"baseAreaId"
>
<option
value =
""
>
区域
</option>
{% if district %}
{% for item in district %}
<option
{{
item
.
id =
=
result
.
district_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
{% endif %}
</select>
<select
id=
"basePlateId"
name=
"basePlateId"
>
<option
value =
""
>
板块
</option>
{% if district %}
{% for item in plate %}
<option
{{
item
.
id =
=
result
.
plate_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
{% endif %}
</select>
</td>
</tr>
...
...
@@ -46,6 +57,24 @@
<th><label
for=
"mainHouse"
>
主力户型
</label></th>
<td>
<div
id=
"preview"
>
{% set exists_ids = "" %}
{% for item in mainImage %}
{% if exists_ids != "" %}
{% set exists_ids = exists_ids~"," %}
{% endif %}
{% set exists_ids = exists_ids~item.id %}
<div
id=
"exists_{{item.id}}"
>
<img
src=
"{{siteUrl}}{{item.path}}"
heghit=
"100"
width=
"100"
><br
/>
<select
name=
"exists[{{item.id}}][buildProperty]"
>
{% for i in buildProperty %}
<option
{{
i
.
id =
=
item
.
buildproperty_id
?"
selected
"
:
""
}}
value=
"{{i.id}}"
>
{{i.value}}
</option>
{% endfor %}
</select>
<input
type=
"text"
placeholder=
"面积"
name=
"exists[{{item.id}}][housearea]"
class=
"regular-text"
value=
"{{item.area}}"
>
<input
type=
"button"
value=
"取消"
class=
"cancel existsCancel"
>
</div>
{% endfor %}
<input
type=
"hidden"
name=
"exists_ids"
value=
"{{exists_ids}}"
>
<input
type=
"file"
name=
"files[0]"
property=
"0"
class =
"files"
multiple
class=
"browser button button-hero"
>
<P></P>
</div>
...
...
@@ -58,15 +87,15 @@
<tbody>
<tr>
<th><label
for=
"address"
>
地址
</label></th>
<td>
<input
name=
"address"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"address"
type=
"text"
value=
"
{{result.address}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"traffic"
>
交通线路
</label></th>
<td>
<input
name=
"traffic"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"traffic"
type=
"text"
value=
"
{{result.traffic}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"periphery"
>
周边配套
</label></th>
<td>
<input
name=
"periphery"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"periphery"
type=
"text"
value=
"
{{result.periphery}}
"
class=
"regular-text code"
></td>
</tr>
</tbody>
</table>
...
...
@@ -78,58 +107,58 @@
<td>
<select
id=
"baseRoom"
name=
"baseRoom"
>
{% for item in room %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
<option
{{
item
.
id =
=
result
.
room_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label
for=
"developers"
>
开发商
</label></th>
<td>
<input
name=
"developers"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"developers"
type=
"text"
value=
"
{{result.developer}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"check_in_time"
>
入住时间
</label></th>
<td>
<input
name=
"check_in_time"
id=
"checkin"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"check_in_time"
id=
"checkin"
type=
"text"
value=
"
{{result.check_in_time}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"property_age"
>
产权年限
</label></th>
<td>
<input
name=
"property_age"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"property_age"
type=
"text"
value=
"
{{result.property_age}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"decoration"
>
装修状况
</label></th>
<td>
<input
name=
"decoration"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"decoration"
type=
"text"
value=
"
{{result.decoration}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
acreage
"
>
建筑面积
</label></th>
<td>
<input
name=
"
acreage"
type=
"text"
value=
"
"
class=
"regular-text code"
></td>
<th><label
for=
"
covered_area
"
>
建筑面积
</label></th>
<td>
<input
name=
"
covered_area"
type=
"text"
value=
"{{result.covered_area}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"volume_rate"
>
容积率
</label></th>
<td>
<input
name=
"volume_rate"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"volume_rate"
type=
"text"
value=
"
{{result.volume_rate}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"greening_rate"
>
绿化率
</label></th>
<td>
<input
name=
"greening_rate"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"greening_rate"
type=
"text"
value=
"
{{result.greening_rate}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"households"
>
规划户数
</label></th>
<td>
<input
name=
"households"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"households"
type=
"text"
value=
"
{{result.households}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"parking_spaces"
>
车位数
</label></th>
<td>
<input
name=
"parking_spaces"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"parking_spaces"
type=
"text"
value=
"
{{result.parking_spaces}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"property_management"
>
物业公司
</label></th>
<td>
<input
name=
"property_management"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"property_management"
type=
"text"
value=
"
{{result.property_management}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"property_money"
>
物业费
</label></th>
<td>
<input
name=
"property_money"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"property_money"
type=
"text"
value=
"
{{result.property_money}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
property_money
"
>
楼盘概述
</label></th>
<td>
<textarea
name=
"overview"
rows=
"4"
cols=
"40"
class=
"large-text code"
></textarea></td>
<th><label
for=
"
overview
"
>
楼盘概述
</label></th>
<td>
<textarea
name=
"overview"
rows=
"4"
cols=
"40"
class=
"large-text code"
>
{{result.overview}}
</textarea></td>
</tr>
</tbody>
</table>
...
...
@@ -139,7 +168,25 @@
<tr>
<th><label>
房源相册
</label></th>
<td>
<div
id=
"picList"
></div><br
/>
<div
id=
"picList"
>
{% set exists_photo_ids = "" %}
{% for item in images %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.id %}
<p
id=
"exists_photo_{{ item.id }}"
>
<select
name=
"exists_photo[{{ item.id }}][type]"
>
{% for i in photoType %}
<option
{{
i
.
id =
=
item
.
image_type
?"
selected
"
:
""
}}
value=
"{{ i.id }}"
>
{{ i.value }}
</option>
{% endfor %}
</select>
<img
src=
"{{siteUrl}}{{item.path}}"
heghit=
"100"
width=
"100"
>
<input
type=
"button"
value=
"取消"
class=
"cancel existsCancel"
>
</p>
{% endfor %}
<input
type=
"hidden"
name=
"exists_photo_ids"
value=
"{{exists_photo_ids}}"
>
</div><br
/>
<button
type=
"button"
id=
"housePicture"
class=
"button action"
data-toggle=
"modal"
>
新增
</button>
...
...
@@ -166,6 +213,9 @@
</tbody>
</table>
<input
type=
"text"
name=
"type"
value=
"1"
hidden=
"hidden"
>
{% if houseId %}
<input
type=
"text"
name=
"houseId"
value=
"{{houseId}}"
hidden=
"hidden"
>
{% endif %}
<input
type=
"submit"
id=
"submit"
class=
"button action"
>
</form>
...
...
@@ -548,6 +598,10 @@
$
(
"#houseImg"
).
find
(
"p:last-child"
).
remove
();
}
}
$
(
"#preview,#picList"
).
on
(
"click"
,
".existsCancel"
,
function
(){
$
(
this
).
parent
().
remove
();
});
});
})(
jQuery
);
...
...
wp-content/plugins/tospur/Admin/views/rentHouse.html
0 → 100644
View file @
99b3aec2
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改租房房源":"添租新房房源" %}
<meta
charset=
"utf-8"
>
<title>
{{title}}
</title>
</head>
<body>
<h2
class=
"title"
>
{{title}}
</h2>
<form
action=
""
method=
"POST"
enctype=
"multipart/form-data"
>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label
for=
"housename"
>
房源名:
</label></th>
<td>
<input
name=
"housename"
id=
"housename"
type=
"text"
value=
"{{result.name}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"rent"
>
租金
</label></th>
<td>
<input
name=
"rent"
id=
"rent"
type=
"text"
value=
"{{result.rent}}"
class=
"regular-text code"
></td>
</tr>
</tbody>
</table>
<h2
class=
"title"
>
基本信息
</h2>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label
for=
"from"
>
户型
</label></th>
<td>
<select
id=
"buildproperty_id"
name=
"buildproperty_id"
>
<option
value=
"-1"
>
户型
</option>
{% for item in buildProperty %}
<option
{{
item
.
id =
=
result
.
buildproperty_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label
for=
"covered_area"
>
面积
</label></th>
<td>
<input
name=
"covered_area"
type=
"text"
value=
"{{result.covered_area}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"floor"
>
楼层:
</label></th>
<td>
<input
name=
"floor"
type=
"text"
value=
"{{result.floor}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"faceto"
>
朝向:
</label></th>
<td>
<input
name=
"faceto"
type=
"text"
value=
"{{result.faceto}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"decoration"
>
装修状况
</label></th>
<td>
<input
name=
"decoration"
type=
"text"
value=
"{{result.decoration}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"age"
>
建筑年代
</label></th>
<td>
<input
name=
"age"
type=
"text"
value=
"{{result.age}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"matching_facilities"
>
配套设施
</label></th>
<td>
<input
name=
"matching_facilities"
type=
"text"
value=
"{{result.matching_facilities}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"flat"
>
楼号
</label></th>
<td>
<input
name=
"flat"
type=
"text"
value=
"{{result.flat}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"suite"
>
室
</label></th>
<td>
<input
name=
"suite"
type=
"text"
value=
"{{result.suite}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"overview"
>
房源点评
</label></th>
<td>
<textarea
name=
"overview"
rows=
"4"
cols=
"40"
class=
"large-text code"
>
{{result.overview}}
</textarea></td>
</tr>
</tbody>
</table>
<h2
class=
"title"
>
位置及周边
</h2>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label
for=
"address"
>
地址
</label></th>
<td>
<input
name=
"address"
type=
"text"
value=
"{{result.address}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"address"
>
小区名称
</label></th>
<td>
<input
name=
"community_name"
type=
"text"
value=
"{{result.community_name}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"traffic"
>
交通线路
</label></th>
<td>
<input
name=
"traffic"
type=
"text"
value=
"{{result.traffic}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"periphery"
>
周边配套
</label></th>
<td>
<input
name=
"periphery"
type=
"text"
value=
"{{result.periphery}}"
class=
"regular-text code"
></td>
</tr>
</tbody>
</table>
<h2
class=
"title"
>
关联信息
</h2>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label>
房源相册
</label></th>
<td>
<div
id=
"picList"
></div><br
/>
<button
type=
"button"
id=
"housePicture"
class=
"button action"
data-toggle=
"modal"
>
新增
</button>
</td>
</tr>
<tr>
<th><label
for=
"recommend"
>
推荐房源
</label></th>
<td>
<div
id=
"houseImg"
></div><br
/>
<button
type=
"button"
class=
"button action"
data-toggle=
"modal"
data-target=
"#myModal"
>
添加房源
</button>
</td>
</tr>
<tr>
<th><label
for=
"consultant"
>
置业顾问
</label></th>
<td>
<div
id=
"consultantImg"
></div><br
/>
<button
type=
"button"
class=
"button action"
data-toggle=
"modal"
data-target=
"#myConsultant"
>
选择置业顾问
</button>
</td>
</tr>
<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>
</select>
</td>
</tr>
</tbody>
</table>
<input
type=
"text"
name=
"type"
value=
"3"
hidden=
"hidden"
>
{% if houseId %}
<input
type=
"text"
name=
"houseId"
value=
"{{houseId}}"
hidden=
"hidden"
>
{% endif %}
<input
type=
"submit"
id=
"submit"
class=
"button action"
>
</form>
<!-- Modal -->
<!-- 新增房源弹出层 -->
<div
class=
"modal fade"
id=
"myModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-body"
style=
"height: 300px;overflow: auto;"
>
<select
id=
"cityId"
>
<option
value=
"-1"
>
城市
</option>
{% for item in city %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<select
id=
"areaId"
>
<option
value =
"-1"
>
区域
</option>
</select>
<select
id=
"plateId"
>
<option
value =
"-1"
>
板块
</option>
</select>
<select
id=
"price"
>
<option
value =
"-1"
>
价格
</option>
</select>
<select
id=
"buildProperty"
>
<option
value =
"-1"
>
房型
</option>
{% for item in buildProperty %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<select
id=
"room"
>
<option
value =
"-1"
>
类型
</option>
{% for item in room %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<select
id=
"acreage"
>
<option
value =
"-1"
>
面积
</option>
</select>
<input
type=
"text"
placeholder=
"请出入楼盘名/地段名搜索"
id=
"searchtext"
>
<button
type=
"button"
class=
"button action"
id=
"search"
>
搜索
</button>
<ul
id=
"houseList"
>
</ul>
</div>
</div>
</div>
</div>
<!-- 置业顾问弹出层 -->
<div
class=
"modal fade"
id=
"myConsultant"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-body"
style=
"height: 300px;overflow: auto;"
>
<select
id=
"consultCity"
>
<option
value=
""
>
城市
</option>
{% for item in city %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<input
type=
"text"
placeholder=
"请出入置业顾问姓名搜索"
id=
"consultantName"
>
<button
type=
"button"
class=
"button action"
id=
"searchConsult"
>
搜索
</button>
<ul
id=
"consultantList"
>
</ul>
</div>
</div>
</div>
</div>
<script>
(
function
(
$
){
$
(
document
).
ready
(
function
(){
//主力房源中选择图片file的下标
var
i
=
0
;
//基本信息的联动AJAX
$
(
"#baseCity"
).
change
(
function
(){
var
cityId
=
$
(
"#baseCity"
).
val
();
var
baserArea
=
$
(
"#baseAreaId"
);
$
(
'#baseAreaId'
).
find
(
'option:not(:first-child)'
).
remove
();
$
(
'#basePlateId'
).
find
(
'option:not(:first-child)'
).
remove
();
//城市联动区域
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=serachCity&cityId="
+
cityId
,
success
:
function
(
json
){
addOption
(
json
,
baserArea
);
}
});
});
//区域联动板块
$
(
"#baseAreaId"
).
change
(
function
(){
var
basePlate
=
$
(
"#basePlateId"
);
var
areaId
=
$
(
"#baseAreaId"
).
val
();
var
cityId
=
$
(
"#baseCity"
).
val
();
$
(
'#basePlateId'
).
find
(
'option:not(:first-child)'
).
remove
();
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=serachCity&cityId="
+
cityId
+
"&districtId="
+
areaId
,
success
:
function
(
json
){
addOption
(
json
,
basePlate
);
}
});
});
//推荐房源的联动AJAX
$
(
"#cityId"
).
change
(
function
(){
var
cityId
=
$
(
this
).
val
();
var
area
=
$
(
"#areaId"
);
var
acreage
=
$
(
"#acreage"
);
var
price
=
$
(
"#price"
);
$
(
'#areaId'
).
find
(
'option:not(:first-child)'
).
remove
();
$
(
'#plateId'
).
find
(
'option:not(:first-child)'
).
remove
();
$
(
'#price'
).
find
(
'option:not(:first-child)'
).
remove
();
$
(
'#acreage'
).
find
(
'option:not(:first-child)'
).
remove
();
$
(
"#houseList"
).
find
(
"li"
).
remove
();
//城市联动区域
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=serachCity&cityId="
+
cityId
,
success
:
function
(
json
){
addOption
(
json
,
area
);
}
});
//城市联动房子面积
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchArea&cityId="
+
cityId
,
success
:
function
(
json
){
addOption
(
json
,
acreage
);
}
});
//城市联动房子价格
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchUnitPriceRange&cityId="
+
cityId
,
success
:
function
(
json
){
addOption
(
json
,
price
);
}
});
});
//区域联动板块
$
(
"#areaId"
).
change
(
function
(){
var
areaId
=
$
(
"#areaId"
).
val
();
var
cityId
=
$
(
"#cityId"
).
val
();
var
plate
=
$
(
"#plateId"
);
$
(
"#houseList"
).
find
(
"li"
).
remove
();
$
(
'#plateId'
).
find
(
'option:not(:first-child)'
).
remove
();
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=serachCity&cityId="
+
cityId
+
"&districtId="
+
areaId
,
success
:
function
(
json
){
addOption
(
json
,
plate
);
}
});
});
//推荐房源下显示图片信息以及房名
$
(
"#cityId,#areaId,#plateId,#buildProperty,#room,#acreage,#price"
).
change
(
function
(){
$
(
"#houseList"
).
find
(
"li"
).
remove
();
var
buildPropertyId
=
$
(
"#buildProperty"
).
val
();
var
room
=
$
(
"#room"
).
val
();
var
areaId
=
$
(
"#areaId"
).
val
();
var
cityId
=
$
(
"#cityId"
).
val
();
var
plateId
=
$
(
"#plateId"
).
val
();
var
acreage
=
$
(
"#acreage"
).
val
();
var
price
=
$
(
"#price"
).
val
();
$
.
ajax
({
type
:
"post"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchHouse&cityId="
+
cityId
+
"&districtId="
+
areaId
+
"&plateId="
+
plateId
+
"&buildPropertyId="
+
buildPropertyId
+
"&roomId="
+
room
+
"&acreage="
+
acreage
+
"&totalPrice="
+
price
+
"&houseType=2"
,
success
:
function
(
json
){
var
result
=
json
.
result
;
for
(
var
i
=
0
;
i
<
result
.
length
;
i
++
){
var
name
=
result
[
i
][
"name"
];
var
id
=
result
[
i
][
'id'
];
var
imgUrl
=
json
.
images
[
id
];
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
imgUrl
,
"height"
:
100
,
"width"
:
100
});
var
li
=
$
(
"<li>"
).
attr
(
"id"
,
id
).
addClass
(
"addImg"
).
append
(
img
).
append
(
name
);
$
(
"#houseList"
).
append
(
li
);
}
}
});
});
//添加房源中搜索框的搜索
$
(
"#search"
).
click
(
function
(){
$searchtext
=
$
(
"#searchtext"
).
val
();
$
(
"#houseList"
).
find
(
"li"
).
remove
();
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchHouse&searchtext="
+
$searchtext
,
success
:
function
(
json
){
for
(
var
i
=
0
;
i
<=
json
.
length
-
1
;
i
++
){
var
name
=
json
[
i
][
"name"
];
var
imgUrl
=
json
[
i
][
"path"
];
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
imgUrl
,
"height"
:
100
,
"width"
:
100
});
var
li
=
$
(
"<li>"
).
addClass
(
"addImg"
).
append
(
img
).
append
(
name
);
$
(
"#houseList"
).
append
(
li
);
}
}
});
})
//搜索对应城市的置业顾问
$
(
"#consultCity"
).
change
(
function
(){
var
consulCityId
=
$
(
"#consultCity"
).
val
();
var
consultantName
=
$
(
"#consultantName"
).
val
();
$
(
"#consultantList"
).
find
(
"li"
).
remove
();
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchConsultant&consulCityId="
+
consulCityId
+
"&consultantName="
+
consultantName
,
success
:
function
(
json
){
for
(
var
i
=
0
;
i
<=
json
.
length
-
1
;
i
++
){
var
name
=
json
[
i
][
"consultantName"
];
var
imgUrl
=
json
[
i
][
"imageUrl"
];
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
imgUrl
,
"height"
:
100
,
"width"
:
100
});
var
li
=
$
(
"<li>"
).
attr
(
"id"
,
json
[
i
][
"id"
]).
append
(
img
).
append
(
name
).
addClass
(
"consultantImg"
);
$
(
"#consultantList"
).
append
(
li
);
}
}
});
});
//添加置业顾问弹出层中搜索框的搜索内容
$
(
"#searchConsult"
).
click
(
function
(){
var
consulCityId
=
$
(
"#consultCity"
).
val
();
var
consultantName
=
$
(
"#consultantName"
).
val
();
$
(
"#consultantList"
).
find
(
"li"
).
remove
();
$
.
ajax
({
type
:
"GET"
,
url
:
"/tospur/wp-admin/admin-ajax.php"
,
data
:
"action=searchConsultant&consulCityId="
+
consulCityId
+
"&consultantName="
+
consultantName
,
success
:
function
(
json
){
for
(
var
i
=
0
;
i
<=
json
.
length
-
1
;
i
++
){
var
name
=
json
[
i
][
"consultantName"
];
var
imgUrl
=
json
[
i
][
"imageUrl"
];
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
imgUrl
,
"height"
:
100
,
"width"
:
100
});
var
li
=
$
(
"<li>"
).
append
(
img
).
append
(
name
).
addClass
(
"consultantImg"
);
$
(
"#consultantList"
).
append
(
li
);
}
}
});
})
//点击添加房源中显示的列表,在界面中显示
$
(
"#houseList"
).
on
(
"click"
,
".addImg"
,
function
(){
var
recommendHouse
=
$
(
"<input>"
).
attr
({
"type"
:
"hidden"
,
"name"
:
"data[recommend][]"
,
"value"
:
$
(
this
).
attr
(
"id"
)});
var
url
=
$
(
this
).
find
(
"img"
).
attr
(
"src"
);
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
url
,
"height"
:
100
,
"width"
:
100
});
var
cancel
=
$
(
"<input>"
).
attr
({
"type"
:
"button"
,
"value"
:
"删除"
}).
addClass
(
"imgCancel"
);
var
p
=
$
(
"<p>"
).
append
(
img
).
append
(
cancel
).
append
(
recommendHouse
);
$
(
"#houseImg"
).
append
(
p
);
controlCommand
(
"houseImg"
,
3
,
0
);
});
//添加置业顾问
$
(
"#consultantList"
).
on
(
"click"
,
".consultantImg"
,
function
(){
var
recommendConsultant
=
$
(
"<input>"
).
attr
({
"type"
:
"hidden"
,
"name"
:
"data[recConsultant][]"
,
"value"
:
$
(
this
).
attr
(
"id"
)});
var
cancel
=
$
(
"<input>"
).
attr
({
"type"
:
"button"
,
"value"
:
"删除"
}).
addClass
(
"consultantCancel"
);
var
font
=
$
(
"<font>"
).
append
(
$
(
this
).
text
());
var
p
=
$
(
"<p>"
).
append
(
font
).
append
(
cancel
).
append
(
recommendConsultant
);
$
(
"#consultantImg"
).
append
(
p
);
controlCommand
(
"consultantImg"
,
1
,
1
);
});
//新增房源相册
$
(
"#housePicture"
).
click
(
function
(){
var
picDelet
=
$
(
"<font>"
).
append
(
"删除"
).
addClass
(
"picDelet"
);
var
file
=
$
(
"<input>"
).
attr
({
"type"
:
"file"
,
"name"
:
"files["
+
i
+
"]"
}).
addClass
(
"picFiles"
);
var
select
=
$
(
"<select>"
).
attr
(
"name"
,
"data["
+
i
+
"][type]"
);
{
%
for
item
in
photoType
%
}
select
.
append
(
$
(
"<option>"
).
attr
(
"value"
,{{
item
.
id
}}).
append
(
'{{item.value}}'
));
{
%
endfor
%
}
var
p
=
$
(
"<p>"
).
append
(
select
).
append
(
file
).
append
(
picDelet
);
$
(
"#picList"
).
append
(
p
);
i
++
});
//房源相册
$
(
"#picList"
).
on
(
"change"
,
".picFiles"
,
function
(){
readURL
(
this
,
2
);
$
(
this
).
hide
();
});
//删除房源相册、推荐房源、推荐置业顾问
$
(
"#houseImg,#consultantImg,#picList"
).
on
(
"click"
,
".imgCancel,.consultantCancel,.picDelet"
,
function
(){
$
(
this
).
parent
(
"p"
).
remove
();
});
$
(
"#submit"
).
click
(
function
(){
if
(
$
(
"#housename"
).
val
()
==
""
){
alert
(
"请输入楼盘名"
);
return
false
;
}
});
//file上传之前,显示图片的方法
function
readURL
(
input
,
type
)
{
if
(
type
==
1
){
if
(
input
.
files
&&
input
.
files
[
0
]){
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
var
img
=
$
(
"<img>"
).
attr
({
"id"
:
"target"
,
"src"
:
e
.
target
.
result
,
"heghit"
:
100
,
"width"
:
100
});
var
button
=
$
(
"<input>"
).
attr
({
"type"
:
"button"
,
"value"
:
"取消"
,
"property"
:
+
i
,
"id"
:
+
i
}).
addClass
(
"cancel"
);
var
type
=
$
(
"<input>"
).
attr
({
"type"
:
"hidden"
,
"name"
:
"data["
+
i
+
"][type]"
,
"value"
:
0
,
"property"
:
+
i
});
var
file
=
$
(
"<input>"
).
attr
({
"type"
:
"file"
,
"name"
:
"files["
+
(
i
+
1
)
+
"]"
,
"property"
:
+
(
i
+
1
)}).
addClass
(
"files"
);
var
select
=
$
(
"<select>"
).
attr
({
"name"
:
"data["
+
i
+
"][buildProperty]"
});
{
%
for
item
in
buildProperty
%
}{{
item
.
id
}}
select
.
append
(
$
(
"<option>"
).
attr
(
"value"
,{{
item
.
id
}}).
append
(
'{{item.value}}'
));
{
%
endfor
%
}
var
areatext
=
$
(
"<input>"
).
attr
({
"type"
:
"text"
,
"placeholder"
:
"面积"
,
"name"
:
"data["
+
i
+
"][housearea]"
}).
addClass
(
"regular-text"
);
var
div
=
$
(
"<div>"
).
append
(
select
).
append
(
areatext
).
append
(
button
).
append
(
type
);
var
span
=
$
(
"<span>"
).
attr
({
"property"
:
+
i
}).
append
(
img
).
append
(
div
);
$
(
"form"
).
find
(
"#preview > p"
).
before
(
file
);
$
(
"#preview > p"
).
append
(
span
);
i
++
;
}
}
}
else
{
if
(
input
.
files
&&
input
.
files
[
0
]){
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
){
var
img
=
$
(
"<img>"
).
attr
({
"src"
:
e
.
target
.
result
,
"heghit"
:
100
,
"width"
:
100
});
$
(
input
).
before
(
img
);
}
}
}
reader
.
readAsDataURL
(
input
.
files
[
0
]);
}
function
addOption
(
json
,
select
){
var
selectId
=
select
.
attr
(
"id"
);
for
(
var
i
=
0
;
i
<=
json
.
length
-
1
;
i
++
){
var
id
=
json
[
i
][
"id"
];
var
value
=
json
[
i
][
"value"
];
if
(
selectId
==
"acreage"
||
selectId
==
"price"
){
id
=
value
;
}
var
Option
=
$
(
"<option>"
).
attr
({
"value"
:
id
}).
append
(
value
);
select
.
append
(
Option
);
}
}
function
controlCommand
(
id
,
number
,
type
){
var
num
=
$
(
"#"
+
id
+
" > p"
).
length
;
if
(
num
>
number
){
if
(
type
==
0
){
alert
(
"最多只能推荐3个房源"
);
}
else
if
(
type
==
1
){
alert
(
"您只能推荐一位置业顾问"
);
}
$
(
"#"
+
id
).
find
(
"p:last-child"
).
remove
();
}
}
});
})(
jQuery
);
</script>
</body>
</html>
\ No newline at end of file
wp-content/plugins/tospur/Admin/views/secHandHouse.html
View file @
99b3aec2
<!DOCTYPE HTML>
<html>
<head>
{% set title = houseId?"修改二手房房源":"添加二手房房源" %}
<meta
charset=
"utf-8"
>
<title>
添加二手房房源
</title>
<title>
{{title}}
</title>
</head>
<body>
<h2
class=
"title"
>
添加二手房房源
</h2>
<h2
class=
"title"
>
{{title}}
</h2>
<form
action=
""
method=
"POST"
enctype=
"multipart/form-data"
>
<table
class=
"form-table"
>
<tbody>
<tr>
<th><label
for=
"housename"
>
房源名:
</label></th>
<td>
<input
name=
"housename"
id=
"housename"
type=
"text"
value=
""
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"community_name"
>
房源编号:
</label></th>
<td>
<input
name=
"house_number"
id=
"house_number"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"housename"
id=
"housename"
type=
"text"
value=
"{{result.name}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"total_price"
>
售价
</label></th>
<td>
<input
name=
"total_price"
id=
"total_price"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"total_price"
id=
"total_price"
type=
"text"
value=
"
{{result.total_price}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"average_price"
>
单价
</label></th>
<td>
<input
name=
"average_price"
id=
"average_price"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"average_price"
id=
"average_price"
type=
"text"
value=
"
{{result.average_price}}
"
class=
"regular-text code"
></td>
</tr>
</tbody>
</table>
...
...
@@ -34,44 +31,71 @@
<th><label
for=
"from"
>
户型
</label></th>
<td>
<select
id=
"buildproperty_id"
name=
"buildproperty_id"
>
<option
value=
"-1"
>
户型
</option>
{% for item in buildProperty %}
<option
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
<option
{{
item
.
id =
=
result
.
buildproperty_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<th><label
for=
"covered_area"
>
面积
</label></th>
<td>
<input
name=
"covered_area"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"covered_area"
type=
"text"
value=
"
{{result.covered_area}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
check_in_time
"
>
楼层:
</label></th>
<td>
<input
name=
"floor"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<th><label
for=
"
floor
"
>
楼层:
</label></th>
<td>
<input
name=
"floor"
type=
"text"
value=
"
{{result.floor}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
property_age
"
>
朝向:
</label></th>
<td>
<input
name=
"faceto"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<th><label
for=
"
faceto
"
>
朝向:
</label></th>
<td>
<input
name=
"faceto"
type=
"text"
value=
"
{{result.faceto}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"decoration"
>
装修状况
</label></th>
<td>
<input
name=
"decoration"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"decoration"
type=
"text"
value=
"{{result.decoration}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"age"
>
建筑年代
</label></th>
<td>
<input
name=
"age"
type=
"text"
value=
"{{result.age}}"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
acreage"
>
年代
</label></th>
<td>
<input
name=
"
age"
type=
"text"
value=
"
"
class=
"regular-text code"
></td>
<th><label
for=
"
flat"
>
楼号
</label></th>
<td>
<input
name=
"
flat"
type=
"text"
value=
"{{result.flat}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"
volume_rate"
>
楼号
</label></th>
<td>
<input
name=
"
flat"
type=
"text"
value=
"
"
class=
"regular-text code"
></td>
<th><label
for=
"
suite"
>
室
</label></th>
<td>
<input
name=
"
suite"
type=
"text"
value=
"{{result.suite}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"greening_rate"
>
室
</label></th>
<td>
<input
name=
"suite"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<th><label
for=
"overview"
>
房源点评
</label></th>
<td>
<textarea
name=
"overview"
rows=
"4"
cols=
"40"
class=
"large-text code"
>
{{result.overview}}
</textarea></td>
</tr>
<tr>
<th><label
for=
"property_money"
>
房源点评
</label></th>
<td>
<textarea
name=
"overview"
rows=
"4"
cols=
"40"
class=
"large-text code"
></textarea></td>
<th><label
for=
"from"
>
所属地区
</label></th>
<td>
<select
id=
"baseCity"
name=
"baseCity"
>
<option
value=
""
>
城市
</option>
{% for item in city %}
<option
{{
item
.
id =
=
result
.
city_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
</select>
<select
id=
"baseAreaId"
name=
"baseAreaId"
>
<option
value =
""
>
区域
</option>
{% if district %}
{% for item in district %}
<option
{{
item
.
id =
=
result
.
district_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
{% endif %}
</select>
<select
id=
"basePlateId"
name=
"basePlateId"
>
<option
value =
""
>
板块
</option>
{% if district %}
{% for item in plate %}
<option
{{
item
.
id =
=
result
.
plate_id
?"
selected
"
:
""
}}
value=
"{{ item.id }}"
>
{{ item.value }}
</option>
{% endfor %}
{% endif %}
</select>
</td>
</tr>
</tbody>
</table>
...
...
@@ -80,19 +104,19 @@
<tbody>
<tr>
<th><label
for=
"address"
>
地址
</label></th>
<td>
<input
name=
"address"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"address"
type=
"text"
value=
"
{{result.address}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"address"
>
小区名称
</label></th>
<td>
<input
name=
"community_name"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"community_name"
type=
"text"
value=
"
{{result.community_name}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"traffic"
>
交通线路
</label></th>
<td>
<input
name=
"traffic"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"traffic"
type=
"text"
value=
"
{{result.traffic}}
"
class=
"regular-text code"
></td>
</tr>
<tr>
<th><label
for=
"periphery"
>
周边配套
</label></th>
<td>
<input
name=
"periphery"
type=
"text"
value=
""
class=
"regular-text code"
></td>
<td>
<input
name=
"periphery"
type=
"text"
value=
"
{{result.periphery}}
"
class=
"regular-text code"
></td>
</tr>
</tbody>
</table>
...
...
@@ -110,7 +134,7 @@
</td>
</tr>
<tr>
<th><label
for=
"
traffic
"
>
推荐房源
</label></th>
<th><label
for=
"
recommend
"
>
推荐房源
</label></th>
<td>
<div
id=
"houseImg"
></div><br
/>
<button
type=
"button"
class=
"button action"
data-toggle=
"modal"
data-target=
"#myModal"
>
...
...
@@ -119,7 +143,7 @@
</td>
</tr>
<tr>
<th><label
for=
"
periphery
"
>
置业顾问
</label></th>
<th><label
for=
"
consultant
"
>
置业顾问
</label></th>
<td>
<div
id=
"consultantImg"
></div><br
/>
<button
type=
"button"
class=
"button action"
data-toggle=
"modal"
data-target=
"#myConsultant"
>
...
...
@@ -141,6 +165,10 @@
</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>
...
...
wp-content/plugins/tospur/Config.php
View file @
99b3aec2
...
...
@@ -3,6 +3,9 @@
class
Config
{
//table name
const
A_DISTRICT_AREA_TABLE
=
'a_district_area'
;
const
A_HOUSE_IMAGE_TABLE
=
'a_house_image'
;
const
A_HOUSE_RECOMMEND_TABLE
=
'a_house_recommend'
;
const
A_HOUSE_USER_TABLE
=
'a_house_user'
;
const
DIC_CITY_TABLE
=
'dic_city'
;
const
DIC_ROOM_TABLE
=
'dic_room'
;
const
DIC_BUILDPROPERTY_TABLE
=
'dic_buildproperty'
;
...
...
wp-content/plugins/tospur/Dao/InsertDao.php
View file @
99b3aec2
...
...
@@ -5,6 +5,9 @@ class InsertDao{
global
$wpdb
;
$houseRes
=
$wpdb
->
insert
(
Config
::
TOSPUR_HOUSE_TABLE
,
$params
);
$houseId
=
$wpdb
->
insert_id
;
if
(
!
SearchDao
::
setHouseNumber
(
$houseId
,
$params
[
'house_type'
],
$params
[
'city_id'
])){
return
510
;
}
if
(
$houseRes
){
return
$houseId
;
}
else
{
...
...
wp-content/plugins/tospur/Dao/SearchDao.php
View file @
99b3aec2
...
...
@@ -308,4 +308,154 @@ class SearchDao
global
$wpdb
;
return
$wpdb
->
get_results
(
$sql
);
}
public
static
function
setHouseNumber
(
$houseId
,
$houseType
,
$cityId
){
global
$wpdb
;
switch
(
$houseType
){
case
0
:
$prefix
=
"xf"
;
break
;
case
1
:
$prefix
=
"CS"
;
break
;
case
2
:
$prefix
=
"CZ"
;
break
;
}
$house_number
=
$prefix
.
str_pad
(
$cityId
,
4
,
'0'
,
STR_PAD_LEFT
)
.
str_pad
(
$houseId
,
8
,
'0'
,
STR_PAD_LEFT
);
return
$wpdb
->
update
(
Config
::
TOSPUR_HOUSE_TABLE
,
array
(
'house_number'
=>
$house_number
),
array
(
"id"
=>
$houseId
)
);
}
public
static
function
getDetailInfo
(
$hid
,
$type
=
NULL
){
global
$wpdb
;
$sql
=
"select * from "
.
Config
::
TOSPUR_HOUSE_TABLE
.
" where id = %d"
;
$result
=
$wpdb
->
get_row
(
$wpdb
->
prepare
(
$sql
,
$hid
));
$context
=
array
();
$context
[
'result'
]
=
$result
;
$houseType
=
$result
->
house_type
;
$context
[
'cityName'
]
=
SearchDao
::
getCityNameWithId
(
$result
->
city_id
);
$consultantLimit
=
1
;
if
(
$houseType
==
0
){
$consultantLimit
=
5
;
$mainImagesSql
=
"SELECT ti.id,ada.buildproperty_id,db.literal as type,ada.house_area as area,ti.path FROM "
.
Config
::
A_DISTRICT_AREA_TABLE
.
" ada
LEFT JOIN "
.
Config
::
DIC_BUILDPROPERTY_TABLE
.
" db on db.value = ada.buildproperty_id
LEFT JOIN "
.
Config
::
TOSPUR_IMAGE_TABLE
.
" ti on ti.id = ada.image_id
where ada.house_id = %d"
;
$mainImage
=
$wpdb
->
get_results
(
$wpdb
->
prepare
(
$mainImagesSql
,
$hid
));
foreach
(
$mainImage
as
$key
=>
$value
){
$value
->
path
=
Image
::
getImage
(
$value
->
path
,
'small'
);
}
$context
[
'mainImage'
]
=
$mainImage
;
}
$recommendSql
=
"select ahi.house_id as id,ti.path from a_house_image ahi
left join tospur_image ti on ahi.image_id = ti.id
where ti.image_type in (1,5) and house_id
in (select recommend_id from a_house_recommend where house_id = %d) group by house_id"
;
$recommends
=
$wpdb
->
get_results
(
$wpdb
->
prepare
(
$recommendSql
,
$hid
));
foreach
(
$recommends
as
$key
=>
$value
){
$value
->
path
=
Image
::
getImage
(
$value
->
path
,
'small'
);
}
$context
[
'recommends'
]
=
$recommends
;
$consultantSql
=
'select id,name,mobile,imageUrl,s.average_score from tospur_consultant c
LEFT JOIN (select consultant_id,sum(score)/count(score) as average_score
from tospur_consultant_score
where valid=1 group by consultant_id) s on c.id = s.consultant_id
where id in(select user_id from a_house_user where user_type = 1 and house_id = %d limit {$consultantLimit});'
;
$consultant
=
$wpdb
->
get_results
(
$wpdb
->
prepare
(
$consultantSql
,
$hid
));
$context
[
'consultant'
]
=
$consultant
;
if
(
$type
==
'edit'
){
$imagesSql
=
'select * from a_house_image ahi
LEFT JOIN tospur_image ti on ti.id = ahi.image_id
where ahi.house_id = %d and ahi.image_id not in (select image_id from a_district_area where house_id = %d);'
;
}
else
{
$imagesSql
=
'select * from tospur_image ti
LEFT JOIN a_house_image ahi on ti.id = ahi.image_id
WHERE ahi.house_id = %d order by image_type;'
;
}
$images
=
$wpdb
->
get_results
(
$wpdb
->
prepare
(
$imagesSql
,
$hid
,
$hid
));
foreach
(
$images
as
$key
=>
$value
){
$value
->
path
=
Image
::
getImage
(
$value
->
path
,
'big'
);
}
$context
[
'images'
]
=
$images
;
return
$context
;
}
public
static
function
addHouseTag
(
$tags
,
$house_id
)
{
global
$wpdb
;
$arr
=
array
(
','
=>
','
);
$in
=
explode
(
','
,
strtr
(
$tags
,
$arr
));
//string
$tags_string
=
SearchDao
::
arrayToString
(
$in
);
//房源的标签id数组
$tags_ids
=
array
();
//查询存在的标签
$sql
=
"select * from tospur_tag where name in "
.
$tags_string
;
$has_tags_result
=
$wpdb
->
get_results
(
$sql
);
//排除存在的标签,剩下未有的标签和存在标签id数组
foreach
(
$has_tags_result
as
$key
=>
$value
)
{
if
((
$key
=
array_search
(
$value
->
name
,
$in
))
!==
false
)
{
unset
(
$in
[
$key
]);
}
$tags_ids
[]
=
$value
->
id
;
}
//添加未有的标签
foreach
(
$in
as
$value
)
{
$insert
=
$wpdb
->
insert
(
'tospur_tag'
,
array
(
'name'
=>
$value
)
);
if
(
$insert
){
$tags_ids
[]
=
$wpdb
->
insert_id
;
}
}
//删除该房源的标签关联后,添加新的标签关联
$wpdb
->
delete
(
'a_house_tag'
,
array
(
'house_id'
=>
$house_id
)
);
foreach
(
$tags_ids
as
$value
)
{
$wpdb
->
insert
(
'a_house_tag'
,
array
(
'house_id'
=>
$house_id
,
'tag_id'
=>
$value
)
);
}
}
public
static
function
arrayToString
(
$array
)
{
$string
=
"("
;
$length
=
count
(
$array
);
$i
=
0
;
foreach
(
$array
as
$key
=>
$value
)
{
$i
++
;
$string
.=
"'"
.
$value
.
"'"
;
if
(
$i
!=
$length
)
{
$string
.=
","
;
}
}
$string
.=
")"
;
return
$string
;
}
}
\ No newline at end of file
wp-content/plugins/tospur/Tools/Core.php
0 → 100644
View file @
99b3aec2
<?php
require_once
(
PLUGIN_DIR
.
'Config.php'
);
class
Core
{
}
\ No newline at end of file
wp-content/plugins/tospur/index.php
View file @
99b3aec2
...
...
@@ -18,6 +18,7 @@ function tospur_init()
require_once
(
PLUGIN_DIR
.
'Admin/House.php'
);
require_once
(
PLUGIN_DIR
.
'Admin/newHouseList.php'
);
require_once
(
PLUGIN_DIR
.
'Admin/secHandHouse.php'
);
require_once
(
PLUGIN_DIR
.
'Admin/secHandHouseList.php'
);
require_once
(
'consultant_score.php'
);
require_once
(
'view_house.php'
);
add_action
(
'admin_menu'
,
'reset_menu'
);
...
...
@@ -130,7 +131,8 @@ 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
(
'secHandHouse'
,
'二手房'
,
'activate_plugins'
,
'secHandHouse'
,
'SecHandHouse::secHandHouse_html'
,
'dashicons-menu'
,
7
);
add_menu_page
(
'secHandHouseList'
,
'二手房列表'
,
'activate_plugins'
,
'secHandHouseList'
,
'secHandHouseList'
,
'dashicons-menu'
,
7
);
add_submenu_page
(
'secHandHouseList'
,
'newHouse_title'
,
'添加二手房'
,
'activate_plugins'
,
'secHandHouse'
,
'SecHandHouse::secHandHouse_html'
);
//移除更新信息
remove_action
(
'admin_notices'
,
'update_nag'
,
3
);
global
$menu
;
...
...
wp-content/themes/tospur/views/index.html
View file @
99b3aec2
...
...
@@ -196,6 +196,9 @@
tags
.
prepend
(
'<span class="label">'
+
v
+
'</span>'
);
});
}
div
.
bind
(
"tap"
,
function
(){
location
.
href
=
"{{site_url}}/?page=detail&hid="
+
value
.
id
;
});
scroller
.
append
(
div
);
});
searchData
.
index
+=
10
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment