Commit cffb3461 by felix

每日一更

parent f2df1629
......@@ -39,6 +39,7 @@ class Contract {
$context['result'] = ContractDao::searchContract($id);
$context["consultant"] = CommissionDao::search_commission_consultant($id);
$context["commission"] = CommissionDao::search_tospur_commission($id);
$context["img"] = ContractDao::searchContractImg($id);
$commissionIds = array();
foreach($context["commission"] as $item){
$commissionIds[] = $item->id;
......@@ -61,6 +62,7 @@ class Contract {
}
private static function doSqlAction(){
date_default_timezone_set("Etc/GMT-8");
$params = array(
'signedDate' =>$_REQUEST['signedDate'],
'status' =>$_REQUEST['status'],
......@@ -84,6 +86,7 @@ class Contract {
);
$commissionType = array();
if(isset($_REQUEST["id"])){
global $wpdb;
$result = ContractDao::update($_REQUEST["id"],$params);
if(!is_numeric($result)){
return $result;
......@@ -94,17 +97,43 @@ class Contract {
$status = 0;
}else if($params['status'] == 3){//成交
$status = 2;
$params['dealTime'] = date("Y-m-d H:i:s");
$result = CustomerDao::updateCustomerStatue($_REQUEST['customerNumber'],1);
if(!is_numeric($result)){
return $result;
}
}
$result = ContractDao::update($_REQUEST["id"],$params);
if(!is_numeric($result)){
return $result;
}
$result = HouseDao::updateStatus($status,$_REQUEST['id']);
if(!is_numeric($result)){
return $result;
}
$commissionType['buy'] = $_REQUEST['commissionId_buy'];
$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{
$params['business'] = $_REQUEST['businessId'];
$params['houseNumber'] = $_REQUEST['houseNumber'];
......@@ -151,6 +180,9 @@ class Contract {
return $result;
}
$commissionType['sell'] = $result;
if( isset($_FILES['files'])){
ContractDao::insert_contract_image($contractId);
}
}
if(isset( $_POST["log"])) {
foreach ($_POST["log"] as $key => $value) {
......
......@@ -94,6 +94,7 @@ class House extends Tospur_House{
),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){
......@@ -102,7 +103,6 @@ class House extends Tospur_House{
$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);
$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
"(business-businessPaid) as unBusinessPaid," .
"(lease-leasePaid) as unLeasePaid" .
" 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" .
$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," .
"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" .
......@@ -119,6 +119,7 @@ class commissionList extends WP_List_Table
}
$result = $wpdb->get_results($sql);
$data = array();
foreach ($result as $key => $value) {
$target_amount = 0;
......
......@@ -2,14 +2,6 @@
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)
{
global $wpdb;
......@@ -21,27 +13,65 @@ class introduction
),
array('id' => $user_id)
);
if($wpdb->last_error){
return $wpdb->last_error;
}
return $result;
}
public static function search_time_and_introduction()
{
public static function updateQRcode($user_id,$url){
global $wpdb;
$user_id = introduction::get_user_id();
$sql = "select time,introduction from " . Config::TOSPUR_CONSULTANT . " where id = " . $user_id;
$result = $wpdb->get_row($sql);
$result = $wpdb->update(
Config::TOSPUR_CONSULTANT,
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;
}
public static function introduction_html()
{
global $wpdb;
$user_id = introduction::get_user_id();
$context = array();
$type = $_POST["type"];
$context['siteUrl'] = get_site_url();
$context['url'] = home_url();
$result = introduction::search_time_and_introduction();
$context['time'] = $result->time;
$context['introduction'] = $result->introduction;
$user_id = introduction::get_user_id();
$result = introduction::search_consultant_results($user_id);
$context['result'] = $result;
$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);
}
......@@ -50,6 +80,52 @@ class introduction
$current_user = wp_get_current_user();
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
{
global $wpdb;
$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,
COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as notSaleNum
COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(status = 2, false)) as notSaleNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 0";
$result = $wpdb->get_results($sql);
foreach ($result as $value) {
......@@ -31,14 +31,19 @@ class newHouseList extends WP_List_Table
"notSaleNum" => $value->notSaleNum
);
}
return array(
"allNum" => '<a href="' . $current_url . '&approval=" 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>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"notSaleNum" => '<a href="' . $current_url . '&approval=-1">下架<span class="count">(' . $approvalParam["notSaleNum"] . ')</span></a>'
"allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</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 . '&status=0" '.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</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 . '&status=-1" '.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"notSaleNum" => '<a href="' . $current_url . '&status=2" '.($_REQUEST["status"]==2?'class="current"':"").'>下架<span class="count">(' . $approvalParam["notSaleNum"] . ')</span></a>'
);
}
function __construct()
......@@ -80,9 +85,11 @@ class newHouseList extends WP_List_Table
function column_cb($item)
{
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s"/>',
$this->_args['singular'],
$item['id']
'<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
);
}
......@@ -158,12 +165,13 @@ class newHouseList extends WP_List_Table
global $wpdb;
$flag = 0;
$action = $this->current_action();
$id = $_POST['sechandhouselist'];
if ($action && $id) {
if ($action) {
$string = null;
$approval = null;
switch ($action) {
case"agree":
$id = $_REQUEST['newhouselist'];
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) {
......@@ -174,11 +182,16 @@ class newHouseList extends WP_List_Table
}
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1;
}
break;
case"goBack":
$id = $_REQUEST['newhouselist'];
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1;
}
break;
}
if ($flag == 1) {
$wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string);
......@@ -307,11 +320,14 @@ class newHouseList extends WP_List_Table
$params[] = $_REQUEST["room"];
$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"];
if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
}
if ($_REQUEST["totalPrice"] != NULL) {
$priceArray = explode("-", $_REQUEST['totalPrice']);
......@@ -326,15 +342,6 @@ class newHouseList extends WP_List_Table
$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) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
$params[] = $time[0];
......@@ -353,6 +360,7 @@ class newHouseList extends WP_List_Table
$sql = $sql . " and consul_name like %s";
}
$sql = $sql . " group by id";
if (isset($_REQUEST["orderby"])) {
......
......@@ -71,7 +71,7 @@ class RentHouse extends Tospur_House{
$insert_tospur_house_array["status"] = 0;
$insert_tospur_house_array["approval"] = 1;
$result = RentHouse::rentHouseData_insert($insert_tospur_house_array);
if (is_numeric($result)) {
if (!is_numeric($result)) {
$wpdb->query("ROLLBACK");
print_r($result);
echo "租房房源新增失败";
......
......@@ -10,16 +10,16 @@ class rentHouseList extends WP_List_Table
{
global $wpdb;
$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,
COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as selfSaleNum,
COUNT(NULLIF(approval = 3, false)) as otherSaleNum,
COUNT(NULLIF(approval = 4, false)) as invalidNum,
COUNT(NULLIF(approval = 5, false)) as reactivationNum
COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(status = 2, false)) as selfSaleNum,
COUNT(NULLIF(status = 3, false)) as otherSaleNum,
COUNT(NULLIF(status = 4, false)) as invalidNum,
COUNT(NULLIF(status = 5, false)) as reactivationNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 2";
$result = $wpdb->get_results($sql);
foreach ($result as $value) {
......@@ -36,15 +36,15 @@ class rentHouseList extends WP_List_Table
);
}
return array(
"allNum" => '<a href="' . $current_url . '&approval" 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>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"selfSaleNum" => '<a href="' . $current_url . '&approval=2">自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>',
"otherSaleNum" => '<a href="' . $current_url . '&approval=3">他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>',
"invalidNum" => '<a href="' . $current_url . '&approval=4">无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>',
"reactivationNum" => '<a href="' . $current_url . '&approval=5">重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
"allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</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 . '&status=0"'.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</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 . '&status=-1"'.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</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 . '&status=3"'.($_REQUEST["status"]==3?'class="current"':"").'>他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</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 . '&status=5"'.($_REQUEST["status"]==5?'class="current"':"").'>重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
);
}
......@@ -156,15 +156,14 @@ class rentHouseList extends WP_List_Table
function manage_bulk_action()
{
global $wpdb;
$flag = 0;
$action = $this->current_action();
$id = $_REQUEST['renthouselist'];
if ($action && $id) {
$string = null;
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approval = null;
$flag = 0;
switch ($action) {
case"agree":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) {
if ($value->approval == -2) {
......@@ -176,7 +175,6 @@ class rentHouseList extends WP_List_Table
$flag = 1;
break;
case"goBack":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1;
break;
case "allot":
......@@ -224,11 +222,10 @@ class rentHouseList extends WP_List_Table
global $wpdb;
$id = $_REQUEST['renthouselist'];
if ($action && $id) {
$string = null;
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$status = null;
switch ($action) {
case 'unCheck':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 0);
if ($res === false) {
exit;
......@@ -236,7 +233,6 @@ class rentHouseList extends WP_List_Table
$status = $res;
break;
case 'check':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 1);
if (!$res) {
exit;
......@@ -244,15 +240,13 @@ class rentHouseList extends WP_List_Table
$status = $res;
break;
case 'selfSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 2);
if (!$res) {
exit;
}
$status = 2;
$status = $res;
break;
case 'otherSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 3);
if (!$res) {
exit;
......@@ -260,7 +254,6 @@ class rentHouseList extends WP_List_Table
$status = $res;
break;
case 'invalid':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 4);
if (!$res) {
exit;
......@@ -268,19 +261,13 @@ class rentHouseList extends WP_List_Table
$status = $res;
break;
case 'reactivation':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string);
foreach ($res as $value) {
if ($value->status == 4) {
$status = 5;
} else {
print_r("只有无效房源可重激活,请重新选择");
$res = $this->getCurrentStatus($string, 5);
if (!$res) {
exit;
}
}
$status = $res;
break;
case 'onSale':
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, -1);
if (!$res) {
exit;
......@@ -289,7 +276,6 @@ class rentHouseList extends WP_List_Table
break;
}
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
}
}
......@@ -340,10 +326,14 @@ class rentHouseList extends WP_List_Table
$params[] = $_REQUEST["room"];
$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"];
if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
}
if ($_REQUEST["rentalPrice"] != NULL) {
$priceArray = explode("-", $_REQUEST['rentalPrice']);
......@@ -357,15 +347,7 @@ class rentHouseList extends WP_List_Table
$params[] = $areaArray[1];
$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) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
......
......@@ -9,16 +9,16 @@ class secHandHouseList extends WP_List_Table
{
global $wpdb;
$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,
COUNT(NULLIF(approval != -2, false)) as needCheckNum,
COUNT(NULLIF(approval = 0, false)) as unCheckNum,
COUNT(NULLIF(approval = 1, false)) as checkNum,
COUNT(NULLIF(approval = -1, false)) as onSaleNum,
COUNT(NULLIF(approval = 2, false)) as selfSaleNum,
COUNT(NULLIF(approval = 3, false)) as otherSaleNum,
COUNT(NULLIF(approval = 4, false)) as invalidNum,
COUNT(NULLIF(approval = 5, false)) as reactivationNum
COUNT(NULLIF(status = 0, false)) as unCheckNum,
COUNT(NULLIF(status = 1, false)) as checkNum,
COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(status = 2, false)) as selfSaleNum,
COUNT(NULLIF(status = 3, false)) as otherSaleNum,
COUNT(NULLIF(status = 4, false)) as invalidNum,
COUNT(NULLIF(status = 5, false)) as reactivationNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 1";
$result = $wpdb->get_results($sql);
foreach ($result as $value) {
......@@ -35,15 +35,15 @@ class secHandHouseList extends WP_List_Table
);
}
return array(
"allNum" => '<a href="' . $current_url . '&approval" 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>',
"unCheckNum" => '<a href="' . $current_url . '&approval=0">未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</span></a>',
"checkNum" => '<a href="' . $current_url . '&approval=1">审核<span class="count">(' . $approvalParam["checkNum"] . ')</span></a>',
"onSaleNum" => '<a href="' . $current_url . '&approval=-1">交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</span></a>',
"selfSaleNum" => '<a href="' . $current_url . '&approval=2">自售<span class="count">(' . $approvalParam["selfSaleNum"] . ')</span></a>',
"otherSaleNum" => '<a href="' . $current_url . '&approval=3">他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</span></a>',
"invalidNum" => '<a href="' . $current_url . '&approval=4">无效<span class="count">(' . $approvalParam["invalidNum"] . ')</span></a>',
"reactivationNum" => '<a href="' . $current_url . '&approval=5">重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
"allNum" => '<a href="' . $current_url . '"'.(isset($_REQUEST["status"])?"":' class="current"').'>全部<span class="count">(' . $approvalParam["allNum"] . ')</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 . '&status=0"'.($_REQUEST["status"]=="0"?'class="current"':"").'>未审核<span class="count">(' . $approvalParam["unCheckNum"] . ')</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 . '&status=-1"'.($_REQUEST["status"]==-1?'class="current"':"").'>交易中<span class="count">(' . $approvalParam["onSaleNum"] . ')</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 . '&status=3"'.($_REQUEST["status"]==3?'class="current"':"").'>他售<span class="count">(' . $approvalParam["otherSaleNum"] . ')</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 . '&status=5"'.($_REQUEST["status"]==5?'class="current"':"").'>重激活<span class="count">(' . $approvalParam["reactivationNum"] . ')</span></a>',
);
}
......@@ -85,7 +85,7 @@ class secHandHouseList extends WP_List_Table
'<input type="checkbox" name="%1$s[]" value="%2$s" data-consultant="%3$s"/>',
$this->_args['singular'],
$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
$action = $this->current_action();
$id = $_REQUEST['sechandhouselist'];
if ($action && $id) {
$string = null;
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approval = null;
switch ($action) {
case"agree":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) {
if ($value->approval == -2) {
......@@ -175,7 +174,6 @@ class secHandHouseList extends WP_List_Table
$flag = 1;
break;
case"goBack":
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$flag = 1;
break;
case "allot":
......@@ -223,87 +221,64 @@ class secHandHouseList extends WP_List_Table
if ($action) {
global $wpdb;
$id = $_REQUEST['sechandhouselist'];
$string = null;
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$status = null;
if ($action == 'allot') {
HouseDao::houseAllotConsultant($_POST['allot_consultant_id'], $_POST['sechandhouselist']);
} else {
$flag = 0;
switch ($action) {
case 'unCheck':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 0);
if ($res === false) {
exit;
}
$status = $res;
}
break;
case 'check':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 1);
if (!$res) {
exit;
}
$status = $res;
}
break;
case 'selfSale':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 2);
if (!$res) {
exit;
}
$status = $res;
}
break;
case 'otherSale':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 3);
if (!$res) {
exit;
}
$status = $res;
}
break;
case 'invalid':
if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')';
$res = $this->getCurrentStatus($string, 4);
if (!$res) {
exit;
}
$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;
}
if($flag == 0)
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
}
}
}
function prepare_items()
......@@ -352,10 +327,14 @@ class secHandHouseList extends WP_List_Table
$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"];
if($_REQUEST["status"] == -2){
$sql = $sql . " and approval != %d";
}else{
$sql = $sql . " and status=%d";
}
}
if ($_REQUEST["totalPrice"] != NULL) {
$priceArray = explode("-", $_REQUEST['totalPrice']);
......@@ -369,15 +348,7 @@ class secHandHouseList extends WP_List_Table
$params[] = $areaArray[1];
$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) {
$time = array($_REQUEST["beginDate"], $_REQUEST["endDate"]);
$params[] = $time[0];
......
......@@ -106,6 +106,36 @@
<textarea name="codicil" id="codicil" rows="8" class="form-control" style="width:80%;">{{result.codicil}}</textarea>
</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 role="tabpanel" class="tab-pane" id="soInfo">
<br />
......@@ -345,7 +375,7 @@
{% if commissionLog %}
<div class="panel panel-default">
<div class="panel-heading">实收佣金列表</div>
<table class="table">
<table class="table" >
<tbody id="commissionList">
<tr>
<th>实收时间:</th>
......@@ -392,7 +422,6 @@
</div>
</div>
</div>
</form>
{% include 'recConsultant.html' %}
{{ block('recConsultant') }}
......@@ -445,41 +474,41 @@
cPhone:'required'
};
$('#contract').validate({
onkeyup: false,
onfocusout: false,
ignore: [],
errorClass: "my-error-class",
rules:rulesJson ,
messages: {
houseNumber:'请选择房源',
customerNumber:'请选择客源',
businessId:'请选择业务类型',
permitNumber:'请选输入产证编号',
area:'请选输入面积',
price:'请选输入金额',
signedDate:'请选输入签约日期',
'buy[accounts]':'请输入买方应收佣金',
'sell[accounts]':'请输入卖方应收佣金',
oCommission:'请选业主佣金',
oPhone:'请选业主手机',
cCommission:'请选买方佣金',
cPhone:'请选买方手机'
},
errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1",
submitHandler: function (form) {
console.log($("input[name='sell[consultantId]']").val() == undefined);
console.log($("input[name='buy[consultantId]']").val() == undefined);
if($("input[name='sell[consultantId]']").val() == undefined && $("input[name='buy[consultantId]']").val() == undefined){
$("#messageBox1").removeAttr("style");
var label = $("<label>").append("请选择员工").addClass("my-error-class");
$("#messageBox1").append(label);
return false;
}
form.submit();
}
});
// $('#contract').validate({
// onkeyup: false,
// onfocusout: false,
// ignore: [],
// errorClass: "my-error-class",
// rules:rulesJson ,
// messages: {
// houseNumber:'请选择房源',
// customerNumber:'请选择客源',
// businessId:'请选择业务类型',
// permitNumber:'请选输入产证编号',
// area:'请选输入面积',
// price:'请选输入金额',
// signedDate:'请选输入签约日期',
// 'buy[accounts]':'请输入买方应收佣金',
// 'sell[accounts]':'请输入卖方应收佣金',
// oCommission:'请选业主佣金',
// oPhone:'请选业主手机',
// cCommission:'请选买方佣金',
// cPhone:'请选买方手机'
// },
// errorContainer: "#messageBox1",
// errorLabelContainer: "#messageBox1",
// submitHandler: function (form) {
// console.log($("input[name='sell[consultantId]']").val() == undefined);
// console.log($("input[name='buy[consultantId]']").val() == undefined);
// if($("input[name='sell[consultantId]']").val() == undefined && $("input[name='buy[consultantId]']").val() == undefined){
// $("#messageBox1").removeAttr("style");
// var label = $("<label>").append("请选择员工").addClass("my-error-class");
// $("#messageBox1").append(label);
// return false;
// }
// form.submit();
// }
// });
var j = 0 ;
var urlParams = getUrlParmas();
......@@ -628,6 +657,39 @@
var div2 = $("<div>").append(row).append(row2).append(recommendConsultant).css("display","inline-block");
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);
</script>
{% include 'recommendHouse.html' %}
......
......@@ -16,3 +16,7 @@ p[class^=col-]{
border-bottom: 1px solid;
border-bottom: 1px solid #ddd;
}
#photoTables th,#photoTables td{
text-align: center;
}
\ No newline at end of file
......@@ -5,35 +5,80 @@
}
</style>
<h2>我的设置</h2>
<p>
<label for="time">入职时间:</label>
<input type="date" id="time" value="{{ time }}">
</p>
<p>
<label for="introduction" style="vertical-align: top;">诚信宣言:</label>
<textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea>
</p>
<p>
<input type="hidden" id="user_id" value="{{ user_id }}">
<input type="submit" id="submit" class="button">
</p>
<form action="" method="POST" enctype="multipart/form-data">
<p>
<label for="time">入职时间:</label>
<input type="date" name="time" value="{{ result.time }}">
</p>
<p>
<label for="introduction" style="vertical-align: top;">诚信宣言:</label>
<textarea name="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ result.introduction }}</textarea>
</p>
<table class="form-table">
<tbody id="QRcodeTable" >
{% 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>
(function ($) {
$(document).ready(function () {
$('#submit').click(function () {
var introduction = $('#introduction').val();
var time = $('#time').val();
var user_id = $('#user_id').val();
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=submit_introduction&time=' + time + '&introduction=' + introduction + '&user_id=' + user_id,
success: function (data) {
if (data) {
alert('提交成功');
}
// $('#submit').click(function () {
// var introduction = $('#introduction').val();
// var time = $('#time').val();
// var user_id = $('#user_id').val();
// $.ajax({
// type: 'POST',
// url: '{{ url }}/wp-admin/admin-ajax.php/',
// data: 'action=submit_introduction&time=' + time + '&introduction=' + introduction + '&user_id=' + user_id,
// success: function (data) {
// if (data) {
// 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);
......
......@@ -7,7 +7,7 @@
<tr>
<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-4 text-center">跟进说明</th>
</tr>
{% for item in list %}
......
<div id="preview">
<table class="form-table">
<tbody>
<tr>
<th style="width:11.7%"><label for="traffic" style="margin-left: 30px">主力房源:</label></th>
<td>
<input type="file" name="files[0]" property="0" class = "files form-control"multiple style="width: 30%;">
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-md-2">
<label for="traffic" style="margin-left: 30px">主力房源:</label>
</div>
<div class="col-md-10">
{% set exists_ids = "" %}
{% for item in mainImage %}
{% if exists_ids != "" %}
{% set exists_ids = exists_ids~"," %}
{% endif %}
{% set exists_ids = exists_ids~item.id %}
<div>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px;margin-top:10px">
<select name="exists[{{item.id}}][buildProperty]" style="margin-right: 50px;width: 10%;display: inline-block" class="form-control">
<div class="row" style="margin-top:5px">
<div class="col-md-3">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140">
</div>
<div class="col-md-3">
<select name="exists[{{item.id}}][buildProperty]" class="form-control" style="height: 33px;width: 80%">
{% 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="form-control" value="{{item.area}}" style="width: 100px;display:inline-block; margin-right: 50px">
<input type="button" value="删除" class="button action cancel existsCancel" style="margin-top: 30px">
</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 %}
<p></p>
<input type="file" name="files[0]" property="0" class = "files form-control"multiple style="width: 30%;margin-top: 5px">
<div id="mainHouseDiv"></div>
<input type="hidden" name="exists_ids" value="{{exists_ids}}" >
</div>
</div>
</div>
<script>
......@@ -43,26 +46,36 @@
});
$("#preview").on("click",".cancel",function(){
$(this).parent("div").remove();
$(this).parent().parent().remove();
});
});
//显示主力户型
function mainHouse(input,i){
var reader = new FileReader();
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");
div4.append(button);
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 file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files form-control").css("width","20%");
var select = $("<select>").attr({"name":"data["+i+"][buildProperty]","style":"margin-right:50px;width:10%;display:inline-block"}).addClass("form-control");
var file = $("<input>").attr({"type":"file","name":"files["+(i+1)+"]","property":+(i+1)}).addClass("files form-control").css({"width":"30%","margin-top":"10px"});
{% for item in buildProperty %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% 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);
$("form").find("#preview > p").after(file);
$("#preview > p").append(div);
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("#mainHouseDiv").after(file);
$("#mainHouseDiv").append(div);
}
reader.readAsDataURL(input.files[0]);
......
......@@ -111,11 +111,14 @@
revertOption(json);
var rulesJson = {
housename:'required',
average_price:'required',
mark:'required',
community_name:'required',
address:'required',
average_price:'required',
covered_area:'required',
property_money:'required',
latest_news:'required',
overview:'required',
baseCity:{
citySelectcheck: true
},
......@@ -124,7 +127,11 @@
},
basePlateId:{
plateSelectcheck: true
},
baseRoom:{
roomSelectcheck:true
}
};
{% if not canApproval %}
rulesJson.description = 'required';
......@@ -139,12 +146,15 @@
rules: rulesJson,
messages: {
housename:'请输入楼盘名称',
mark:'请输入标签',
community_name:'请输入小区名称',
address:'请输入地址',
mark:'请输入标签',
average_price:'请输入均价',
description:'请输入跟进说明'
address:'请输入地址',
description:'请输入跟进说明',
covered_area:'请输入建筑面积',
property_money:'请输入物业费',
latest_news:'请输入最新动态',
overview:'请输入楼盘概述'
},
errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1",
......@@ -169,6 +179,10 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) {
return (value != '-1');
},"请选择板块");
jQuery.validator.addMethod('roomSelectcheck', function (value) {
return (value != '-1');
},"请选择建筑类型");
});
})(jQuery);
......
<div class="row" id="addPhotos">
<div class="col-md-12">
<table class="form-table" style="margin-left: 30px">
<thead >
<tr >
<th >类型</th>
<div id="addPhotos">
<div class="row">
<div class="col-md-2">
<label for="photos" style="margin-left: 30px; margin-top: 25px">房源相册:</label>
</div>
<div class="col-md-10">
<table class="form-table" id="photoTables">
<thead>
<tr>
<th>类型</th>
<th>相册</th>
<th>设为封面</th>
<th></th>
......@@ -18,17 +22,17 @@
{% set exists_photo_ids = exists_photo_ids~item.image_id %}
<tr>
<td>
<select name="exists_photo[{{ item.image_id }}][type]" style="margin-right: 50px">
<select name="exists_photo[{{ item.image_id }}][type]" style="width:38%;margin-left:30px" class="form-control" >
{% for i in photoType %}
<option {{ i.id == item.image_type?"selected":"" }} value="{{ i.id }}">{{ i.value }}</option>
{% endfor %}
</select>
</td>
<td>
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" style="margin-right: 50px">
<img src="{{siteUrl}}{{item.path}}" height="90" width="140" >
</td>
<td>
<input type="radio" name="frontCover" style="margin-right: 50px" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
<input type="radio" name="frontCover" value="{{item.image_id}}" {{ result.frontCover_id == item.image_id?"checked":"" }} />
</td>
<td>
<input type="button" value="删除" class="button action cancel existsCancel">
......@@ -37,10 +41,11 @@
{% endfor %}
</tbody>
</table>
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px;margin-left: 30px">
</div>
<button type="button" id="housePicture" class="button action" data-toggle="modal" style="margin-top: 10px;margin-left: 225px">
新增
</button>
<input type="hidden" name="exists_photo_ids" value="{{exists_photo_ids}}" >
</div>
</div>
......@@ -51,7 +56,7 @@
$("#housePicture").click(function(){
var tr = $("<tr>");
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 %}
select.append($("<option>").attr("value",{{item.id}}).append('{{item.value}}'));
{% endfor%}
......
......@@ -51,7 +51,8 @@
</div>
<div class="col-xs-2">
<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 result.approval != -2 %}
<select name="status" class="form-control">
......@@ -70,7 +71,8 @@
{% endif %}
{% endif %}
<input type="submit" id="submit" class="button action" style="float:left">
{% endif %} </div>
{% endif %}
</div>
</div>
</div>
</form>
......@@ -110,24 +112,43 @@
"kitchen":"{{result.kitchen}}",
"balcony":"{{result.balcony}}"
};
{% if result is not null %}
revertOption(json);
{% endif %}
var rulesJson = {
housename:'required',
mark:'required',
rent:'required',
community_name:'required',
suite:'required',
floor:'required',
totalFloor:'required',
covered_area:'required',
rent:'required',
overview:'required',
description:'required',
matching_facilities:'required',
baseCity:{
citySelectcheck: true
citySelectcheck:true
},
baseAreaId:{
areaSelectcheck: true
areaSelectcheck:true
},
basePlateId:{
plateSelectcheck: true
plateSelectcheck:true
},
roomNum:{
roomNumSelectcheck:true
},
baseRoom:{
baseRoomSelectcheck:true
},
decoration:{
decorationSelectcheck:true
}
};
{% if not houseId %}
rulesJson.owner_name = 'required';
rulesJson.owner_phone = 'required';
......@@ -145,10 +166,16 @@
messages: {
housename:'请输入房源名称',
mark:'请输入标签',
suite:'请输入门牌号码',
owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话',
rent:'请输入租金',
covered_area:'请输入建筑面积',
floor:'请输入楼层',
totalFloor:'请输入总层',
matching_facilities:'请输入配套设施',
community_name:'请输入小区名称',
overview:'请输入房源点评',
description:'请输入跟进说明'
},
errorContainer: "#messageBox1",
......@@ -174,6 +201,15 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) {
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);
......
......@@ -116,25 +116,43 @@
"kitchen":"{{result.kitchen}}",
"balcony":"{{result.balcony}}"
};
{% if result is not null %}
revertOption(json);
{% endif %}
var rulesJson = {
housename:'required',
mark:'required',
total_price:'required',
community_name:'required',
suite:'required',
floor:'required',
totalFloor:'required',
covered_area:'required',
total_price:'required',
average_price:'required',
latest_news:'required',
overview:'required',
description:'required',
garage:'required',
baseCity:{
citySelectcheck: true
citySelectcheck:true
},
baseAreaId:{
areaSelectcheck: true
areaSelectcheck:true
},
basePlateId:{
plateSelectcheck: true
plateSelectcheck:true
},
roomNum:{
roomNumSelectcheck:true
},
baseRoom:{
baseRoomSelectcheck:true
},
decoration:{
decorationSelectcheck:true
}
};
{% if not houseId %}
rulesJson.owner_name = 'required';
......@@ -144,6 +162,7 @@
{% if not canApproval %}
rulesJson.description = 'required';
{% endif %}
$('#secHouse').validate({
onkeyup: false,
onfocusout: false,
......@@ -153,11 +172,17 @@
messages: {
housename:'请输入房源名称',
mark:'请输入标签',
suite:'请输入门牌号码',
floor:'请输入楼层',
totalFloor:'请输入总层',
owner_name:'请输入业主姓名',
owner_phone:'请输入业主电话',
total_price:'请输入售价',
community_name:'请输入小区名称',
average_price:'请输入单价',
covered_area:'请输入建筑面积',
community_name:'请输入小区名称',
garage:'请输入车库',
overview:'请输入房源点评',
description:'请输入跟进说明'
},
errorContainer: "#messageBox1",
......@@ -187,6 +212,15 @@
jQuery.validator.addMethod('plateSelectcheck', function (value) {
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);
......
......@@ -7,7 +7,7 @@ class Config {
const A_HOUSE_RECOMMEND_TABLE = 'a_house_recommend';
const A_HOUSE_USER_TABLE = 'a_house_user';
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_BUILDPROPERTY_TABLE = 'dic_buildproperty';
const DIC_AREA_TABLE = 'dic_area';
......@@ -31,6 +31,7 @@ class Config {
const TOSPUR_COMMISSION = 'tospur_commission';
const TOSPUR_COMMISSION_LOG = 'tospur_commission_log';
const TOSPUR_QUOTA_TABLE = 'tospur_quota';
const STATISTICS_BUSINESS = 'statistics_business';
//sync url
......
......@@ -7,7 +7,6 @@ class ContractDao {
if($wpdb->last_error){
return $wpdb->last_error;
}
print_r($wpdb->last_error);
return $wpdb->insert_id;
}
......@@ -47,4 +46,85 @@ class ContractDao {
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
$mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid));
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;
......@@ -424,11 +426,12 @@ class SearchDao
}
$images = $wpdb->get_results($wpdb->prepare($imagesSql,$hid,$hid));
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;
return $context;
}
......
......@@ -45,6 +45,9 @@ function tospur_init()
require_once(PLUGIN_DIR . 'Admin/Contract_List.php');
require_once(PLUGIN_DIR . 'Admin/commissionManage.php');
require_once(PLUGIN_DIR . 'Admin/commissionList.php');
require_once(PLUGIN_DIR . 'Admin/Statistics.php');
//Statistics::business();
add_action('admin_menu', 'reset_menu');
tospur_register_script_style();
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