Pārlūkot izejas kodu

启动器添加查询锁号接口

laiguoran 6 gadi atpakaļ
vecāks
revīzija
29ddc95fe5

+ 75 - 0
protected/class/building.php

@@ -0,0 +1,75 @@
+<?php
+/**
+ * 建筑接口
+ *
+ * User: Ellisran
+ * Date: 2018/9/27
+ * Time: 16:23
+ */
+
+class Building {
+
+    private $BuildUrl = 'https://yun.smartcost.com.cn/cld'; // 建筑-cld url接口地址
+
+    public function getUsersAndCompilationByID ($id) {
+        $url = $this->BuildUrl. '/getUsersAndCompilation?ssoID='. $id;
+        $result = json_decode($this->curl_request($url), true);
+        if ($result['error'] == 0) {
+            return $result['data'];
+        } else {
+            return '';
+        }
+    }
+
+    public function getUsersAndCompilationByMobile ($mobile) {
+        $url = $this->BuildUrl. '/getUsersAndCompilation?mobile='. $mobile;
+        $result = json_decode($this->curl_request($url), true);
+        if ($result['error'] == 0) {
+            return $result['data'];
+        } else {
+            return '';
+        }
+    }
+
+    public function setUserCompilation($ssoId, $compilationId) {
+        $url =  $this->BuildUrl. '/setUserUpgrade';
+        $data = array('ssoId' => $ssoId, 'cid' => $compilationId);
+        $result = json_decode($this->curl_request($url, $data), true);
+        if ($result['error'] == 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * curl 获取接口数据,data为空时为GET方法,有值则为POST方法
+     *
+     * @param $url
+     * @param string $data
+     * @return mixed|string
+     */
+    private function curl_request($url, $data = '') {
+
+        $curl = curl_init();
+
+        curl_setopt($curl, CURLOPT_URL, $url);
+
+        curl_setopt($curl, CURLOPT_HEADER, 0);
+
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+
+        if($data) {
+            curl_setopt($curl, CURLOPT_POST, 1);
+            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
+        }
+
+        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
+
+        $data = curl_exec($curl);
+
+        curl_close($curl);
+
+        return $data;
+    }
+}

+ 3 - 0
protected/config/routes.conf.php

@@ -656,4 +656,7 @@ $route['*']['/building/getBuildList'] = array('BuildingController', 'getBuildLis
 $route['*']['/building/setUserCompilation'] = array('BuildingController', 'setUserCompilation');
 $route['*']['/building/setUserClient'] = array('BuildingController', 'setUserClient');
 
+// 启动器-CLD接口
+$route['*']['/api/startup/keynum'] = array('StartUpController', 'getKeyNum');
+
 ?>

+ 27 - 0
protected/controller/BuildingApiController.php

@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * 建筑接口控制器
+ *
+ * @author EllisRan
+ */
+
+class BuildingApiController extends DooController {
+
+	public $staff;
+
+	function __construct() {
+
+	}
+
+	public function categoryStaff() {
+		Doo::loadModel('staff');
+		$staff = new staff();
+		$stafflist = $staff->getStaffByCidOnBuilding($this->params['cid']);
+		echo json_encode($stafflist);
+		exit;
+	}
+
+}
+
+?>

+ 374 - 0
protected/controller/BuildingController.php

@@ -0,0 +1,374 @@
+<?php
+
+/**
+ * 建筑激活控制器
+ *
+ * User: smartcost
+ * Date: 2018/9/26
+ * Time: 11:03
+ */
+class BuildingController extends DooController {
+
+    public $staff;
+
+    function __construct() {
+        if(isset($_COOKIE["staff"])){
+            if(!empty($_COOKIE["staff"])){
+                Doo::loadModel ( 'staff' );
+                $staff = new staff ();
+                $this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
+
+                return "/";
+            }
+        }
+
+        Doo::loadCore ( 'uri/DooUriRouter' );
+        $router = new DooUriRouter ();
+        $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
+
+        if($routeRs['1']!="login"){
+            header ( 'Content-Type:text/html;charset=utf-8' );
+            @header ( "Location: /login"  );
+        }
+    }
+
+    public function index() {
+        Doo::loadModel('buildActivation');
+
+        $buildActivation = new BuildActivation();
+
+        Doo::loadModel('L_category');
+
+        $category = new L_category();
+
+        Doo::loadModel('staff');
+
+        $staff = new staff();
+
+        Doo::loadModel('client');
+
+        $client = new client();
+
+        $thisyear = date('Y',time());
+        $num = intval($thisyear)-2018;
+        $html = '<option value="0" selected>所有年份</option>';
+        for($i = $num; $i >= 0; $i--){
+            $html .= '<option value="'.(2018+$i).'">'.(2018+$i).'</option>';
+        }
+
+        $data['year_option'] = $html;
+
+        // 获取建筑版本
+        $data['compilationList'] = $buildActivation->getCompilationList();
+
+        $sql = $this->staff[0]['cid'] == 12 ? ' 1' : 'cid='. $this->staff[0]['cid'];
+
+        $blist = $buildActivation->getList($sql);
+
+        if (!empty($blist)) {
+            foreach ($blist as $k => $v) {
+                $blist[$k]['categoryname'] = $category->getCategoryById($v['cid'])[0]['title'];
+                $blist[$k]['staffname'] = $staff->getStaffBySid($v['sid'])['username'];
+                if ($v['client_id'] != 0) {
+                    $blist[$k]['clientname'] = $client->getClientByID($v['client_id'])['clientname'];
+                }
+                $blist[$k]['addtime'] = date('Y-m-d', $v['addtime']);
+            }
+        }
+
+        //办事处列表
+        $data['categoryList'] = $category->getCategory();
+
+        //办事处人员列表
+        $data['staffList'] = $staff->getStaffByCid($this->staff[0]['cid']);
+
+        $data['blist'] = $blist;
+
+        $data ['memu'] = 'building';
+        $data ['staff'] = $this->staff;
+        $this->render ( "/building-index", $data );
+    }
+
+    /**
+     * 获取办事处员工信息json
+     */
+    public function getStaffMsg() {
+        if (isset($_GET['sid']) && is_numeric($_GET['sid'])) {
+            Doo::loadModel('staff');
+
+            $staff = new staff();
+
+            $sid = $_GET['sid'];
+
+            $staffInfo = $staff->getStaffBySid($sid);
+
+            if (!empty($staffInfo)) {
+                echo json_encode(array('code' => 200, 'msg' => '', 'data' => $staffInfo));
+                exit;
+            }
+
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 获取建筑用户信息json
+     */
+    public function getBuildMsg() {
+        if (isset($_GET['id']) && is_numeric($_GET['id'])) {
+//            Doo::loadModel('staff');
+//
+//            $staff = new staff();
+//
+//            $id = $_GET['id'];
+//
+//            $staffInfo = $staff->getStaffBySid($id);
+
+            Doo::loadClass('building');
+
+            $building = new Building();
+
+            $data = $building->getUsersAndCompilationByID($_GET['id']);
+//            $data = $building->getUsersAndCompilationByMobile('13726259839');
+            $clientInfo = '';
+            if (isset($_GET['cid']) && is_numeric($_GET['cid'])) {
+                Doo::loadModel('client');
+
+                $client = new client();
+
+                $clientInfo = $client->getClientByID($_GET['cid']);
+            }
+            $data['clientInfo'] = $clientInfo;
+
+            Doo::loadModel('buildActivation');
+
+            $buildActivation = new BuildActivation();
+
+            Doo::loadModel('L_category');
+
+            $category = new L_category();
+
+            Doo::loadModel('staff');
+
+            $staff = new staff();
+
+            $buildActivationList = $buildActivation->getListByssoID($_GET['id']);
+
+            if (!empty($buildActivationList)) {
+                foreach ($buildActivationList as $bk => $bv) {
+                    $buildActivationList[$bk]['year'] = date('Y', $bv['addtime']);
+                    $buildActivationList[$bk]['month'] = date('m', $bv['addtime']);
+                    $buildActivationList[$bk]['day'] = date('d', $bv['addtime']);
+                    $buildActivationList[$bk]['categoryname'] = $category->getCategoryById($bv['cid'])[0]['title'];
+                    $buildActivationList[$bk]['staffname'] = $staff->getStaffBySid($bv['sid'])['username'];
+                }
+            }
+
+            $data['buildActivationList'] = $buildActivationList;
+
+            if (!empty($data)) {
+                echo json_encode(array('code' => 200, 'msg' => '', 'data' => $data));
+                exit;
+            } else {
+                echo json_encode(array('code' => 404, 'msg' => '建筑不存在该用户'));
+                exit;
+            }
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 获取cld客户信息
+     */
+    public function getClientMsg() {
+        if (isset($_GET['cid']) && is_numeric($_GET['cid'])) {
+            Doo::loadModel('client');
+
+            $client = new client();
+
+            $cid = $_GET['cid'];
+
+            $clientInfo = $client->getClientByID($cid);
+
+            if (!empty($clientInfo)) {
+
+                Doo::loadModel ( 'client_staff' );
+
+                $client_staff = new client_staff ();
+
+                Doo::loadModel ( 'company' );
+
+                $company = new company ();
+
+                Doo::loadModel ( "district" );
+
+                $district = new district ();
+
+                $companyInfo = $company->getCompanyByCid ( $clientInfo ['companyid'] )[0];
+
+                $staffInfo = $client_staff->getClientByCid ( $clientInfo ['cid'] );
+
+                $local = $district->getbyidlist ( $clientInfo ['district'] );
+
+                if (! isset ( $local [1] ))
+                    $local [1] ['name'] = "";
+                if (! isset ( $local [2] ))
+                    $local [2] ['name'] = "";
+
+                echo json_encode(array('code' => 200, 'msg' => '', 'data' => array('clientInfo' => $clientInfo, 'companyInfo' => $companyInfo, 'staffInfo' => $staffInfo, 'local' => $local)));
+                exit;
+            }
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 搜索手机号,防止由于改号码导致数据不全问题
+     */
+    public function checkMobile() {
+        if (isset($_GET['mobile'])) {
+            Doo::loadClass('building');
+
+            $building = new Building();
+
+            $data = $building->getUsersAndCompilationByMobile($_GET['mobile']);
+
+            if ($data) {
+                Doo::loadModel('buildActivation');
+
+                $buildActivation = new BuildActivation();
+
+                $buildActivationList = $buildActivation->getOneByssoID($data['userInfo']['ssoId']);
+
+                $cid = !empty($buildActivationList) && $buildActivationList['client_id'] != 0 ? $buildActivationList['client_id'] : '';
+
+                echo json_encode(array('code' => 200, 'msg' => '', 'data' => array('id' => $data['userInfo']['ssoId'], 'cid' => $cid)));
+                exit;
+            } else {
+                echo json_encode(array('code' => 404, 'msg' => '该号码未注册建筑项目'));
+                exit;
+            }
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 修改编办信息
+     */
+    public function setUserCompilation() {
+        if (isset($_POST['id']) && is_numeric($_POST['id']) && isset($_POST['cid'])) {
+            Doo::loadClass('building');
+
+            $building = new Building();
+
+            $result = $building->setUserCompilation($_POST['id'], $_POST['cid']);
+
+            if($result) {
+                Doo::loadModel('buildActivation');
+
+                $buildActivation = new BuildActivation();
+
+                $buildActivation->insertActivation($_POST,$this->staff[0]);
+                echo json_encode(array('code' => 200, 'msg' => ''));
+                exit;
+            } else {
+                echo json_encode(array('code' => 404, 'msg' => '添加失败'));
+                exit;
+            }
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 绑定cld客户
+     */
+    public function setUserClient() {
+        if (isset($_POST['id']) && is_numeric($_POST['id']) && isset($_POST['cid']) && is_numeric($_POST['cid'])) {
+            Doo::loadModel('buildActivation');
+
+            $buildActivation = new BuildActivation();
+
+            $result = $buildActivation->setClientID($_POST['id'], $_POST['cid']);
+
+            if ($result) {
+                echo json_encode(array('code' => 200, 'msg' => ''));
+                exit;
+            } else {
+                echo json_encode(array('code' => 404, 'msg' => '绑定失败'));
+                exit;
+            }
+        }
+        echo json_encode(array('code' => 404, 'msg' => '参数有误'));
+        exit;
+    }
+
+    /**
+     * 获取列表
+     */
+    public function getBuildList() {
+
+        Doo::loadModel('buildActivation');
+
+        $buildActivation = new BuildActivation();
+
+        $sql = ' 1';
+
+        if (isset($_POST['sso_id']) && is_numeric($_POST['sso_id'])) {
+            $sql .= ' and sso_id='.$_POST['sso_id'];
+        }
+
+        if (isset($_POST['compilation_id']) && $_POST['compilation_id'] != 0) {
+            $sql .= ' and compilation_id="'.$_POST['compilation_id'].'"';
+        }
+
+        if (isset($_POST['staff_id']) && is_numeric($_POST['staff_id']) && $_POST['staff_id'] != 0) {
+            $sql .= ' and sid='.$_POST['staff_id'];
+        } else if (isset($_POST['category']) && is_numeric($_POST['category']) && $_POST['category'] != 12) {
+            $sql .= ' and cid='.$_POST['category'];
+        }
+
+        if (isset($_POST['year']) && is_numeric($_POST['year']) && $_POST['year'] != 0) {
+            $year = intval($_POST['year']);
+            if (isset($_POST['month']) && is_numeric($_POST['month']) && $_POST['month'] != 0) {
+                $month = intval($_POST['month']);
+                $startday = $year.'/'.$month.'/1';
+                $endday = $month == 12 ? ($year+1).'/1/1' : $year.'/'.($month+1).'/1';
+            } else {
+                $startday = $year.'/1/1';
+                $endday = ($year+1).'/1/1';
+            }
+            $sql .= ' and addtime>=UNIX_TIMESTAMP("'.$startday.'") and addtime<UNIX_TIMESTAMP("'.$endday.'")';
+        }
+
+        $blist = $buildActivation->getList($sql);
+        if (!empty($blist)) {
+            Doo::loadModel('L_category');
+
+            $category = new L_category();
+
+            Doo::loadModel('staff');
+
+            $staff = new staff();
+
+            Doo::loadModel('client');
+
+            $client = new client();
+
+            foreach ($blist as $k => $v) {
+                $blist[$k]['categoryname'] = $category->getCategoryById($v['cid'])[0]['title'];
+                $blist[$k]['staffname'] = $staff->getStaffBySid($v['sid'])['username'];
+                if ($v['client_id'] != 0) {
+                    $blist[$k]['clientname'] = $client->getClientByID($v['client_id'])['clientname'];
+                }
+                $blist[$k]['addtime'] = date('Y-m-d', $v['addtime']);
+            }
+        }
+        echo json_encode(array('code' => 200, 'msg' => '', 'data' => $blist));
+        exit;
+    }
+}

+ 40 - 0
protected/controller/StartUpController.php

@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * 启动器接口控制器
+ *
+ * @author EllisRan
+ */
+
+class StartUpController extends DooController {
+
+	public $staff;
+
+	function __construct() {
+
+	}
+
+	public function getKeyNum() {
+		if (isset($_GET['num'])) {
+			Doo::loadModel('longle');
+			$longle = new longle();
+			$keynum = $longle->getOne(array('select' => 'key_num', 'where' => 'SerialNumber=?', 'param' => array($_GET['longle']), 'asArray' => TRUE));
+			if (!empty($keynum)) {
+				echo json_encode(array('error' => 0, 'msg' => '', 'info' => $keynum['key_num']));
+				exit;
+			} else {
+				echo json_encode(array('error' => 1, 'msg' => '不存在该锁号'));
+				exit;
+			}
+		} else {
+			echo json_encode(array('error' => 1, 'msg' => '参数有误'));
+			exit;
+		}
+
+
+
+	}
+
+}
+
+?>

+ 56 - 0
protected/model/buildActivation.php

@@ -0,0 +1,56 @@
+<?php
+
+Doo::loadCore ( 'db/DooModel' );
+
+class BuildActivation extends DooModel {
+	
+	public $id;
+	public $mobile;
+	public $sso_id;
+	public $compilation_id;
+	public $cname;
+	public $sid;
+	public $cid;
+	public $status;
+	public $client_id;
+	public $addtime;
+
+	public $_table = 'build_activation';
+	public $_primarykey = 'id';
+	public $_fields = array ('id','mobile','sso_id','compilation_id','cname','sid','cid','status','client_id','addtime');
+
+	public function insertActivation($postData, $staff) {
+		$this->mobile = $postData['mobile'];
+		$this->sso_id = $postData['id'];
+		$this->compilation_id = $postData['cid'];
+		$this->cname = $postData['cname'];
+		$this->sid = $staff['sid'];
+		$this->cid = $staff['cid'];
+		$this->client_id = !empty($postData['client_id']) && $postData['client_id'] != 0 ? $postData['client_id'] : 0;
+		$this->addtime = time();
+		return $this->insert();
+	}
+
+	public function getList($sql = ' 1') {
+		return $this->find(array('where' => $sql, 'desc' => 'id', 'asArray' => true));
+	}
+
+	public function getListByssoID($ssoid) {
+		return $this->find(array('where' => 'sso_id=?', 'param' => array($ssoid), 'desc' => 'id', 'asArray' => TRUE));
+	}
+
+	public function getOneByssoID($ssoid) {
+		return $this->getOne(array('where' => 'sso_id=?', 'param' => array($ssoid), 'desc' => 'id', 'asArray' => TRUE));
+	}
+
+	public function setClientID($ssoid, $client_id) {
+		$this->client_id = $client_id;
+		return $this->update(array('where' => 'sso_id=?', 'param' => array($ssoid)));
+	}
+
+	public function getCompilationList() {
+		return $this->find(array('select' => 'compilation_id,cname,cid', 'groupby' => 'cname', 'desc' => 'id', 'asArray' => TRUE));
+	}
+}
+
+?>

+ 628 - 0
protected/view/building-index.html

@@ -0,0 +1,628 @@
+<!-- include 'header' -->
+<body>
+	<div class="mainLayout">
+		<div class="mainMenu">
+			<div class="menuItem">
+				<a href="#" class="mLogo">CLD</a>
+				<ul>
+					<!-- include 'menu' -->
+				</ul>
+			</div>
+		</div>
+		<div class="warpContent">
+			<div class="contactTab">
+				<a class="now" href="#">建筑激活</a>
+				<div class="searchItem">
+					<input type="text" placeholder="输入建筑用户手机号进行搜索" id="search_mobile">
+					<input type="hidden" id="hidden_search" value="0">
+					<input type="button" class="subBtn search-build" value="搜索">
+				</div>
+			</div>
+			<div class="contactDatabase fL">
+				<div class="contactCate">
+					<ul class="cateList">
+						<li class="clearfix filter">
+							<select id="compilation_select">
+								<option value="0">所有建筑版本</option>
+								<!-- if !empty({{compilationList}}) -->
+								<!-- loop compilationList -->
+								<option value="{{compilationList' value.compilation_id}}">{{compilationList' value.cname}}专业版</option>
+								<!-- endloop -->
+								<!-- endif -->
+							</select>&nbsp;
+							<select id="year_select">
+								{{year_option}}
+							</select>&nbsp;
+							<select id="month_select">
+								<option value="0">所有月份</option>
+								<option value="1">1月</option>
+								<option value="2">2月</option>
+								<option value="3">3月</option>
+								<option value="4">4月</option>
+								<option value="5">5月</option>
+								<option value="6">6月</option>
+								<option value="7">7月</option>
+								<option value="8">8月</option>
+								<option value="9">9月</option>
+								<option value="10">10月</option>
+								<option value="11">11月</option>
+								<option value="12">12月</option>
+							</select>&nbsp;
+							<select id="category_select">
+								<!-- loop categoryList -->
+								<option value="{{categoryList' value.cid}}" <!-- if {{categoryList' value.cid}} == {{staff.0.cid}} -->selected<!-- endif -->>{{categoryList' value.title}}</option>
+								<!-- endloop -->
+							</select>&nbsp;
+							<select id="staff_select">
+								<option value="0">负责人</option>
+								<!-- loop staffList -->
+								<option value="{{staffList' value.sid}}">{{staffList' value.username}}</option>
+								<!-- endloop -->
+							</select>
+						</li>
+					</ul>
+					<div class="contactTableHead">
+						<table class="buildingUl">
+							<tbody>
+							<tr>
+								<td width="150">通行帐号手机号</td>
+								<td width="180">激活产品</td>
+								<td width="100">办事处</td>
+								<td width="75">责任人</td>
+								<td width="90">状态</td>
+								<td width="90">cld客户</td>
+								<td>激活时间</td>
+							</tr>
+							</tbody>
+						</table>
+					</div>
+				</div>
+				<div class="contactList autoHeightL2">
+					<table class="contactTable" id="build_list">
+						<!-- if !empty({{blist}}) -->
+						<!-- loop blist -->
+						<tr>
+							<td width="150"><a href="javascript:void(0);" class="getBuildingMsg" data-id="{{blist' value.sso_id}}" data-cid="{{blist' value.client_id}}">{{blist' value.mobile}}</a></td>
+							<td width="180">{{blist' value.cname}}专业版</td>
+							<td width="100">{{blist' value.categoryname}}</td>
+							<td width="75"><a href="javascript:void(0);" class="getStaffMsg" data-sid="{{blist' value.sid}}">{{blist' value.staffname}}</a></td>
+							<td width="90"><!-- if {{blist' value.status}} == 1 -->已激活<!-- endif --></td>
+							<td width="90"><!-- if {{blist' value.client_id}} != 0 --><a href="javascript:void(0);" class="getClientMsg" data-cid="{{blist' value.client_id}}">{{blist' value.clientname}}</a><!-- endif --></td>
+							<td>{{blist' value.addtime}}</td>
+						</tr>
+						<!-- endloop -->
+						<!-- endif -->
+					</table>
+				</div>
+			</div>
+			<div class="lockDetil fL">
+				<div class="lockRecord autoHeightR2">
+					<!--build建筑信息页-->
+					<div id="build_msg" style="display:none;">
+						<div class="toolItem clearfix">
+							<div class="contactInfo">
+								<div class="contactPanel">
+									<h1>建筑用户信息</h1>
+									<table>
+										<tbody id="buildUserInfo_msg">
+										</tbody>
+									</table>
+								</div>
+							</div>
+						</div>
+						<div class="toolItem clearfix">
+							<div class="contactPanel">
+								<div class="subNav">
+									<ul class="navTabs">
+										<li class="active tabChange" data-tab="build"><a href="#">建筑激活版本</a></li>
+										<li class="tabChange" data-tab="cld"><a href="#">cld客户信息</a></li>
+									</ul>
+								</div>
+								<table class="versionTabale" id="compilation_msg">
+									<input type="hidden" id="build_ssoid" value="">
+									<input type="hidden" id="build_mobile" value="">
+									<input type="hidden" id="client_id" value="">
+									<tr>
+										<th>产品</th><th>免费版</th><th>专业版</th>
+									</tr>
+									<tbody id="compilation_list">
+
+									</tbody>
+									<tr id="activation_btn" style="display: none">
+										<td colspan="2">
+											<a href="javascript:void(0)" class="button">确定</a>
+										</td><td></td>
+									</tr>
+								</table>
+								<table id="clientInfo_msg" style="display: none;">
+									<tr><th>姓名</th><td><a href="#">周乃君</a></td><th>昵称</th><td>周工</td></tr>
+									<tr><th>性别</th><td>女</td><th>办事处</th><td>广东办</td></tr>
+									<tr><th>手机</th><td>12345678910</td><th>电话</th><td>0000-564645654</td></tr>
+									<tr><th>QQ</th><td>12345678</td><th>邮箱</th><td>123456@qq.com</td></tr>
+									<tr><th>单位全称</th><td><a href="#">广东长誉公路工程有限公司</a></td></tr>
+								</table>
+							</div>
+						</div>
+
+						<div class="toolItem clearfix" id="add_client" style="display: none">
+							<div class="contactInfo">
+								<div class="contactPanel">
+									<h1>绑定cld客户</h1>
+									<div>
+										<span data-placement="right" data-toggle="ctooltip" data-original-title="只允许填写库中存在的客户,若输入客户不存在,请先添加该客户。">
+										<input type="text" id="client_result" value="">
+										</span>
+									</div>
+									<a href="javascript:void(0)" class="button" id="addclient_btn">确定绑定</a>
+								</div>
+							</div>
+						</div>
+
+						<div id="activation_list">
+						</div>
+					</div>
+					<!--end build-->
+
+					<!--staff员工信息页-->
+					<div class="toolItem clearfix" style="display: none;" id="staff_msg">
+						<div class="contactPanel">
+							<h1>刘飞</h1>
+							<table>
+								<tbody>
+								<tr>
+									<th>性别</th><td>男</td>
+									<th>办事处</th><td>广东办</td>
+								</tr>
+								<tr>
+									<th>手机</th><td>12345678910</td>
+									<th>电话</th><td>0000-564645654</td>
+								</tr>
+								<tr>
+									<th>QQ</th><td>12345678</td>
+									<th>邮箱</th><td>123456@qq.com</td>
+								</tr>
+								</tbody>
+							</table>
+						</div>
+					</div>
+					<!--end staff-->
+
+					<!--client客户信息页-->
+					<div class="toolItem clearfix" style="display: none;" id="clientInfo">
+					<!--<div class="toolItem clearfix" style="display: none;" id="client_msg">-->
+						<div class="contactPanel">
+							<h1><p class="fR">总部-<a href="javascript:void(0)" onclick="getStaffInfo('温秀娟')">温秀娟</a></p>周乃君<i class="icon- sport">5</i><a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(80171)" class="icon- edit">I</a></h1>
+							<table>
+								<tbody><tr><th>性别</th><td>女</td><th>昵称</th><td>庄(青美):</td></tr>
+								<tr><th>手机</th><td>18299400510</td><th>QQ</th><td>409764520</td></tr>
+								<tr><th>电话</th><td>0794-8223829</td><th>邮箱</th><td>409764520@qq.com</td></tr>
+								<tr><th>备注</th><td colspan="3"></td></tr>
+								<tr><td colspan="4"></td></tr>
+								</tbody></table>
+						</div>
+						<div class="contactPanel">
+							<table>
+								<tbody>
+								<tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany('8668')">昆明苇杭科技有限公司</a></td></tr>
+								<tr><th>单位主页</th><td colspan="3">http://www.xfxsoft.cn/</td></tr>
+								<tr><th>客户地区</th><td>云南省,昆明市,西山区</td><th>部门/职位</th><td>/</td></tr>
+								<tr><th>客户传真</th><td></td><th>办公室</th><td></td></tr>
+								<tr><th>客户地址</th><td colspan="3">云南省昆明市盘龙区东风东路47号建业商务中心A2202</td></tr>
+								<tr><th>客户乘车</th><td colspan="3"></td></tr>
+								<tr><th>客户地标</th><td colspan="3">建业商务中心</td></tr>
+								<tr><th>客户住宿</th><td colspan="3"></td></tr>
+								</tbody></table>
+						</div>
+					</div>
+					<!--end client-->
+				</div>
+			</div>
+		</div>
+	</div>
+	<script type="text/javascript">autoFlashHeight();</script>
+	<link rel="stylesheet" href="<?= WEB_SITE_GLOBAL ?>/js/jquery-ui.css" />
+	<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery-ui.js"></script>
+
+	<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery.ui.core.js"></script>
+	<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery.ui.widget.js"></script>
+	<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery.ui.position.js"></script>
+	<script src="<?= WEB_SITE_GLOBAL ?>/js/jquery.ui.autocomplete.js"></script>
+	<script>
+		$(function(){
+			// 建筑激活页面cld客户搜索
+			$("#client_result").blur(function(){
+
+				var url="/checkClient";
+
+				var name=$(this).val();
+
+				$.ajax({
+					url:url,
+					type: "post",
+					cache: false,
+					dataType: "json",
+					data: {
+						name:name
+					},
+					global: true,
+					success: function(data){
+
+						if(data.success){
+							$("#client_result").css("background-color","#fff");
+						}else{
+							$("#client_result").css("background-color","#f15b6c");
+							$('#client_id').val('');
+						}
+					},
+					error:function(err){
+						$("#client_result").css("background-color","#f15b6c");
+						$('#client_id').val('');
+					}
+				});
+
+
+			});
+
+			$("#client_result").autocomplete({
+				source: function( request, response ) {
+					$.ajax({
+						url: "/searchClient",
+						dataType: "json",
+						data:{
+							searchDbInforItem: request.term
+						},
+						success: function( data ) {
+
+							response( $.map( data, function( item ) {
+
+								return {
+									name:item.cid,
+
+									value: item.clientname+"-"+item.companyname
+								}
+							}));
+						}
+					});
+				},
+				minLength: 1,
+				select: function( event, ui ) {
+					$("#client_result").val(ui.item.dbId);
+					$('#client_id').val(ui.item.name);
+				}
+			});
+		})
+	</script>
+<script>
+	$(function(){
+		// 获取建筑用户信息
+		$('body').on('click', '.getBuildingMsg', function(){
+			var id = $(this).attr('data-id');
+			var cid = $(this).attr('data-cid');
+			getBuildMsg(id, cid);
+		});
+
+		// 获取cld客户信息
+		$('body').on('click', '.getClientMsg', function(){
+			var cid = $(this).attr('data-cid');
+			$.ajax({
+				type: 'get',
+				url: '/building/getClientMsg?cid=' + cid,
+				dataType: 'json',
+				success: function(result) {
+					if (result.code == '200') {
+						var data = result.data;
+
+						// 获取cld客户信息
+						var clientInfo = data.clientInfo;
+						var staffInfo = data.staffInfo;
+						var clienthtml = '<div class="contactPanel"><h1><p class="fR">' + staffInfo.category + '-<a href="javascript:void(0)" class="getStaffMsg" data-sid="' + staffInfo.sid + '">' + staffInfo.username + '</a></p>' +
+								clientInfo.clientname + '<i class="icon- sport">' + clientInfo.priority + '</i><a data-original-title="编辑客户" data-toggle="ctooltip" data-placement="right" href="javascript:clientEdit(' + clientInfo.cid + ')" class="icon- edit">I</a></h1> ' +
+								'<table><tbody>' +
+								'<tr><th>性别</th><td>' + clientInfo.gender + '</td><th>昵称</th><td>' + clientInfo.nicename + '</td></tr> ' +
+								'<tr><th>手机</th><td>' + clientInfo.telephone + '</td><th>QQ</th><td>' + clientInfo.qq + '</td></tr> ' +
+								'<tr><th>电话</th><td>' + clientInfo.phone + '</td><th>邮箱</th><td>' + clientInfo.email + '</td></tr> ' +
+								'<tr><th>备注</th><td colspan="3">' + clientInfo.mark + '</td></tr> ' +
+								'<tr><td colspan="4"></td></tr> ' +
+								'</tbody></table></div>';
+						$('#clientInfo_result').html(clienthtml);
+
+						// 获取单位信息
+						var companyInfo = data.companyInfo;
+						var local = data.local;
+						var companyhtml = '<div class="contactPanel"><table> <tbody> ' +
+								'<tr><th>单位全称</th><td colspan="3"><a href="javascript:void(0)" onclick="getCompany(' + companyInfo.cid + ')">' + companyInfo.companyname + '</a></td></tr> ' +
+								'<tr><th>单位主页</th><td colspan="3">' + clientInfo.webservice + '</td></tr> ' +
+								'<tr><th>客户地区</th><td>' + local[0].name + ',' + local[1].name + ',' + local[2].name + '</td><th>部门/职位</th><td>' + clientInfo.department + '</td></tr> ' +
+								'<tr><th>客户传真</th><td>' + clientInfo.fax + '</td><th>办公室</th><td>' + clientInfo.office + '</td></tr> ' +
+								'<tr><th>客户地址</th><td colspan="3">' + clientInfo.address + '</td></tr> ' +
+								'<tr><th>客户乘车</th><td colspan="3">' + clientInfo.ride + '</td></tr> ' +
+								'<tr><th>客户地标</th><td colspan="3">' + clientInfo.landmarks + '</td></tr> ' +
+								'<tr><th>客户住宿</th><td colspan="3">' + clientInfo.stay + '</td></tr> ' +
+								'</tbody></table></div>';
+
+						var html = clienthtml + companyhtml;
+
+						$('#clientInfo').html(html);
+
+						$('#clientInfo').show();
+						$('#staff_msg').hide();
+						$('#build_msg').hide();
+					}
+				}
+			})
+		});
+
+		// 获取cld责任人信息
+		$('body').on('click', '.getStaffMsg', function(){
+			var sid = $(this).attr('data-sid');
+			$.ajax({
+				type: 'get',
+				url: '/building/getStaffMsg?sid=' + sid,
+				dataType: 'json',
+				success: function(result) {
+					if (result.code == '200') {
+						var userinfo = result.data;
+						var html = '<div class="contactPanel"><h1>' + userinfo.username + '</h1> ' +
+								'<table> <tbody> ' +
+								'<tr> ' +
+								'<th>性别</th><td>' + userinfo.gender + '</td> ' +
+								'<th>办事处</th><td>' + userinfo.category + '</td> ' +
+								'</tr> ' +
+								'<tr> ' +
+								'<th>手机</th><td>' + userinfo.telephone + '</td> ' +
+								'<th>电话</th><td>' + userinfo.phone + '</td> ' +
+								'</tr> ' +
+								'<tr> ' +
+								'<th>QQ</th><td>' + userinfo.qq + '</td> ' +
+								'<th>邮箱</th><td>' + userinfo.email + '</td> ' +
+								'</tr> ' +
+								'</tbody> ' +
+								'</table></div>';
+						$('#staff_msg').html(html);
+						$('#staff_msg').show();
+						$('#build_msg').hide();
+						$('#clientInfo').hide();
+					}
+				}
+			})
+		});
+
+		// 搜索建筑用户信息
+		$('.search-build').on('click', function(){
+			var mobile = $('#search_mobile').val();
+			if (mobile == '') {
+				alert('请输入建筑用户手机号');
+			} else {
+				$.ajax({
+					type: 'get',
+					url: '/building/checkMobile?mobile=' + mobile,
+					dataType: 'json',
+					success: function(result) {
+						if (result.code == '200') {
+							var data = result.data;
+							getBuildList(data.id);
+							getBuildMsg(data.id, data.cid);
+						} else {
+							alert(result.msg);
+						}
+					}
+				})
+			}
+		});
+
+		// 激活建筑产品
+		$('#activation_btn a').click(function() {
+			// 只获取第一个选中的值
+			var cid = $('#compilation_list input:checked').attr('data-cid');
+			var cname = $('#compilation_list input:checked').attr('data-cname');
+			var id = $('#build_ssoid').val();
+			var mobile = $('#build_mobile').val();
+			var client_id = $('#client_id').val();
+			if (cid !== undefined && id !== '') {
+				$.ajax({
+					type: 'post',
+					url: '/building/setUserCompilation',
+					data: {id: id, cid: cid, mobile: mobile, client_id: client_id, cname: cname},
+					dataType: 'json',
+					success: function(result) {
+						if (result.code == '200') {
+							$('#hidden_search').val() != 0 ? getBuildList(id) : getBuildList('');
+							getBuildMsg(id, client_id);
+						} else {
+							alert('激活失败');
+						}
+					}
+				})
+			} else {
+				alert('请选择需要激活的版本');
+			}
+		});
+
+		// 绑定cld客户
+		$('#addclient_btn').click(function() {
+			var cid = $('#client_id').val();
+			var id = $('#build_ssoid').val();
+			if (cid == '' || id == '') {
+				alert('请根据要求填入cld客户');
+			} else {
+				$.ajax({
+					type: 'post',
+					url: '/building/setUserClient',
+					data: {id: id, cid: cid},
+					dataType: 'json',
+					success: function(result) {
+						if (result.code == '200') {
+							$('#hidden_search').val() != 0 ? getBuildList(id) : getBuildList('');
+							getBuildMsg(id, cid);
+						} else {
+							alert('绑定失败');
+						}
+					}
+				})
+			}
+		});
+
+		// ajax 获取建筑信息方法
+		function getBuildMsg(id, cid) {
+			$.ajax({
+				type: 'get',
+				url: '/building/getBuildMsg',
+				data: {id: id, cid: cid},
+				dataType: 'json',
+				success: function(result) {
+					if (result.code == '200') {
+						var data = result.data;
+						var builduserinfo = data.userInfo;
+						var buildmsghtml =
+								'<tr><th>称呼</th><td>' + builduserinfo.real_name + '</td><th>使用时间</th><td>' + builduserinfo.create_time + '</td></tr> ' +
+								'<tr><th>手机</th><td>' + builduserinfo.mobile + '</td><th>邮箱</th><td>' + builduserinfo.email + '</td></tr> ' +
+								'<tr><th>企业名称</th><td>' + builduserinfo.company + '</td><th>企业规模</th><td>' + builduserinfo.company_scale + '</td></tr> ' +
+								'<tr><th colspan="2" width="50">企业所在地区</th><td colspan="2">' + builduserinfo.province + '</td></tr> ';
+						$('#buildUserInfo_msg').html(buildmsghtml);
+						$('#build_ssoid').val(builduserinfo.ssoId);
+						$('#build_mobile').val(builduserinfo.mobile);
+
+						var compilationhtml = '';
+						var addCompilation = false;
+						$.each(data.compilationList, function(k, v) {
+							compilationhtml += '<tr> <th>' + v.name + '</th>' +
+									'<td>' + (v.isUpgrade !== undefined && v.isUpgrade === false ? '<img src="<?= WEB_SITE_GLOBAL ?>css/checkmark.png" width="20" height="20">' : '') + '</td>' +
+									'<td>' + (v.isUpgrade !== undefined && v.isUpgrade === true ? '<img src="<?= WEB_SITE_GLOBAL ?>css/checkmark.png" width="20" height="20">' : '<input type="checkbox" data-cid="' + v._id + '" data-cname="' + v.name + '" >') + '</td> ' +
+									'</tr>';
+							if (v.isUpgrade === undefined || v.isUpgrade === false) {
+								addCompilation = true;
+							}
+						});
+						if (addCompilation) {
+							$('#activation_btn').show();
+						} else {
+							$('#activation_btn').hide();
+						}
+
+						$('#compilation_list').html(compilationhtml);
+
+						var addclienthtml = '';
+						$('#add_client').hide();
+						if (data.clientInfo != '') {
+							var clientinfo = data.clientInfo;
+							var clientInfohtml = '' +
+									'<tr><th>姓名</th><td><a href="#" class="getClientMsg" data-cid="' + clientinfo.cid + '">' + clientinfo.clientname + '</a></td><th>昵称</th><td>' + clientinfo.nicename + '</td></tr> ' +
+									'<tr><th>性别</th><td>' + clientinfo.gender + '</td><th>办事处</th><td>' + clientinfo.department + '</td></tr> ' +
+									'<tr><th>手机</th><td>' + clientinfo.telephone + '</td><th>电话</th><td>' + clientinfo.phone + '</td></tr> ' +
+									'<tr><th>QQ</th><td>' + clientinfo.qq + '</td><th>邮箱</th><td>' + clientinfo.email + '</td></tr> ' +
+									'<tr><th>单位全称</th><td><a href="#">' + clientinfo.companyname + '</a></td></tr>';
+							$('#clientInfo_msg').html(clientInfohtml);
+							$('#client_id').val(clientinfo.cid);
+						} else {
+							$('#clientInfo_msg').html('暂未添加cld客户信息');
+							$('#add_client input').val('');
+							$('#add_client').show();
+							$('#client_id').val('');
+							$('#clientInfo').val('');
+						}
+
+						// 激活时间轴
+						var activationListhtml = '';
+						var activationList = data.buildActivationList;
+						$.each(activationList, function(k, v) {
+							activationListhtml += '<div class="infoFlowList"> <div class="dateTitle"> ' +
+									'<em class="month"><span class="num">' + v.month + '</span><span class="text">-' + v.day + '</span></em> ' +
+									'<span class="year">' + v.year + '</span> </div> ' +
+									'<ul class="flowList"> ' +
+									'<li class="item iconUpdate">激活 &lt; ' + v.categoryname + '<a href="#" class="getStaffMsg" data-sid="' + v.sid + '">' + v.staffname + '</a></li> ' +
+									'<li class="item">' + v.cname + '专业版</li> </ul> </div>';
+						});
+						$('#activation_list').html(activationListhtml);
+
+						$('#build_msg').show();
+						$('#staff_msg').hide();
+						$('#clientInfo').hide();
+					} else {
+						alert('没有此用户');
+					}
+				}
+			})
+		}
+
+		// ajax 获取列表方法
+		function getBuildList(ssoid) {
+			if (ssoid != '') {
+				$('#compilation_select').val(0);
+				$('#year_select').val(0);
+				$('#month_select').val(0);
+				$('#category_select').val('{{staff.0.cid}}');
+				$('#staff_select').val(0);
+				$('#hidden_search').val(1);
+			} else {
+				$('#search_mobile').val('');
+				$('#hidden_search').val(0);
+			}
+			var postData = {
+				compilation_id: $('#compilation_select').val(),
+				year: $('#year_select').val(),
+				month: $('#year_select').val() != 0 ? $('#month_select').val() : 0,
+				category: $('#category_select').val(),
+				staff_id: $('#staff_select').val(),
+				sso_id: ssoid
+			};
+			$.ajax({
+				type: 'post',
+				url: '/building/getBuildList',
+				data: postData,
+				dataType: 'json',
+				success: function(result) {
+					if (result.code == '200') {
+						var data = result.data;
+						var html = '';
+						$.each(data, function(k,v) {
+							html += '<tr> ' +
+									'<td width="150"><a href="javascript:void(0);" class="getBuildingMsg" data-id="' + v.sso_id + '" data-cid="' + v.client_id + '">' + v.mobile + '</a></td> ' +
+									'<td width="180">' + v.cname + '专业版</td> ' +
+									'<td width="100">' + v.categoryname + '</td>' +
+									'<td width="75"><a href="javascript:void(0);" class="getStaffMsg" data-sid="' + v.sid + '">' + v.staffname + '</a></td> ' +
+									'<td width="90">' + (v.status == 1 ? '已激活' : '') + '</td> ' +
+									'<td width="90">' + (v.client_id != 0 ? '<a href="javascript:void(0);" class="getClientMsg" data-cid="' + v.client_id + '">' + v.clientname + '</a>' : '') + '</td> ' +
+									'<td>' + v.addtime + '</td> ' +
+									'</tr>';
+						});
+						$('#build_list').html(html);
+					} else {
+						alert('获取列表数据失败');
+					}
+				}
+			})
+		}
+
+		// 获取列表各种条件筛选方法
+		$('#compilation_select').change(function() {
+			getBuildList('');
+		});
+		$('#year_select').change(function() {
+			getBuildList('');
+		});
+		$('#month_select').change(function() {
+			getBuildList('');
+		});
+		$('#category_select').change(function() {
+			getBuildList('');
+		});
+		$('#staff_select').change(function() {
+			getBuildList('');
+		});
+
+		// tab切换
+		$('.tabChange').click(function() {
+			var tab = $(this).attr('data-tab');
+			if (tab == 'build') {
+				$('#compilation_msg').show();
+				$('#clientInfo_msg').hide();
+			} else {
+				$('#compilation_msg').hide();
+				$('#clientInfo_msg').show();
+			}
+			$(this).addClass('active');
+			$(this).siblings().removeClass('active');
+		})
+	})
+</script>
+</body>