示例#1
0
 public function run($id = null, $page = 1, $size = 2)
 {
     $this->controller->pageTitle = "Profile";
     if (Yii::app()->request->isAjaxRequest) {
         if (!$id) {
             $id = Yii::app()->user->id;
         }
         $post = new CPost();
         $result = $post->getProfileList($id, $page, $size);
         echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('list' => $result['data'])));
     } else {
         if ($id) {
             $user = User::model()->with('companyid')->findByAttributes(array('id' => $id));
             $company = Company::model()->findByAttributes(array('ownerId' => $user['id']));
             $location = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getProfileList($id);
         } else {
             $id = Yii::app()->user->id;
             $user = User::model()->with('companyid')->findByAttributes(array('id' => $id));
             $company = Company::model()->findByAttributes(array('ownerId' => $user['id']));
             $location = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getProfileList($id);
         }
         $this->controller->render('profile', array('user' => $user, 'companylocation' => $location['location'], 'postlist' => $postlist['data']));
     }
 }
示例#2
0
文件: CHub.php 项目: itliuchang/test
 public function getHubInfo($id)
 {
     $result = Hub::model()->findByAttributes(array('status' => 1, 'id' => $id));
     if ($result) {
         $data = array('code' => 200, 'message' => 'SUCCESS', 'data' => $result);
     }
     return $data;
 }
示例#3
0
 public function run($id = null, $page = 1, $size = 2)
 {
     $this->controller->pageTitle = "Company";
     if (Yii::app()->request->isAjaxRequest) {
         if (!$id) {
             $id = User::model()->findByAttributes(array('id' => Yii::app()->user->id))->company;
         }
         $post = new CPost();
         $result = $post->getCompanyList($id, $page, $size);
         echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('list' => $result['data'])));
     } else {
         if ($id) {
             $company = Company::model()->findByAttributes(array('id' => $id));
             $service = Service_company::model()->findAllByAttributes(array('companyId' => $id, 'status' => 1));
             if ($service) {
                 foreach ($service as $list) {
                     $servicelist[] = Service::model()->findByAttributes(array('id' => $list['serviceId']));
                 }
             }
             $hub = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getCompanyList($id, $page, $size);
             //取出公司所有成员
             $member = User::model()->findAllByAttributes(array('company' => $id));
         } else {
             $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
             $company = Company::model()->findByAttributes(array('id' => $user['company']));
             $service = Service_company::model()->findAllByAttributes(array('companyId' => $company['id'], 'status' => 1));
             if ($service) {
                 foreach ($service as $list) {
                     $servicelist[] = Service::model()->findByAttributes(array('id' => $list['serviceId']));
                 }
             }
             $hub = Hub::model()->findByAttributes(array('id' => $company['location']));
             $post = new CPost();
             $postlist = $post->getCompanyList($company->id, $page, $size);
             $member = User::model()->findAllByAttributes(array('company' => $user['company']));
         }
         // print_r($company);die;
         $this->controller->render('profile', array('company' => $company, 'service' => $servicelist, 'location' => $hub['location'], 'postlist' => $postlist['data'], 'member' => $member));
     }
 }