Commit cffb3461 by felix

每日一更

parent f2df1629
...@@ -39,6 +39,7 @@ class Contract { ...@@ -39,6 +39,7 @@ class Contract {
$context['result'] = ContractDao::searchContract($id); $context['result'] = ContractDao::searchContract($id);
$context["consultant"] = CommissionDao::search_commission_consultant($id); $context["consultant"] = CommissionDao::search_commission_consultant($id);
$context["commission"] = CommissionDao::search_tospur_commission($id); $context["commission"] = CommissionDao::search_tospur_commission($id);
$context["img"] = ContractDao::searchContractImg($id);
$commissionIds = array(); $commissionIds = array();
foreach($context["commission"] as $item){ foreach($context["commission"] as $item){
$commissionIds[] = $item->id; $commissionIds[] = $item->id;
...@@ -61,6 +62,7 @@ class Contract { ...@@ -61,6 +62,7 @@ class Contract {
} }
private static function doSqlAction(){ private static function doSqlAction(){
date_default_timezone_set("Etc/GMT-8");
$params = array( $params = array(
'signedDate' =>$_REQUEST['signedDate'], 'signedDate' =>$_REQUEST['signedDate'],
'status' =>$_REQUEST['status'], 'status' =>$_REQUEST['status'],
...@@ -84,6 +86,7 @@ class Contract { ...@@ -84,6 +86,7 @@ class Contract {
); );
$commissionType = array(); $commissionType = array();
if(isset($_REQUEST["id"])){ if(isset($_REQUEST["id"])){
global $wpdb;
$result = ContractDao::update($_REQUEST["id"],$params); $result = ContractDao::update($_REQUEST["id"],$params);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
...@@ -94,17 +97,43 @@ class Contract { ...@@ -94,17 +97,43 @@ class Contract {
$status = 0; $status = 0;
}else if($params['status'] == 3){//成交 }else if($params['status'] == 3){//成交
$status = 2; $status = 2;
$params['dealTime'] = date("Y-m-d H:i:s");
$result = CustomerDao::updateCustomerStatue($_REQUEST['customerNumber'],1); $result = CustomerDao::updateCustomerStatue($_REQUEST['customerNumber'],1);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
} }
} }
$result = ContractDao::update($_REQUEST["id"],$params);
if(!is_numeric($result)){
return $result;
}
$result = HouseDao::updateStatus($status,$_REQUEST['id']); $result = HouseDao::updateStatus($status,$_REQUEST['id']);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
} }
$commissionType['buy'] = $_REQUEST['commissionId_buy']; $commissionType['buy'] = $_REQUEST['commissionId_buy'];
$commissionType['sell'] = $_REQUEST['commissionId_sell']; $commissionType['sell'] = $_REQUEST['commissionId_sell'];
$exists_photo_ids = array();
foreach($_REQUEST['exists_photo'] as $id => $item){
$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);
if($delete_photo_ids){
$path = ContractDao::searchImgPath($delete_photo_ids);
$wpdb->query("delete from ".Config::A_CONTRACT_IMAGE_TABLE." where contract_id = {$_REQUEST["id"]} and image_id in ({$delete_photo_ids});");
$wpdb->query("delete from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$delete_photo_ids});");
foreach($path as $value){
$url = substr_replace(__DIR__,$value->path,strpos(__DIR__,"wp",0)-1);
unlink($url);
}
}
ContractDao::insert_contract_image($_REQUEST["id"]);
}else{ }else{
$params['business'] = $_REQUEST['businessId']; $params['business'] = $_REQUEST['businessId'];
$params['houseNumber'] = $_REQUEST['houseNumber']; $params['houseNumber'] = $_REQUEST['houseNumber'];
...@@ -151,6 +180,9 @@ class Contract { ...@@ -151,6 +180,9 @@ class Contract {
return $result; return $result;
} }
$commissionType['sell'] = $result; $commissionType['sell'] = $result;
if( isset($_FILES['files'])){
ContractDao::insert_contract_image($contractId);
}
} }
if(isset( $_POST["log"])) { if(isset( $_POST["log"])) {
foreach ($_POST["log"] as $key => $value) { foreach ($_POST["log"] as $key => $value) {
......
...@@ -94,15 +94,15 @@ class House extends Tospur_House{ ...@@ -94,15 +94,15 @@ class House extends Tospur_House{
),array("image_id" => $id)); ),array("image_id" => $id));
$exist_ids[] = $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});");
} }
$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});");
InsertDao::addMainImage($houseId,$data); InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array(); $exists_photo_ids = array();
......
<?php
class Statistics {
public static function business(){
global $wpdb;
$today = date("Y-m-d");
$year = date("Y");
$month = date("m");
$today = "2015-09-24";
$month = 9;
$consultant = array();
$sql = "select count(name) as num,house_type ,user_id as consultantId from tospur_house
where house_type >0 and creattime >= '".$today."' and
creattime<DATE_SUB('".$today."', INTERVAL -1 DAY)
group by user_id,house_type;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
if(!$consultant[$item->user_id]){
$consultant[$item->user_id] = array();
}
$where = array(
"consultantId" => $item->user_id,
"date" => $today
);
$params = array();
$house_type = $item->house_type;
if($house_type == 1)
$params["newSell"] = $item->num;
if($house_type == 2)
$params["newLease"] = $item->num;
Statistics::updateBusiness($params,$where);
}
}
$sql = "select consultant_id,sum(if(new_house+secondHand_house>0,1,0)) as newBuy,sum(rent_house) as newTenant from tospur_customer
where time >= '".$today."'
and time<DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultant_id;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultant_id,
"date" => $today
);
$params = array(
"newBuy" => $item->newBuy,
"newTenant" => $item->newTenant
);
Statistics::updateBusiness($params,$where);
}
}
/* 效率高点? 由于数据少 待确认 少了sql的if判断,
* select consultant_id,sum(business) as business,sum(lease) as lease from (select consultant_id,1 as business,0 as lease,tct.time from tospur_customer_tracking tct
left join tospur_house th on th.id =tct.house_id
where th.house_type in(0,1)
union
select consultant_id,0 as business,1 as lease,tct.time from tospur_customer_tracking tct
left join tospur_house th on th.id =tct.house_id
where th.house_type = 2) t1
where time >= '2015-09-24'
and time < DATE_SUB('2015-09-24', INTERVAL -1 DAY)
group by consultant_id;
* */
$sql = "select tct.consultant_id,
sum(if(th.house_type<2,1,0)) as business,sum(if(th.house_type = 2 ,1,0)) as lease
from tospur_customer_tracking tct
left join tospur_house th on th.id =tct.house_id
where tct.time >= '".$today."'
and tct.time < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultant_id;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultant_id,
"date" => $today
);
$params = array(
"business" => $item->business,
"lease" => $item->lease
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select consultantId,sum(if(type = 0,1,0)) as dealBusiness,sum(if(type = 1,1,0)) as dealLease from tospur_commission tc
where contractId in(select id from tospur_contract where status = 3
and dealTime >= '".$today."'
and dealTime < DATE_SUB('".$today."', INTERVAL -1 DAY))
group by consultantId;";
$result = $wpdb->get_results($sql);
//print_r($wpdb->last_query);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultantId,
"date" => $today
);
$params = array(
"dealBusiness" => $item->dealBusiness,
"dealLease" => $item->dealLease
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select consultantId,quota from tospur_quota where year = ".$year." and month = ".$month.";";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultantId,
"date" => $today
);
$params = array(
"quota" => $item->quota
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select consultantId,sum(accounts) as accounts from
tospur_commission where mtime >= '".$today."'
and mtime < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultantId;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultantId,
"date" => $today
);
$params = array(
"accounts" => $item->accounts
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select tc.consultantId,sum(tcl.paid) as paid from tospur_commission tc
left join tospur_commission_log tcl on tc.id = tcl.commissionId
where time >= '".$today."'
and time < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by tc.consultantId;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultantId,
"date" => $today
);
$params = array(
"paid" => $item->paid
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select sum(if(house_type = 1,1,0)) sell,sum(if(house_type = 2,1,0)) lease,ahu.user_id as consultantId from a_house_user ahu
left join tospur_house th on th.id = ahu.house_id
where th.house_type > 0 and user_type = 1 group by ahu.user_id;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultantId,
"date" => $today
);
$params = array(
"stockSellH" => $item->sell,
"stockLeaseH" => $item->lease
);
Statistics::updateBusiness($params,$where);
}
}
$sql = "select consultant_id,sum(secondHand_house) as stockSellC,sum(rent_house) as stockLeaseC from tospur_customer where status = 0 group by consultant_id;";
$result = $wpdb->get_results($sql);
if(!$wpdb->last_error){
foreach($result as $item){
$where = array(
"consultantId" => $item->consultant_id,
"date" => $today
);
$params = array(
"stockSellC" => $item->stockSellC,
"stockLeaseC" => $item->stockLeaseC
);
Statistics::updateBusiness($params,$where);
}
}
}
public static function updateBusiness($params,$where){
global $wpdb;
$result = $wpdb->update(Config::STATISTICS_BUSINESS,$params,$where);
if($result === 0){
$result = $wpdb->get_row($wpdb->prepare("select * from ".Config::STATISTICS_BUSINESS." where consultantId=%d and date = %s",$where["consultantId"],$where["date"]));
if(!$result)
$wpdb->insert(Config::STATISTICS_BUSINESS,array_merge($params,$where));
}
}
}
\ No newline at end of file
...@@ -95,9 +95,9 @@ class commissionList extends WP_List_Table ...@@ -95,9 +95,9 @@ class commissionList extends WP_List_Table
"(business-businessPaid) as unBusinessPaid," . "(business-businessPaid) as unBusinessPaid," .
"(lease-leasePaid) as unLeasePaid" . "(lease-leasePaid) as unLeasePaid" .
" from (select consultantId,sum(accounts) as accounts,sum(case when t1.type = 0 then accounts else 0 end) business," . " from (select consultantId,sum(accounts) as accounts,sum(case when t1.type = 0 then accounts else 0 end) business," .
"sum(case when t1.type = 1 then accounts else 0 end) lease from (select consultantId,accounts,tcn.type from tospur_commission tcn" . "sum(case when t1.type = 1 then accounts else 0 end) lease from (select consultantId,sum(accounts) as accounts,tcn.type from tospur_commission tcn" .
" left join tospur_commission_log tcl on tcl.commissionId = tcn.id" . " left join tospur_commission_log tcl on tcl.commissionId = tcn.id" .
$commission_time_sql . " group by consultantId ) t1 group by consultantId) should" . $commission_time_sql . " group by consultantId,tcn.type ) t1 group by consultantId) should" .
" left join (select consultantId,sum(paid) as paid,sum(case when tcn.type = 0 then paid else 0 end) businessPaid," . " left join (select consultantId,sum(paid) as paid,sum(case when tcn.type = 0 then paid else 0 end) businessPaid," .
"sum(case when tcn.type = 1 then paid else 0 end) leasePaid from tospur_commission tcn" . "sum(case when tcn.type = 1 then paid else 0 end) leasePaid from tospur_commission tcn" .
" left join tospur_commission_log tcl on tcl.commissionId = tcn.id" . " left join tospur_commission_log tcl on tcl.commissionId = tcn.id" .
...@@ -119,6 +119,7 @@ class commissionList extends WP_List_Table ...@@ -119,6 +119,7 @@ class commissionList extends WP_List_Table
} }
$result = $wpdb->get_results($sql); $result = $wpdb->get_results($sql);
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$target_amount = 0; $target_amount = 0;
......
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
class introduction class introduction
{ {
public static function ajax_submit_introduction()
{
$time = $_POST['time'];
$introduction = $_POST['introduction'];
$user_id = $_POST['user_id'];
wp_send_json(introduction::submit_introduction($time, $introduction, $user_id));
}
public static function submit_introduction($time, $introduction, $user_id) public static function submit_introduction($time, $introduction, $user_id)
{ {
global $wpdb; global $wpdb;
...@@ -21,27 +13,65 @@ class introduction ...@@ -21,27 +13,65 @@ class introduction
), ),
array('id' => $user_id) array('id' => $user_id)
); );
if($wpdb->last_error){
return $wpdb->last_error;
}
return $result; return $result;
} }
public static function search_time_and_introduction() public static function updateQRcode($user_id,$url){
{
global $wpdb; global $wpdb;
$user_id = introduction::get_user_id(); $result = $wpdb->update(
$sql = "select time,introduction from " . Config::TOSPUR_CONSULTANT . " where id = " . $user_id; Config::TOSPUR_CONSULTANT,
$result = $wpdb->get_row($sql); array(
'QRcodeImg' => $url,
),
array('id' => $user_id)
);
if($wpdb->last_error){
return $wpdb->last_error;
}
return $result;
}
public static function search_consultant_results($user_id){
global $wpdb;
$sql = "select time,introduction,QRcodeImg from " . Config::TOSPUR_CONSULTANT . " where id = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$user_id));
if($wpdb->last_error){
return $wpdb->last_error;
}
return $result; return $result;
} }
public static function introduction_html() public static function introduction_html()
{ {
global $wpdb;
$user_id = introduction::get_user_id();
$context = array(); $context = array();
$type = $_POST["type"];
$context['siteUrl'] = get_site_url();
$context['url'] = home_url(); $context['url'] = home_url();
$result = introduction::search_time_and_introduction(); $result = introduction::search_consultant_results($user_id);
$context['time'] = $result->time; $context['result'] = $result;
$context['introduction'] = $result->introduction;
$user_id = introduction::get_user_id();
$context['user_id'] = $user_id; $context['user_id'] = $user_id;
if($type == 1){
$wpdb->query("START TRANSACTION");
if(!$_POST['oldImg']){
$url = substr_replace(__DIR__,$result->QRcodeImg,strpos(__DIR__,"wp",0)-1);
unlink($url);
}
$res = introduction::dosql();
if(!is_numeric($res)){
$wpdb->query("ROLLBACK");
echo $res;
echo "提交失败";
}else{
$wpdb->query("COMMIT");
echo "提交成功";
}
exit;
}
Timber::render('introduction.html', $context); Timber::render('introduction.html', $context);
} }
...@@ -50,6 +80,52 @@ class introduction ...@@ -50,6 +80,52 @@ class introduction
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
return $current_user->ID; return $current_user->ID;
} }
public static function dosql(){
global $wpdb;
$time = $_POST['time'];
$introduction = $_POST['introduction'];
$user_id = $_POST['user_id'];
$result = $wpdb->update(
Config::TOSPUR_CONSULTANT,
array(
'time' => $time,
'introduction' => $introduction
),
array('id' => $user_id)
);
if($wpdb->last_error){
return $wpdb->last_error;
}
if( isset($_FILES['files'])){
$uploadedfile = $_FILES['files'];
$uploadParam = array(
"name" => $uploadedfile["name"],
"type" => $uploadedfile["type"],
"tmp_name" => $uploadedfile["tmp_name"],
"error" => $uploadedfile["error"],
"size" => $uploadedfile["size"]
);
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'])) {
$result = introduction::updateQRcode($user_id,$url);
if (!is_numeric($result)) {
return $result;
}
} else {
return $movefile['error'];
}
}
return $result;
}
} }
?> ?>
\ No newline at end of file
...@@ -12,13 +12,13 @@ class newHouseList extends WP_List_Table ...@@ -12,13 +12,13 @@ class newHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$current_url = remove_query_arg(array('paged', 'type'), $current_url); $current_url = remove_query_arg(array('paged', 'status'), $current_url);
$sql = "select COUNT(*) as allNum, $sql = "select COUNT(*) as allNum,
COUNT(NULLIF(approval != -2, false)) as needCheckNum, COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum, COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum, COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum, COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as notSaleNum COUNT(NULLIF(status = 2, false)) as notSaleNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 0"; from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 0";
$result = $wpdb->get_results($sql); $result = $wpdb->get_results($sql);
foreach ($result as $value) { foreach ($result as $value) {
...@@ -31,14 +31,19 @@ class newHouseList extends WP_List_Table ...@@ -31,14 +31,19 @@ class newHouseList extends WP_List_Table
"notSaleNum" => $value->notSaleNum "notSaleNum" => $value->notSaleNum
); );
} }
return array( return array(
"allNum" => '<a href="' . $current_url . '&approval=" class="current">全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>', "allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>',
"needCheckNum" => '<a href="' . $current_url . '&approval=-2" class="current">需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>', "needCheckNum" => '<a href="' . $current_url . '&status=-2" '.($_REQUEST["status"]==-2?'class="current"':"").'>需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>', "unCheckNum" => '<a href="' . $current_url . '&status=0" '.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>', "checkNum" => '<a href="' . $current_url . '&status=1" '.($_REQUEST["status"]==1?'class="current"':"").'>审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>', "onSaleNum" => '<a href="' . $current_url . '&status=-1" '.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"notSaleNum" => '<a href="' . $current_url . '&approval=-1">下架<span class="count">(' . $approvalParam["notSaleNum"] . ')</span></a>' "notSaleNum" => '<a href="' . $current_url . '&status=2" '.($_REQUEST["status"]==2?'class="current"':"").'>下架<span class="count">(' . $approvalParam["notSaleNum"] . ')</span></a>'
); );
} }
function __construct() function __construct()
...@@ -80,9 +85,11 @@ class newHouseList extends WP_List_Table ...@@ -80,9 +85,11 @@ class newHouseList extends WP_List_Table
function column_cb($item) function column_cb($item)
{ {
return sprintf( return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s"/>', '<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'], /*$1%s*/
$item['id'] $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
); );
} }
...@@ -158,27 +165,33 @@ class newHouseList extends WP_List_Table ...@@ -158,27 +165,33 @@ class newHouseList extends WP_List_Table
global $wpdb; global $wpdb;
$flag = 0; $flag = 0;
$action = $this->current_action(); $action = $this->current_action();
$id = $_POST['sechandhouselist']; if ($action) {
if ($action && $id) {
$string = null; $string = null;
$approval = null; $approval = null;
switch ($action) { switch ($action) {
case"agree": case"agree":
$string = '(' . implode(',', array_map('intval', $id)) . ')'; $id = $_REQUEST['newhouselist'];
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); if ($id) {
foreach ($approvalRes as $value) { $string = '(' . implode(',', array_map('intval', $id)) . ')';
if ($value->approval == -2) { $approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
print_r("您审批的房源中含有未申请审批的房源,请重新选择"); foreach ($approvalRes as $value) {
exit; if ($value->approval == -2) {
print_r("您审批的房源中含有未申请审批的房源,请重新选择");
exit;
}
} }
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1;
} }
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1;
break; break;
case"goBack": case"goBack":
$string = '(' . implode(',', array_map('intval', $id)) . ')'; $id = $_REQUEST['newhouselist'];
$flag = 1; if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1;
}
break; break;
} }
if ($flag == 1) { if ($flag == 1) {
$wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string); $wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string);
...@@ -307,12 +320,15 @@ class newHouseList extends WP_List_Table ...@@ -307,12 +320,15 @@ class newHouseList extends WP_List_Table
$params[] = $_REQUEST["room"]; $params[] = $_REQUEST["room"];
$sql = $sql . " and room_id=%d"; $sql = $sql . " and room_id=%d";
} }
if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -1) { if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -3&& $_REQUEST["status"]!="") {
$params[] = $_REQUEST["status"]; $params[] = $_REQUEST["status"];
$sql = $sql . " and status=%d"; if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
} }
if ($_REQUEST["totalPrice"] != NULL) { if ($_REQUEST["totalPrice"] != NULL) {
$priceArray = explode("-", $_REQUEST['totalPrice']); $priceArray = explode("-", $_REQUEST['totalPrice']);
$params[] = $priceArray[0]; $params[] = $priceArray[0];
...@@ -326,15 +342,6 @@ class newHouseList extends WP_List_Table ...@@ -326,15 +342,6 @@ class newHouseList extends WP_List_Table
$sql = $sql . " and covered_area between %d and %d"; $sql = $sql . " and covered_area between %d and %d";
} }
if (isset($_REQUEST["approval"]) && $_REQUEST["approval"] != "") {
if ($_REQUEST["approval"] == -2) {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval != %d";
} else {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval = %d";
}
}
if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) { if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]); $time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
$params[] = $time[0]; $params[] = $time[0];
...@@ -353,6 +360,7 @@ class newHouseList extends WP_List_Table ...@@ -353,6 +360,7 @@ class newHouseList extends WP_List_Table
$sql = $sql . " and consul_name like %s"; $sql = $sql . " and consul_name like %s";
} }
$sql = $sql . " group by id"; $sql = $sql . " group by id";
if (isset($_REQUEST["orderby"])) { if (isset($_REQUEST["orderby"])) {
......
...@@ -71,7 +71,7 @@ class RentHouse extends Tospur_House{ ...@@ -71,7 +71,7 @@ class RentHouse extends Tospur_House{
$insert_tospur_house_array["status"] = 0; $insert_tospur_house_array["status"] = 0;
$insert_tospur_house_array["approval"] = 1; $insert_tospur_house_array["approval"] = 1;
$result = RentHouse::rentHouseData_insert($insert_tospur_house_array); $result = RentHouse::rentHouseData_insert($insert_tospur_house_array);
if (is_numeric($result)) { if (!is_numeric($result)) {
$wpdb->query("ROLLBACK"); $wpdb->query("ROLLBACK");
print_r($result); print_r($result);
echo "租房房源新增失败"; echo "租房房源新增失败";
......
...@@ -10,16 +10,16 @@ class rentHouseList extends WP_List_Table ...@@ -10,16 +10,16 @@ class rentHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$current_url = remove_query_arg(array('paged', 'type'), $current_url); $current_url = remove_query_arg(array('paged', 'status'), $current_url);
$sql = "select COUNT(*) as allNum, $sql = "select COUNT(*) as allNum,
COUNT(NULLIF(approval != -2, false)) as needCheckNum, COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum, COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum, COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum, COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as selfSaleNum, COUNT(NULLIF(status = 2, false)) as selfSaleNum,
COUNT(NULLIF(approval = 3, false)) as otherSaleNum, COUNT(NULLIF(status = 3, false)) as otherSaleNum,
COUNT(NULLIF(approval = 4, false)) as invalidNum, COUNT(NULLIF(status = 4, false)) as invalidNum,
COUNT(NULLIF(approval = 5, false)) as reactivationNum COUNT(NULLIF(status = 5, false)) as reactivationNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 2"; from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 2";
$result = $wpdb->get_results($sql); $result = $wpdb->get_results($sql);
foreach ($result as $value) { foreach ($result as $value) {
...@@ -36,15 +36,15 @@ class rentHouseList extends WP_List_Table ...@@ -36,15 +36,15 @@ class rentHouseList extends WP_List_Table
); );
} }
return array( return array(
"allNum" => '<a href="' . $current_url . '&approval" class="current">全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>', "allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>',
"needCheckNum" => '<a href="' . $current_url . '&approval=-2" class="current">需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>', "needCheckNum" => '<a href="' . $current_url . '&status=-2"'.($_REQUEST["status"]==-2?'class="current"':"").'>需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>', "unCheckNum" => '<a href="' . $current_url . '&status=0"'.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>', "checkNum" => '<a href="' . $current_url . '&status=1"'.($_REQUEST["status"]==1?'class="current"':"").'>审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>', "onSaleNum" => '<a href="' . $current_url . '&status=-1"'.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"selfSaleNum" => '<a href="' . $current_url . '&approval=2">自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>', "selfSaleNum" => '<a href="' . $current_url . '&status=2"'.($_REQUEST["status"]==2?'class="current"':"").'>自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>',
"otherSaleNum" => '<a href="' . $current_url . '&approval=3">他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>', "otherSaleNum" => '<a href="' . $current_url . '&status=3"'.($_REQUEST["status"]==3?'class="current"':"").'>他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>',
"invalidNum" => '<a href="' . $current_url . '&approval=4">无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>', "invalidNum" => '<a href="' . $current_url . '&status=4"'.($_REQUEST["status"]==4?'class="current"':"").'>无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>',
"reactivationNum" => '<a href="' . $current_url . '&approval=5">重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>', "reactivationNum" => '<a href="' . $current_url . '&status=5"'.($_REQUEST["status"]==5?'class="current"':"").'>重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
); );
} }
...@@ -156,15 +156,14 @@ class rentHouseList extends WP_List_Table ...@@ -156,15 +156,14 @@ class rentHouseList extends WP_List_Table
function manage_bulk_action() function manage_bulk_action()
{ {
global $wpdb; global $wpdb;
$flag = 0;
$action = $this->current_action(); $action = $this->current_action();
$id = $_REQUEST['renthouselist']; $id = $_REQUEST['renthouselist'];
if ($action && $id) { if ($action && $id) {
$string = null; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$approval = null; $approval = null;
$flag = 0;
switch ($action) { switch ($action) {
case"agree": case"agree":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); $approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) { foreach ($approvalRes as $value) {
if ($value->approval == -2) { if ($value->approval == -2) {
...@@ -176,7 +175,6 @@ class rentHouseList extends WP_List_Table ...@@ -176,7 +175,6 @@ class rentHouseList extends WP_List_Table
$flag = 1; $flag = 1;
break; break;
case"goBack": case"goBack":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1; $flag = 1;
break; break;
case "allot": case "allot":
...@@ -224,11 +222,10 @@ class rentHouseList extends WP_List_Table ...@@ -224,11 +222,10 @@ class rentHouseList extends WP_List_Table
global $wpdb; global $wpdb;
$id = $_REQUEST['renthouselist']; $id = $_REQUEST['renthouselist'];
if ($action && $id) { if ($action && $id) {
$string = null; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$status = null; $status = null;
switch ($action) { switch ($action) {
case 'unCheck': case 'unCheck':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 0); $res = $this->getCurrentStatus($string, 0);
if ($res === false) { if ($res === false) {
exit; exit;
...@@ -236,7 +233,6 @@ class rentHouseList extends WP_List_Table ...@@ -236,7 +233,6 @@ class rentHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
case 'check': case 'check':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 1); $res = $this->getCurrentStatus($string, 1);
if (!$res) { if (!$res) {
exit; exit;
...@@ -244,15 +240,13 @@ class rentHouseList extends WP_List_Table ...@@ -244,15 +240,13 @@ class rentHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
case 'selfSale': case 'selfSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 2); $res = $this->getCurrentStatus($string, 2);
if (!$res) { if (!$res) {
exit; exit;
} }
$status = 2; $status = $res;
break; break;
case 'otherSale': case 'otherSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 3); $res = $this->getCurrentStatus($string, 3);
if (!$res) { if (!$res) {
exit; exit;
...@@ -260,7 +254,6 @@ class rentHouseList extends WP_List_Table ...@@ -260,7 +254,6 @@ class rentHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
case 'invalid': case 'invalid':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 4); $res = $this->getCurrentStatus($string, 4);
if (!$res) { if (!$res) {
exit; exit;
...@@ -268,19 +261,13 @@ class rentHouseList extends WP_List_Table ...@@ -268,19 +261,13 @@ class rentHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
case 'reactivation': case 'reactivation':
$string = '(' . implode(',', array_map('intval', $id)) . ')'; $res = $this->getCurrentStatus($string, 5);
$res = $this->getCurrentStatus($string); if (!$res) {
foreach ($res as $value) { exit;
if ($value->status == 4) {
$status = 5;
} else {
print_r("只有无效房源可重激活,请重新选择");
exit;
}
} }
$status = $res;
break; break;
case 'onSale': case 'onSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, -1); $res = $this->getCurrentStatus($string, -1);
if (!$res) { if (!$res) {
exit; exit;
...@@ -289,7 +276,6 @@ class rentHouseList extends WP_List_Table ...@@ -289,7 +276,6 @@ class rentHouseList extends WP_List_Table
break; break;
} }
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status)); $result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
} }
} }
...@@ -340,9 +326,13 @@ class rentHouseList extends WP_List_Table ...@@ -340,9 +326,13 @@ class rentHouseList extends WP_List_Table
$params[] = $_REQUEST["room"]; $params[] = $_REQUEST["room"];
$sql = $sql . " and room_id=%d"; $sql = $sql . " and room_id=%d";
} }
if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -1) { if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -3&& $_REQUEST["status"]!="") {
$params[] = $_REQUEST["status"]; $params[] = $_REQUEST["status"];
$sql = $sql . " and status=%d"; if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
} }
if ($_REQUEST["rentalPrice"] != NULL) { if ($_REQUEST["rentalPrice"] != NULL) {
...@@ -357,15 +347,7 @@ class rentHouseList extends WP_List_Table ...@@ -357,15 +347,7 @@ class rentHouseList extends WP_List_Table
$params[] = $areaArray[1]; $params[] = $areaArray[1];
$sql = $sql . " and covered_area between %d and %d"; $sql = $sql . " and covered_area between %d and %d";
} }
if (isset($_REQUEST["approval"]) && $_REQUEST["approval"] != "") {
if ($_REQUEST["approval"] == -2) {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval != %d";
} else {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval = %d";
}
}
if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) { if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]); $time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
......
...@@ -9,16 +9,16 @@ class secHandHouseList extends WP_List_Table ...@@ -9,16 +9,16 @@ class secHandHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$current_url = remove_query_arg(array('paged', 'type'), $current_url); $current_url = remove_query_arg(array('paged', 'status'), $current_url);
$sql = "select COUNT(*) as allNum, $sql = "select COUNT(*) as allNum,
COUNT(NULLIF(approval != -2, false)) as needCheckNum, COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum, COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum, COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum, COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as selfSaleNum, COUNT(NULLIF(status = 2, false)) as selfSaleNum,
COUNT(NULLIF(approval = 3, false)) as otherSaleNum, COUNT(NULLIF(status = 3, false)) as otherSaleNum,
COUNT(NULLIF(approval = 4, false)) as invalidNum, COUNT(NULLIF(status = 4, false)) as invalidNum,
COUNT(NULLIF(approval = 5, false)) as reactivationNum COUNT(NULLIF(status = 5, false)) as reactivationNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 1"; from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 1";
$result = $wpdb->get_results($sql); $result = $wpdb->get_results($sql);
foreach ($result as $value) { foreach ($result as $value) {
...@@ -35,15 +35,15 @@ class secHandHouseList extends WP_List_Table ...@@ -35,15 +35,15 @@ class secHandHouseList extends WP_List_Table
); );
} }
return array( return array(
"allNum" => '<a href="' . $current_url . '&approval" class="current">全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>', "allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</span></a>',
"needCheckNum" => '<a href="' . $current_url . '&approval=-2" class="current">需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>', "needCheckNum" => '<a href="' . $current_url . '&status=-2"'.($_REQUEST["status"]==-2?'class="current"':"").'>需审批<span class="count">(' . $approvalParam["needCheckNum"] . ')</span></a>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>', "unCheckNum" => '<a href="' . $current_url . '&status=0"'.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>', "checkNum" => '<a href="' . $current_url . '&status=1"'.($_REQUEST["status"]==1?'class="current"':"").'>审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>', "onSaleNum" => '<a href="' . $current_url . '&status=-1"'.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"selfSaleNum" => '<a href="' . $current_url . '&approval=2">自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>', "selfSaleNum" => '<a href="' . $current_url . '&status=2"'.($_REQUEST["status"]==2?'class="current"':"").'>自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>',
"otherSaleNum" => '<a href="' . $current_url . '&approval=3">他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>', "otherSaleNum" => '<a href="' . $current_url . '&status=3"'.($_REQUEST["status"]==3?'class="current"':"").'>他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>',
"invalidNum" => '<a href="' . $current_url . '&approval=4">无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>', "invalidNum" => '<a href="' . $current_url . '&status=4"'.($_REQUEST["status"]==4?'class="current"':"").'>无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>',
"reactivationNum" => '<a href="' . $current_url . '&approval=5">重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>', "reactivationNum" => '<a href="' . $current_url . '&status=5"'.($_REQUEST["status"]==5?'class="current"':"").'>重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
); );
} }
...@@ -85,7 +85,7 @@ class secHandHouseList extends WP_List_Table ...@@ -85,7 +85,7 @@ class secHandHouseList extends WP_List_Table
'<input type="checkbox" name="%1$s[]" value="%2$s" data-consultant="%3$s"/>', '<input type="checkbox" name="%1$s[]" value="%2$s" data-consultant="%3$s"/>',
$this->_args['singular'], $this->_args['singular'],
$item['id'], $item['id'],
$item['consultant_id'] $item['consultant_id'] //The value of the checkbox should be the record's id
); );
} }
...@@ -159,11 +159,10 @@ class secHandHouseList extends WP_List_Table ...@@ -159,11 +159,10 @@ class secHandHouseList extends WP_List_Table
$action = $this->current_action(); $action = $this->current_action();
$id = $_REQUEST['sechandhouselist']; $id = $_REQUEST['sechandhouselist'];
if ($action && $id) { if ($action && $id) {
$string = null; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$approval = null; $approval = null;
switch ($action) { switch ($action) {
case"agree": case"agree":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); $approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) { foreach ($approvalRes as $value) {
if ($value->approval == -2) { if ($value->approval == -2) {
...@@ -175,7 +174,6 @@ class secHandHouseList extends WP_List_Table ...@@ -175,7 +174,6 @@ class secHandHouseList extends WP_List_Table
$flag = 1; $flag = 1;
break; break;
case"goBack": case"goBack":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1; $flag = 1;
break; break;
case "allot": case "allot":
...@@ -223,85 +221,62 @@ class secHandHouseList extends WP_List_Table ...@@ -223,85 +221,62 @@ class secHandHouseList extends WP_List_Table
if ($action) { if ($action) {
global $wpdb; global $wpdb;
$id = $_REQUEST['sechandhouselist']; $id = $_REQUEST['sechandhouselist'];
$string = null; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$status = null; $status = null;
if ($action == 'allot') { $flag = 0;
HouseDao::houseAllotConsultant($_POST['allot_consultant_id'], $_POST['sechandhouselist']); switch ($action) {
} else { case 'unCheck':
switch ($action) { $res = $this->getCurrentStatus($string, 0);
case 'unCheck': if ($res === false) {
if ($id) { exit;
$string = '(' . implode(',', array_map('intval', $id)) . ')'; }
$res = $this->getCurrentStatus($string, 0); $status = $res;
if ($res === false) { break;
exit; case 'check':
} $res = $this->getCurrentStatus($string, 1);
$status = $res; if (!$res) {
} exit;
break; }
case 'check': $status = $res;
if ($id) { break;
$string = '(' . implode(',', array_map('intval', $id)) . ')'; case 'selfSale':
$res = $this->getCurrentStatus($string, 1); $res = $this->getCurrentStatus($string, 2);
if (!$res) { if (!$res) {
exit; exit;
} }
$status = $res; $status = $res;
} break;
break; case 'otherSale':
case 'selfSale': $res = $this->getCurrentStatus($string, 3);
if ($id) { if (!$res) {
$string = '(' . implode(',', array_map('intval', $id)) . ')'; exit;
$res = $this->getCurrentStatus($string, 2); }
if (!$res) { $status = $res;
exit; break;
} case 'invalid':
$status = $res; $res = $this->getCurrentStatus($string, 4);
} if (!$res) {
break; exit;
case 'otherSale': }
if ($id) { $status = $res;
$string = '(' . implode(',', array_map('intval', $id)) . ')'; break;
$res = $this->getCurrentStatus($string, 3); case 'reactivation':
if (!$res) { $res = $this->getCurrentStatus($string, 5);
exit; if (!$res) {
} exit;
$status = $res; }
} $status = $res;
break; break;
case 'invalid': case 'onSale':
if ($id) { $res = $this->getCurrentStatus($string, -1);
$string = '(' . implode(',', array_map('intval', $id)) . ')'; if (!$res) {
$res = $this->getCurrentStatus($string, 4); exit;
if (!$res) { }
exit; $status = $res;
} break;
$status = $res;
}
break;
case 'reactivation':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 5);
if (!$res) {
exit;
}
$status = $res;
}
break;
case 'onSale':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, -1);
if (!$res) {
exit;
}
$status = $res;
}
break;
}
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
} }
if($flag == 0)
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
} }
} }
...@@ -352,9 +327,13 @@ class secHandHouseList extends WP_List_Table ...@@ -352,9 +327,13 @@ class secHandHouseList extends WP_List_Table
$sql = $sql . " and room_id=%d"; $sql = $sql . " and room_id=%d";
} }
if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -1) { if (isset($_REQUEST["status"]) && $_REQUEST["status"] != -3&& $_REQUEST["status"]!="") {
$params[] = $_REQUEST["status"]; $params[] = $_REQUEST["status"];
$sql = $sql . " and status=%d"; if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
} }
if ($_REQUEST["totalPrice"] != NULL) { if ($_REQUEST["totalPrice"] != NULL) {
...@@ -369,15 +348,7 @@ class secHandHouseList extends WP_List_Table ...@@ -369,15 +348,7 @@ class secHandHouseList extends WP_List_Table
$params[] = $areaArray[1]; $params[] = $areaArray[1];
$sql = $sql . " and covered_area between %d and %d"; $sql = $sql . " and covered_area between %d and %d";
} }
if (isset($_REQUEST["approval"]) && $_REQUEST["approval"] != "") {
if ($_REQUEST["approval"] == -2) {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval != %d";
} else {
$params[] = $_REQUEST["approval"];
$sql = $sql . " and approval = %d";
}
}
if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) { if ($_REQUEST["beginDate"] != NULL && $_REQUEST["endDate"] != NULL) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]); $time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
$params[] = $time[0]; $params[] = $time[0];
......
...@@ -106,6 +106,36 @@ ...@@ -106,6 +106,36 @@
<textarea name="codicil" id="codicil" rows="8" class="form-control" style="width:80%;">{{result.codicil}}</textarea> <textarea name="codicil" id="codicil" rows="8" class="form-control" style="width:80%;">{{result.codicil}}</textarea>
</div> </div>
</div> </div>
<br />
<div class="row">
<div class="col-md-8">
<table class="form-table">
<tbody id="contractPic">
{% set exists_photo_ids = "" %}
{% for item in img %}
{% if exists_photo_ids != "" %}
{% set exists_photo_ids = exists_photo_ids~"," %}
{% endif %}
{% set exists_photo_ids = exists_photo_ids~item.id %}
<tr>
<td>
<a href="{{siteUrl}}{{item.path}}" target="_blank"><img src="{{siteUrl}}{{item.path}}" height="90" width="140" ></a>
</td>
<td>
<input type="button" value="删除" class="button action existsCancel">
</td>
<input type="hidden" name="exists_photo[{{ item.id }}]">
</tr>
{% endfor %}
</tbody>
</table>
<button type="button" id="contractPicture" class="button action" data-toggle="modal" style="margin-top: 10px;margin-left: 15px">
添加合同图片
</button>
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div>
</div>
</div> </div>
<div role="tabpanel" class="tab-pane" id="soInfo"> <div role="tabpanel" class="tab-pane" id="soInfo">
<br /> <br />
...@@ -345,7 +375,7 @@ ...@@ -345,7 +375,7 @@
{% if commissionLog %} {% if commissionLog %}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">实收佣金列表</div> <div class="panel-heading">实收佣金列表</div>
<table class="table"> <table class="table" >
<tbody id="commissionList"> <tbody id="commissionList">
<tr> <tr>
<th>实收时间:</th> <th>实收时间:</th>
...@@ -392,7 +422,6 @@ ...@@ -392,7 +422,6 @@
</div> </div>
</div> </div>
</div> </div>
</form> </form>
{% include 'recConsultant.html' %} {% include 'recConsultant.html' %}
{{ block('recConsultant') }} {{ block('recConsultant') }}
...@@ -445,41 +474,41 @@ ...@@ -445,41 +474,41 @@
cPhone:'required' cPhone:'required'
}; };
$('#contract').validate({ // $('#contract').validate({
onkeyup: false, // onkeyup: false,
onfocusout: false, // onfocusout: false,
ignore: [], // ignore: [],
errorClass: "my-error-class", // errorClass: "my-error-class",
rules:rulesJson , // rules:rulesJson ,
messages: { // messages: {
houseNumber:'请选择房源', // houseNumber:'请选择房源',
customerNumber:'请选择客源', // customerNumber:'请选择客源',
businessId:'请选择业务类型', // businessId:'请选择业务类型',
permitNumber:'请选输入产证编号', // permitNumber:'请选输入产证编号',
area:'请选输入面积', // area:'请选输入面积',
price:'请选输入金额', // price:'请选输入金额',
signedDate:'请选输入签约日期', // signedDate:'请选输入签约日期',
'buy[accounts]':'请输入买方应收佣金', // 'buy[accounts]':'请输入买方应收佣金',
'sell[accounts]':'请输入卖方应收佣金', // 'sell[accounts]':'请输入卖方应收佣金',
oCommission:'请选业主佣金', // oCommission:'请选业主佣金',
oPhone:'请选业主手机', // oPhone:'请选业主手机',
cCommission:'请选买方佣金', // cCommission:'请选买方佣金',
cPhone:'请选买方手机' // cPhone:'请选买方手机'
}, // },
errorContainer: "#messageBox1", // errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1", // errorLabelContainer: "#messageBox1",
submitHandler: function (form) { // submitHandler: function (form) {
console.log($("input[name='sell[consultantId]']").val() == undefined); // console.log($("input[name='sell[consultantId]']").val() == undefined);
console.log($("input[name='buy[consultantId]']").val() == undefined); // console.log($("input[name='buy[consultantId]']").val() == undefined);
if($("input[name='sell[consultantId]']").val() == undefined && $("input[name='buy[consultantId]']").val() == undefined){ // if($("input[name='sell[consultantId]']").val() == undefined && $("input[name='buy[consultantId]']").val() == undefined){
$("#messageBox1").removeAttr("style"); // $("#messageBox1").removeAttr("style");
var label = $("<label>").append("请选择员工").addClass("my-error-class"); // var label = $("<label>").append("请选择员工").addClass("my-error-class");
$("#messageBox1").append(label); // $("#messageBox1").append(label);
return false; // return false;
} // }
form.submit(); // form.submit();
} // }
}); // });
var j = 0 ; var j = 0 ;
var urlParams = getUrlParmas(); var urlParams = getUrlParmas();
...@@ -628,6 +657,39 @@ ...@@ -628,6 +657,39 @@
var div2 = $("<div>").append(row).append(row2).append(recommendConsultant).css("display","inline-block"); var div2 = $("<div>").append(row).append(row2).append(recommendConsultant).css("display","inline-block");
clickButton.before(div2); clickButton.before(div2);
} }
var i = 0;
$("#contractPicture").click(function(){
var tr = $("<tr>");
var td = $("<td>");
var file = $("<input>").attr({"type":"file","name":"files[]"}).addClass("picFiles form-control");
var td2 = td.clone().append(file);
var picDelet = $("<input>").attr({"type":"button","value":"删除"}).addClass("button action existsCancel");
var td3 = td.clone().append(picDelet);
var input = $("<input>").attr({"type":"hidden","name":"exists_photo["+i+"]"});
tr.append(td2).append(td3).append(input);
$("#contractPic").append(tr);
i--;
});
$("#contractPic").on("change",".picFiles",function(){
var that = this;
if (this.files && this.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":90,"width":140});
var a = $("<a>").attr({"href":e.target.result,"target":"_blank"});
a.append(img);
$(that).before(a);
$(that).hide();
}
reader.readAsDataURL(this.files[0]);
}
});
$("#contractPic").on("click",".existsCancel",function(){
$(this).parent().parent().remove();
});
})(jQuery); })(jQuery);
</script> </script>
{% include 'recommendHouse.html' %} {% include 'recommendHouse.html' %}
......
...@@ -15,4 +15,8 @@ p[class^=col-]{ ...@@ -15,4 +15,8 @@ p[class^=col-]{
#preview,#addPhotos,#recHouseTable{ #preview,#addPhotos,#recHouseTable{
border-bottom: 1px solid; border-bottom: 1px solid;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
}
#photoTables th,#photoTables td{
text-align: center;
} }
\ No newline at end of file
...@@ -5,35 +5,80 @@ ...@@ -5,35 +5,80 @@
} }
</style> </style>
<h2>我的设置</h2> <h2>我的设置</h2>
<p> <form action="" method="POST" enctype="multipart/form-data">
<label for="time">入职时间:</label> <p>
<input type="date" id="time" value="{{ time }}"> <label for="time">入职时间:</label>
</p> <input type="date" name="time" value="{{ result.time }}">
<p> </p>
<label for="introduction" style="vertical-align: top;">诚信宣言:</label> <p>
<textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea> <label for="introduction" style="vertical-align: top;">诚信宣言:</label>
</p> <textarea name="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ result.introduction }}</textarea>
<p> </p>
<input type="hidden" id="user_id" value="{{ user_id }}"> <table class="form-table">
<input type="submit" id="submit" class="button"> <tbody id="QRcodeTable" >
</p> {% if result.QRcodeImg %}
<tr>
<td>
<img src=" {{siteUrl}}{{result.QRcodeImg}}" height="90" width="140" >
<input type="hidden" name="oldImg" value="1">
</td>
</tr>
{% endif %}
</tbody>
</table>
<p>
<button type="button" id="QRcode" class="button action" data-toggle="modal" style="margin-top: 10px">
微信二维码
</button>
</p>
<p>
<input type="hidden" name="user_id" value="{{ user_id }}">
<input type="hidden" name="type" value="1">
<input type="submit" class="button">
</p>
</form>
<script> <script>
(function ($) { (function ($) {
$(document).ready(function () { $(document).ready(function () {
$('#submit').click(function () { // $('#submit').click(function () {
var introduction = $('#introduction').val(); // var introduction = $('#introduction').val();
var time = $('#time').val(); // var time = $('#time').val();
var user_id = $('#user_id').val(); // var user_id = $('#user_id').val();
$.ajax({ // $.ajax({
type: 'POST', // type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/', // url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=submit_introduction&time=' + time + '&introduction=' + introduction + '&user_id=' + user_id, // data: 'action=submit_introduction&time=' + time + '&introduction=' + introduction + '&user_id=' + user_id,
success: function (data) { // success: function (data) {
if (data) { // if (data) {
alert('提交成功'); // alert('提交成功');
} // }
// }
// });
// });
$("#QRcode").click(function(){
if($("#QRcodeTable > tr").length > 0){
$("#QRcodeTable").find("tr").remove();
}
var tr = $("<tr>");
var td = $("<td>");
var file = $("<input>").attr({"type":"file","name":"files"}).addClass("picFiles form-control").css("width","20%");
var td2 = td.clone().css("width","30%").append(file);
tr.append(td2);
$("#QRcodeTable").append(tr);
});
$("#QRcodeTable").on("change",".picFiles",function(){
var that = this;
if (this.files && this.files[0]){
var reader = new FileReader();
reader.onload = function (e){
var img = $("<img>").attr({"src":e.target.result,"heghit":90,"width":140});
$(that).before(img);
$(that).hide();
} }
}); reader.readAsDataURL(this.files[0]);
}
}); });
}); });
})(jQuery); })(jQuery);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<tr> <tr>
<th class="col-md-2 text-center">跟进类型</th> <th class="col-md-2 text-center">跟进类型</th>
<th class="col-md-3 text-center">置业顾问</th> <th class="col-md-3 text-center">置业顾问</th>
<th class="col-md-3 text-center">时间</th> <th class="col-md-3 text-center">跟进时间</th>
<th class="col-md-4 text-center">跟进说明</th> <th class="col-md-4 text-center">跟进说明</th>
</tr> </tr>
{% for item in list %} {% for item in list %}
......
<div id="preview"> <div id="preview">
<table class="form-table"> <div class="row">
<tbody> <div class="col-md-2">
<tr> <label for="traffic" style="margin-left: 30px">主力房源:</label>
<th style="width:11.7%"><label for="traffic" style="margin-left: 30px">主力房源:</label></th> </div>
<td> <div class="col-md-10">
<input type="file" name="files[0]" property="0" class = "files form-control"multiple style="width: 30%;"> {% set exists_ids = "" %}
</td> {% for item in mainImage %}
</tr> {% if exists_ids != "" %}
</tbody> {% set exists_ids = exists_ids~"," %}
</table> {% endif %}
{% set exists_ids = "" %} {% set exists_ids = exists_ids~item.id %}
{% for item in mainImage %} <div class="row" style="margin-top:5px">
{% if exists_ids != "" %} <div class="col-md-3">
{% set exists_ids = exists_ids~"," %} <img src="{{siteUrl}}{{item.path}}" height="90" width="140">
{% endif %} </div>
{% set exists_ids = exists_ids~item.id %} <div class="col-md-3">
<div> <select name="exists[{{item.id}}][buildProperty]" class="form-control" style="height: 33px;width: 80%">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px;margin-top:10px"> {% for i in buildProperty %}
<select name="exists[{{item.id}}][buildProperty]" style="margin-right: 50px;width: 10%;display: inline-block" class="form-control"> <option {{ i.id == item.buildproperty_id?"selected":"" }} value="{{i.id}}">{{i.value}}</option>
{% for i in buildProperty %} {% endfor %}
<option {{ i.id == item.buildproperty_id?"selected":"" }} value="{{i.id}}">{{i.value}}</option> </select>
</div>
<div class="col-md-3">
<input type="text" placeholder="面积" name="exists[{{item.id}}][housearea]" class="form-control" value="{{item.area}}" style="width: 80%">
</div>
<div class="col-md-3">
<input type="button" value="删除" class="button action cancel existsCancel">
</div>
</div>
{% endfor %} {% endfor %}
</select> <input type="file" name="files[0]" property="0" class = "files form-control"multiple style="width: 30%;margin-top: 5px">
<input type="text" placeholder="面积" name="exists[{{item.id}}][housearea]" class="form-control" value="{{item.area}}" style="width: 100px;display:inline-block; margin-right: 50px"> <div id="mainHouseDiv"></div>
<input type="button" value="删除" class="button action cancel existsCancel" style="margin-top: 30px"> <input type="hidden" name="exists_ids" value="{{exists_ids}}" >
</div>
</div> </div>
{% endfor %}
<p></p>
<input type="hidden" name="exists_ids" value="{{exists_ids}}" >
</div> </div>
<script> <script>
...@@ -43,26 +46,36 @@ ...@@ -43,26 +46,36 @@
}); });
$("#preview").on("click",".cancel",function(){ $("#preview").on("click",".cancel",function(){
$(this).parent("div").remove(); $(this).parent().parent().remove();
}); });
}); });
//显示主力户型 //显示主力户型
function mainHouse(input,i){ function mainHouse(input,i){
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function (e) { reader.onload = function (e) {
var img = $("<img>").attr({"id":"target","src":e.target.result,"height":90,"width":140,"style":"margin-right:50px;margin-top:10px;"}); var div1 = $("<div>").addClass("col-md-3");
var img = $("<img>").attr({"id":"target","src":e.target.result,"height":90,"width":140});
div1.append(img);
var div2 = $("<div>").addClass("col-md-3");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]","style":"height:33px;width:80%"}).addClass("form-control");
div2.append(select);
var div3 = $("<div>").addClass("col-md-3");
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]","style":"width:80%"}).addClass("form-control");
div3.append(areatext);
var div4 = $("<div>").addClass("col-md-3");
var button = $("<input>").attr({"type":"button","value":"删除","property":+i,"id":+i}).addClass("button action cancel"); var button = $("<input>").attr({"type":"button","value":"删除","property":+i,"id":+i}).addClass("button action cancel");
div4.append(button);
var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":4,"property":+i}); var type = $("<input>").attr({"type":"hidden","name":"data["+i+"][type]","value":4,"property":+i});
var mainHousePic = $("<input>").attr({"type":"hidden","name":"data["+i+"][mainHouse]","value":0,"property":+i}); var mainHousePic = $("<input>").attr({"type":"hidden","name":"data["+i+"][mainHouse]","value":0,"property":+i});
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files form-control").css("width","20%"); var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files form-control").css({"width":"30%","margin-top":"10px"});
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]","style":"margin-right:50px;width:10%;display:inline-block"}).addClass("form-control");
{% for item in buildProperty %} {% for item in buildProperty %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}')); select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%} {% endfor%}
var areatext = $("<input>").attr({"type":"text","placeholder":"面积","name":"data["+i+"][housearea]","style":"width: 100px;display:inline-block;margin-right:50px"}).addClass("form-control");
var div = $("<div>").attr({"property":+i}).append(img).append(select).append(areatext).append(button).append(type).append(mainHousePic); var div = $("<div>").attr({"property":+i,"style":"margin-top:5px"}).addClass("row").append(div1).append(div2).append(div3).append(div4).append(type).append(mainHousePic);
$("form").find("#preview > p").after(file); $("form").find("#mainHouseDiv").after(file);
$("#preview > p").append(div); $("#mainHouseDiv").append(div);
} }
reader.readAsDataURL(input.files[0]); reader.readAsDataURL(input.files[0]);
......
...@@ -111,11 +111,14 @@ ...@@ -111,11 +111,14 @@
revertOption(json); revertOption(json);
var rulesJson = { var rulesJson = {
housename:'required', housename:'required',
average_price:'required',
mark:'required', mark:'required',
community_name:'required', community_name:'required',
address:'required', address:'required',
average_price:'required', covered_area:'required',
property_money:'required',
latest_news:'required',
overview:'required',
baseCity:{ baseCity:{
citySelectcheck: true citySelectcheck: true
}, },
...@@ -124,7 +127,11 @@ ...@@ -124,7 +127,11 @@
}, },
basePlateId:{ basePlateId:{
plateSelectcheck: true plateSelectcheck: true
},
baseRoom:{
roomSelectcheck:true
} }
}; };
{% if not canApproval %} {% if not canApproval %}
rulesJson.description = 'required'; rulesJson.description = 'required';
...@@ -139,12 +146,15 @@ ...@@ -139,12 +146,15 @@
rules: rulesJson, rules: rulesJson,
messages: { messages: {
housename:'请输入楼盘名称', housename:'请输入楼盘名称',
mark:'请输入标签',
community_name:'请输入小区名称', community_name:'请输入小区名称',
address:'请输入地址', mark:'请输入标签',
average_price:'请输入均价', average_price:'请输入均价',
address:'请输入地址',
description:'请输入跟进说明' description:'请输入跟进说明',
covered_area:'请输入建筑面积',
property_money:'请输入物业费',
latest_news:'请输入最新动态',
overview:'请输入楼盘概述'
}, },
errorContainer: "#messageBox1", errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1", errorLabelContainer: "#messageBox1",
...@@ -169,6 +179,10 @@ ...@@ -169,6 +179,10 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) { jQuery.validator.addMethod('plateSelectcheck', function (value) {
return (value != '-1'); return (value != '-1');
},"请选择板块"); },"请选择板块");
jQuery.validator.addMethod('roomSelectcheck', function (value) {
return (value != '-1');
},"请选择建筑类型");
}); });
})(jQuery); })(jQuery);
......
<div class="row" id="addPhotos"> <div id="addPhotos">
<div class="col-md-12"> <div class="row">
<table class="form-table" style="margin-left: 30px"> <div class="col-md-2">
<thead > <label for="photos" style="margin-left: 30px; margin-top: 25px">房源相册:</label>
<tr > </div>
<th >类型</th> <div class="col-md-10">
<th>相册</th> <table class="form-table" id="photoTables">
<th>设为封面</th> <thead>
<th></th> <tr>
</tr> <th>类型</th>
</thead> <th>相册</th>
<tbody id="photosTbody"> <th>设为封面</th>
{% set exists_photo_ids = "" %} <th></th>
{% for item in images %} </tr>
{% if exists_photo_ids != "" %} </thead>
{% set exists_photo_ids = exists_photo_ids~"," %} <tbody id="photosTbody">
{% endif %} {% set exists_photo_ids = "" %}
{% set exists_photo_ids = exists_photo_ids~item.image_id %} {% for item in images %}
<tr> {% if exists_photo_ids != "" %}
<td> {% set exists_photo_ids = exists_photo_ids~"," %}
<select name="exists_photo[{{ item.image_id }}][type]" style="margin-right: 50px"> {% endif %}
{% for i in photoType %} {% set exists_photo_ids = exists_photo_ids~item.image_id %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option> <tr>
{% endfor %} <td>
</select> <select name="exists_photo[{{ item.image_id }}][type]" style="width:38%;margin-left:30px" class="form-control" >
</td> {% for i in photoType %}
<td> <option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px"> {% endfor %}
</td> </select>
<td> </td>
<input type="radio" name="frontCover" style="margin-right: 50px" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} /> <td>
</td> <img src="{{siteUrl}}{{item.path}}" height="90" width="140" >
<td> </td>
<input type="button" value="删除" class="button action cancel existsCancel"> <td>
</td> <input type="radio" name="frontCover" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
</tr> </td>
{% endfor %} <td>
</tbody> <input type="button" value="删除" class="button action cancel existsCancel">
</table> </td>
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" > </tr>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px;margin-left: 30px"> {% endfor %}
</tbody>
</table>
</div>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px;margin-left: 225px">
新增 新增
</button> </button>
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div> </div>
</div> </div>
...@@ -51,7 +56,7 @@ ...@@ -51,7 +56,7 @@
$("#housePicture").click(function(){ $("#housePicture").click(function(){
var tr = $("<tr>"); var tr = $("<tr>");
var td = $("<td>"); var td = $("<td>");
var select = $("<select>").attr({"name":"data["+i+"][type]"}).addClass("form-control").css("width","30%"); var select = $("<select>").attr({"name":"data["+i+"][type]"}).addClass("form-control").css({"width":"38%","margin-left":"30px"});
{% for item in photoType %} {% for item in photoType %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}')); select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%} {% endfor%}
......
...@@ -51,7 +51,8 @@ ...@@ -51,7 +51,8 @@
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<div class="row" style="position: fixed;"> <div class="row" style="position: fixed;">
{% if (result.status != 2 and result.status != 3) %} {% if houseId %} {% if (result.status != 2 and result.status != 3) %}
{% if houseId %}
{% if canApproval %} {% if canApproval %}
{% if result.approval != -2 %} {% if result.approval != -2 %}
<select name="status" class="form-control"> <select name="status" class="form-control">
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,8 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<input type="submit" id="submit" class="button action" style="float:left"> <input type="submit" id="submit" class="button action" style="float:left">
{% endif %} </div> {% endif %}
</div>
</div> </div>
</div> </div>
</form> </form>
...@@ -110,24 +112,43 @@ ...@@ -110,24 +112,43 @@
"kitchen":"{{result.kitchen}}", "kitchen":"{{result.kitchen}}",
"balcony":"{{result.balcony}}" "balcony":"{{result.balcony}}"
}; };
revertOption(json);
var rulesJson = { {% if result is not null %}
revertOption(json);
{% endif %}
var rulesJson = {
housename:'required', housename:'required',
mark:'required', mark:'required',
rent:'required',
community_name:'required', community_name:'required',
suite:'required',
floor:'required',
totalFloor:'required',
covered_area:'required',
rent:'required',
overview:'required',
description:'required', description:'required',
matching_facilities:'required',
baseCity:{ baseCity:{
citySelectcheck: true citySelectcheck:true
}, },
baseAreaId:{ baseAreaId:{
areaSelectcheck: true areaSelectcheck:true
}, },
basePlateId:{ basePlateId:{
plateSelectcheck: true plateSelectcheck:true
},
roomNum:{
roomNumSelectcheck:true
},
baseRoom:{
baseRoomSelectcheck:true
},
decoration:{
decorationSelectcheck:true
} }
}; };
{% if not houseId %} {% if not houseId %}
rulesJson.owner_name = 'required'; rulesJson.owner_name = 'required';
rulesJson.owner_phone = 'required'; rulesJson.owner_phone = 'required';
...@@ -145,10 +166,16 @@ ...@@ -145,10 +166,16 @@
messages: { messages: {
housename:'请输入房源名称', housename:'请输入房源名称',
mark:'请输入标签', mark:'请输入标签',
suite:'请输入门牌号码',
owner_name:'请输入业主姓名', owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话', owner_phone:'请输入业主电话',
rent:'请输入租金', rent:'请输入租金',
covered_area:'请输入建筑面积',
floor:'请输入楼层',
totalFloor:'请输入总层',
matching_facilities:'请输入配套设施',
community_name:'请输入小区名称', community_name:'请输入小区名称',
overview:'请输入房源点评',
description:'请输入跟进说明' description:'请输入跟进说明'
}, },
errorContainer: "#messageBox1", errorContainer: "#messageBox1",
...@@ -174,6 +201,15 @@ ...@@ -174,6 +201,15 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) { jQuery.validator.addMethod('plateSelectcheck', function (value) {
return (value != '-1'); return (value != '-1');
},"请选择板块"); },"请选择板块");
jQuery.validator.addMethod('roomNumSelectcheck', function (value) {
return (value != '0');
},"请选择户型");
jQuery.validator.addMethod('baseRoomSelectcheck', function (value) {
return (value != '-1');
},"请选择建筑类型");
jQuery.validator.addMethod('decorationSelectcheck', function (value) {
return (value != '-1');
},"请选择装修程度");
}); });
})(jQuery); })(jQuery);
......
...@@ -116,25 +116,43 @@ ...@@ -116,25 +116,43 @@
"kitchen":"{{result.kitchen}}", "kitchen":"{{result.kitchen}}",
"balcony":"{{result.balcony}}" "balcony":"{{result.balcony}}"
}; };
revertOption(json); {% if result is not null %}
revertOption(json);
{% endif %}
var rulesJson = { var rulesJson = {
housename:'required', housename:'required',
mark:'required', mark:'required',
total_price:'required',
community_name:'required', community_name:'required',
suite:'required',
floor:'required',
totalFloor:'required',
covered_area:'required',
total_price:'required',
average_price:'required', average_price:'required',
latest_news:'required', overview:'required',
description:'required', description:'required',
garage:'required',
baseCity:{ baseCity:{
citySelectcheck: true citySelectcheck:true
}, },
baseAreaId:{ baseAreaId:{
areaSelectcheck: true areaSelectcheck:true
}, },
basePlateId:{ basePlateId:{
plateSelectcheck: true plateSelectcheck:true
},
roomNum:{
roomNumSelectcheck:true
},
baseRoom:{
baseRoomSelectcheck:true
},
decoration:{
decorationSelectcheck:true
} }
}; };
{% if not houseId %} {% if not houseId %}
rulesJson.owner_name = 'required'; rulesJson.owner_name = 'required';
...@@ -144,6 +162,7 @@ ...@@ -144,6 +162,7 @@
{% if not canApproval %} {% if not canApproval %}
rulesJson.description = 'required'; rulesJson.description = 'required';
{% endif %} {% endif %}
$('#secHouse').validate({ $('#secHouse').validate({
onkeyup: false, onkeyup: false,
onfocusout: false, onfocusout: false,
...@@ -153,11 +172,17 @@ ...@@ -153,11 +172,17 @@
messages: { messages: {
housename:'请输入房源名称', housename:'请输入房源名称',
mark:'请输入标签', mark:'请输入标签',
suite:'请输入门牌号码',
floor:'请输入楼层',
totalFloor:'请输入总层',
owner_name:'请输入业主姓名', owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话', owner_phone:'请输入业主电话',
total_price:'请输入售价', total_price:'请输入售价',
community_name:'请输入小区名称',
average_price:'请输入单价', average_price:'请输入单价',
covered_area:'请输入建筑面积',
community_name:'请输入小区名称',
garage:'请输入车库',
overview:'请输入房源点评',
description:'请输入跟进说明' description:'请输入跟进说明'
}, },
errorContainer: "#messageBox1", errorContainer: "#messageBox1",
...@@ -187,6 +212,15 @@ ...@@ -187,6 +212,15 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) { jQuery.validator.addMethod('plateSelectcheck', function (value) {
return (value != '-1'); return (value != '-1');
},"请选择板块"); },"请选择板块");
jQuery.validator.addMethod('roomNumSelectcheck', function (value) {
return (value != '0');
},"请选择户型");
jQuery.validator.addMethod('baseRoomSelectcheck', function (value) {
return (value != '-1');
},"请选择建筑类型");
jQuery.validator.addMethod('decorationSelectcheck', function (value) {
return (value != '-1');
},"请选择装修程度");
}); });
})(jQuery); })(jQuery);
......
...@@ -7,7 +7,7 @@ class Config { ...@@ -7,7 +7,7 @@ class Config {
const A_HOUSE_RECOMMEND_TABLE = 'a_house_recommend'; const A_HOUSE_RECOMMEND_TABLE = 'a_house_recommend';
const A_HOUSE_USER_TABLE = 'a_house_user'; const A_HOUSE_USER_TABLE = 'a_house_user';
const A_HOUSE_TAG_TABLE = 'a_house_tag'; const A_HOUSE_TAG_TABLE = 'a_house_tag';
const DIC_CITY_TABLE = 'dic_city'; const A_CONTRACT_IMAGE_TABLE = 'a_contract_image'; const DIC_CITY_TABLE = 'dic_city';
const DIC_ROOM_TABLE = 'dic_room'; const DIC_ROOM_TABLE = 'dic_room';
const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty'; const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty';
const DIC_AREA_TABLE = 'dic_area'; const DIC_AREA_TABLE = 'dic_area';
...@@ -31,6 +31,7 @@ class Config { ...@@ -31,6 +31,7 @@ class Config {
const TOSPUR_COMMISSION = 'tospur_commission'; const TOSPUR_COMMISSION = 'tospur_commission';
const TOSPUR_COMMISSION_LOG = 'tospur_commission_log'; const TOSPUR_COMMISSION_LOG = 'tospur_commission_log';
const TOSPUR_QUOTA_TABLE = 'tospur_quota'; const TOSPUR_QUOTA_TABLE = 'tospur_quota';
const STATISTICS_BUSINESS = 'statistics_business';
//sync url //sync url
......
...@@ -7,7 +7,6 @@ class ContractDao { ...@@ -7,7 +7,6 @@ class ContractDao {
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
print_r($wpdb->last_error);
return $wpdb->insert_id; return $wpdb->insert_id;
} }
...@@ -47,4 +46,85 @@ class ContractDao { ...@@ -47,4 +46,85 @@ class ContractDao {
return $wpdb->last_error; return $wpdb->last_error;
} }
} }
public static function insert_a_contract_image($params){
global $wpdb;
$wpdb->insert(Config::A_CONTRACT_IMAGE_TABLE,$params);
if($wpdb->last_error){
return $wpdb->last_error;
}
return $wpdb->insert_id;
}
public static function insert_contract_image($contractId){
$uploadedfile = $_FILES['files'];
if($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]
);
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' => 7
);
$result = InsertDao::insert_tospur_image($insert_image_array);
if (!is_numeric($result)) {
return $result;
}
$imgid = $result;
$contract_image_array = array(
"contract_id" => $contractId,
"image_id" => $imgid
);
$result = ContractDao::insert_a_contract_image($contract_image_array);
if (!is_numeric($result)) {
return $result;
}
} else {
return $movefile['error'];
}
}
}
}
public static function searchContractImg($id){
global $wpdb;
$sql = "select ti.id,ti.path from a_contract_image aci
left join tospur_contract tc on tc.id = aci.contract_id
left join tospur_image ti on aci.image_id = ti.id where aci.contract_id = %d;";
$result = $wpdb->get_results($wpdb->prepare($sql,$id));
if($wpdb->last_error){
return $wpdb->last_error;
}
return $result;
}
public static function searchImgPath($id){
global $wpdb;
$sql = "select path from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$id})";
$results = $wpdb->get_results($sql);
if($wpdb->last_error){
return $wpdb->last_error;
}
return $results;
}
} }
\ No newline at end of file
...@@ -379,7 +379,9 @@ class SearchDao ...@@ -379,7 +379,9 @@ class SearchDao
$mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid)); $mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid));
foreach($mainImage as $key => $value){ foreach($mainImage as $key => $value){
$value->path = Image::getImage($value->path,'big'); $path = $value->path;
$value->path = Image::getImage($path,'big');
$value->smallPath = Image::getImage($path,'small');
} }
$context['mainImage'] = $mainImage; $context['mainImage'] = $mainImage;
...@@ -424,11 +426,12 @@ class SearchDao ...@@ -424,11 +426,12 @@ class SearchDao
} }
$images = $wpdb->get_results($wpdb->prepare($imagesSql,$hid,$hid)); $images = $wpdb->get_results($wpdb->prepare($imagesSql,$hid,$hid));
foreach($images as $key => $value){ foreach($images as $key => $value){
$value->path = Image::getImage($value->path,'big'); $path = $value->path;
$value->path = Image::getImage($path,'big');
$context['normalImages'][]->path = Image::getImage($path,'normal');
} }
$context['images'] = $images; $context['images'] = $images;
return $context; return $context;
} }
......
...@@ -45,6 +45,9 @@ function tospur_init() ...@@ -45,6 +45,9 @@ function tospur_init()
require_once(PLUGIN_DIR . 'Admin/Contract_List.php'); require_once(PLUGIN_DIR . 'Admin/Contract_List.php');
require_once(PLUGIN_DIR . 'Admin/commissionManage.php'); require_once(PLUGIN_DIR . 'Admin/commissionManage.php');
require_once(PLUGIN_DIR . 'Admin/commissionList.php'); require_once(PLUGIN_DIR . 'Admin/commissionList.php');
require_once(PLUGIN_DIR . 'Admin/Statistics.php');
//Statistics::business();
add_action('admin_menu', 'reset_menu'); add_action('admin_menu', 'reset_menu');
tospur_register_script_style(); tospur_register_script_style();
tospur_ajax_set(); tospur_ajax_set();
......
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