wzh 5 年之前
父節點
當前提交
9b51428370

+ 85 - 6
api/application/controllers/Common.php

@@ -9,10 +9,6 @@ class Common extends CI_Controller {
     public function __construct() {
         parent::__construct();
         $this->load->model('User_model');
-        $this->load->model('Hotel_model');
-        $this->load->model('Build_model');
-        $this->load->model('Floor_model');
-        $this->load->model('Room_model');
         $this->response = $this->config->config['response_en'];
     }
 
@@ -105,9 +101,9 @@ class Common extends CI_Controller {
         $this->load->model('Global_location_model');
         $version = $this->session->userdata('version');
         if (empty($version)) {
-            $data = $this->Global_location_model->get_list(['level'=>1], 'id, chinese_name as name',null,null,'convert(chinese_name using gbk) ASC,id DESC');
+            $data = $this->Global_location_model->get_list(['level'=>1,'id'=>92], 'id, chinese_name as name',null,null,'convert(chinese_name using gbk) ASC,id DESC');
         }else{
-            $data = $this->Global_location_model->get_list(['level'=>1], 'id, english_name as name',null,null,'convert(english_name using gbk) ASC,id DESC');
+            $data = $this->Global_location_model->get_list(['level'=>1,'id'=>92], 'id, english_name as name',null,null,'convert(english_name using gbk) ASC,id DESC');
         }
         
         exit(json_result('0000', $this->response['0000'], ['list'=>$data]));
@@ -115,6 +111,7 @@ class Common extends CI_Controller {
 
     public function get_province() {
         $country_id = intval($this->input->post('countryId',true));
+        $country_id = 92;
 
         $this->load->model('Global_location_model');
         $version = $this->session->userdata('version');
@@ -164,4 +161,86 @@ class Common extends CI_Controller {
         }
         exit(json_result('0000', $this->response['0000'], ['list'=>$data]));
     }
+
+
+    // 批量导入
+    function test(){
+        $indexArr = ['D'=>'area','F'=>'shen','G'=>'city'];
+        // $config['file'] = md5(uniqid());   // 设置文件名字
+        // $path = '../upload/file';
+        
+        // if (!file_exists($path)) {
+        //     mkdir($path);
+        // }
+        // $config['upload_path']      = $path.'/';   // 设置文件上传路径
+        // $config['file_name']      = date('YmdHis',time());   // 设置文件上传路径
+        // $config['allowed_types']    = 'xls|xlsx';  // 设置文件上传格式
+        // $config['max_size']     = 1024*2;   // 设置文件上传大小
+        
+        // $this->load->library('upload', $config);
+        // if ( ! $this->upload->do_upload('file')){
+        //     // 文件上传失败
+        //     $error = array('error' => $this->upload->display_errors('',''));
+        //     if (empty($this->version)) {
+        //         exit(json_result('0012',$this->response['0012'],array('error'=>transfer_error_tips($error['error']))));
+        //     }elseif ($this->version == 2) {
+        //         exit(json_result('0012',$this->response['0012'],array('error'=>transfer_error_tips_ru($error['error']))));
+        //     }else{
+        //         exit(json_result('0012',$this->response['0012'],array('error'=>$error['error'])));
+        //     }
+            
+        // }
+        // else{
+            // 文件上传成功
+            // $data = $this->upload->data();
+
+            // $filePath = $data['full_path'];
+            $filePath = '../upload/test.xls';
+            $this->load->library('phpExcel/PHPExcel');
+
+            $reader = PHPExcel_IOFactory::createReader('Excel5'); //设置以Excel5格式(Excel97-2003工作簿)
+
+            $PHPExcel = $reader->load($filePath); // 载入excel文件  
+            $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表  
+            $highestRow = $sheet->getHighestRow(); // 取得总行数  
+            // $highestColumm = $sheet->getHighestColumn(); // 取得总列数  
+              
+            /** 循环读取每个单元格的数据 */  
+            $k = 0;
+            $data = array();
+            for ($row = 1; $row <= $highestRow; $row++)    //行号从1开始  
+            {  
+                if ($row < 2) continue; // 跳过标题行
+                foreach ($indexArr as $key => $value) {
+                    $res = $sheet->getCell($key.$row)->getValue();
+
+                    if (is_object($res)) {
+                        $res= $res->__toString();
+                    }
+                    $data[$k][$value] = $res;  
+                }
+
+                $k ++;
+            }
+            // var_dump($data);
+            $temp = array();
+            foreach ($data as $key => $value) {
+                if (!isset($temp[$value['area']])) $temp[$value['area']] = $value;
+            }
+            // $temp = array_unique(array_column($data, 'shen'));
+            foreach ($temp as $key => $value) {
+                $res = $this->db->query('select id from global_location where english_name = "'.$value['city'].'" and level = 3')->row_array();
+                if (!empty($res) && !empty($res['id'])){
+                    $res2 = $this->db->query('select id from global_location where english_name = "'.$value['area'].'" and level = 4')->row_array();
+                    if (!empty($res2) && !empty($res2['id'])) continue;
+                    $data = array('level'=>4,'english_name'=>$value['area'],'pid'=>$res['id'],'timezone'=>6);
+                    $this->db->insert('global_location', $data);
+                }
+                
+            }
+            var_dump($temp);
+            // 批量写入数据
+            // return $data;
+        // }
+    }
 }

+ 22 - 0
api/application/controllers/Group.php

@@ -0,0 +1,22 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+include_once(FCPATH . 'application/controllers/Base_Controller.php');
+
+class Map extends Base_Controller{
+	public function __construct()
+	{
+		parent::__construct();
+		$this->load->model('Group_model');
+	}
+
+	// 分组列表
+	public function get_list(){
+
+		$userId = $this->get_user_info('id');
+		$role = $this->get_user_info('role');
+
+		$where = array();
+
+		if ($role != SYSTEM_ADMIN) $where['userId'] = $userId;
+	}
+}

+ 10 - 21
api/application/controllers/Project.php

@@ -469,28 +469,17 @@ class Project extends Base_Controller {
 
     // 获取项目下拉列表
     public function get() {
-        $companyid = $this->input->post('companyid',true);
+
         $role = $this->get_user_info('role');
-        $userid = $this->get_user_info('id');
-        $keyword = $this->input->post('keyword', true);
-        $condition = array();
-        if (!empty($keyword)) {
-            $condition['keyword'] = $keyword;
-        }
-        if (empty($companyid)) {
-            $companyid = $this->get_user_info('companyid');
-            $data = $this->Project_model->getMultiData($condition, 'P.id, P.projectname as name, P.networkcount as network', $role, $companyid, $userid);
-        }else{
-            $zone = $this->get_user_info('zone');
-            $data = $this->Project_model->get_list_by_company('id, projectname as name,company', $role, $companyid, $zone);
-        }
-        
-        if (!empty($data)) {
-            foreach ($data as $key => $value) {
-                $data[$key]['tag'] = get_first_char($value['name']);
-            }
-        }
-        exit(json_result('0000', $this->response['0000'], array('projects'=>$data)));
+        $company = $this->get_user_info('company');
+
+
+        $where = array();
+
+        if ($role != SYSTEM_ADMIN) $where['company'] = $company;
+
+        $list = $this->Project_model->get_list($where,'projectname,id');
+        exit(json_result('0000', $this->response['0000'], array('list'=>$list)));
     }
 
     private function getLeftTimeByProject($project_id){

+ 7 - 1
api/application/controllers/User.php

@@ -248,10 +248,16 @@ class User extends Base_Controller{
                 exit(json_result('0722',$this->response['0722'],array()));
             }
 
+            $oldData = $this->User_model->get_one($wher,'company');
+
+            if ($oldData['company'] != $data['company']) {
+            	$this->Project_model->update(array('company'=>$data['company']),array('userId'=>$where['id'],'company'=>$data['company']));
+            }
+
             $privilegeIds = $this->input->post('privilegeIds',true);
 			if ($privilegeIds !== NULL && $privilegeIds !== '') $data['privilege'] = $privilegeIds;
 
-			$this->User_model->update_user($data,$where['id']);
+			$this->User_model->update($data,$where);
 
 			$userid = $where['id'];
 			$this->add_operation_log('update',"修改用户,用户名\"{$data['name']}\"",0);