Esempio n. 1
0
 public function actionCancel()
 {
     $success = BusinessShare::model()->deleteAll("ID=:id", array(":id" => Yii::app()->request->getParam("ID")));
     if ($success == 1) {
         $result['success'] = "共享状态删除成功!";
     } else {
         $result['errorMsg'] = "系统异常,共享状态删除失败!";
     }
     echo json_encode($result);
 }
Esempio n. 2
0
 public function actionSharecontact()
 {
     $organID = Commonmodel::getOrganID();
     $dealer = Dealer::model()->find('userID=:userid', array(':userid' => $organID));
     $share = BusinessShare::model()->findAll('InitiatorID=:intorID and Status=2', array(':intorID' => $organID));
     foreach ($share as $key => $value) {
         $shareID .= ',' . $value['ShareID'];
     }
     $shareID = ltrim($shareID, ",");
     //查出shareID
     $sql = "select a.id,a.contact_user_id,a.customertype,\n\t\t   a.cooperationtype,a.name,a.sex,\n\t\t   a.companyname,a.phone,a.province,a.city,a.area,a.email,\n\t\t   a.weixin,a.QQ,a.create_time,a.Status,a.jiapart_ID,a.update_time,\n\t\t   (select b.category from tbl_customer_category b where a.customercategory=b.id and a.user_id={$organID}) as customercategory\n\t\t   from tbl_business_contacts a where \n\t\t   user_id='{$organID}' and Status=0  and a.contact_user_id in({$shareID})";
     if ($_POST) {
         $search['name'] = $_POST['name'];
         $search['phone'] = $_POST['phone'];
         $search['keyword'] = $_POST['keyword'];
         if ($search) {
             if ($search['name']) {
                 $sql .= " and name like'%{$search['name']}%'";
             }
             if ($search['phone']) {
                 $sql .= " and phone like '%{$search['phone']}%'";
             }
             if ($search['keyword']) {
                 $sql .= " and (companyname like '%{$search['keyword']}%') ";
             }
         }
     }
     $sql .= "order by create_time desc";
     $criteria = new CDbCriteria();
     $models = Yii::app()->db->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = intval($_GET['rows']);
     $pages->applylimit($criteria);
     $models = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     foreach ($models as $key => $value) {
         $data[$key]['id'] = $value['id'];
         $data[$key]['Initiator'] = F::msubstr($dealer['organName']);
         $data[$key]['companyID'] = $value['contact_user_id'];
         //$data[$key]['customertype'] = $value['customertype'];
         $data[$key]['cooperationtype'] = $value['cooperationtype'];
         $data[$key]['customercategory'] = $value['customercategory'];
         $data[$key]['name'] = $value['name'];
         $data[$key]['sex'] = $value['sex'];
         $data[$key]['companyname2'] = F::msubstr($value['companyname']);
         $data[$key]['companyname'] = $value['companyname'];
         $data[$key]['phone'] = $value['phone'];
         $data[$key]['province'] = $value['province'];
         $data[$key]['city'] = $value['city'];
         $data[$key]['area'] = $value['area'];
         $data[$key]['address'] = F::msubstr(Area::getCity($value['province']) . Area::getCity($value['city']) . Area::getCity($value['area']));
         $data[$key]['email'] = $value['email'];
         $data[$key]['weixin'] = $value['weixin'];
         $data[$key]['QQ'] = $value['QQ'];
         $data[$key]['create_time'] = $value['create_time'];
         $data[$key]['Status'] = $value['Status'];
         $data[$key]['jiapart_ID'] = $value['jiapart_ID'];
         $data[$key]['update_time'] = $value['update_time'];
         //$data[$key]['checked']=true;
     }
     $rs = array('total' => $count, 'rows' => !empty($data) ? $data : array());
     echo json_encode($rs);
 }