| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 | 
							- <?php
 
- /**
 
-  * 建筑激活控制器
 
-  *
 
-  * User: smartcost
 
-  * Date: 2018/9/26
 
-  * Time: 11:03
 
-  */
 
- class BuildingController extends DooController {
 
-     public $staff;
 
-     public function beforeRun($resource, $action) {
 
-         Doo::loadModel ( 'staff' );
 
-         $staff = new staff ();
 
-         $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
 
-         $accessModular = 'BUILD';
 
-         if (empty ( $detail ['cldAccessArray'] ))
 
-             die ( 'illegal request' );
 
-         else {
 
-             if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
 
-                 if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
 
-                     $flag = true;
 
-                 } else {
 
-                     $flag = false;
 
-                 }
 
-             } else {
 
-                 die ( 'illegal request' );
 
-             }
 
-         }
 
-         if (! $flag)
 
-             die ( 'illegal request' );
 
-     }
 
-     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;
 
-     }
 
- }
 
 
  |