public static function getOrganName() { $organName = Yii::app()->user->getState('organName'); if ($organName) { return $organName; } //先获取角色身份(生产商/经销商/修理厂) $organName = ""; // $userid = Yii::app()->user->id; $userid = Commonmodel::getOrganID(); $model = self::getIdentity($userid); if ($model['identity'] == 1) { $organ = MakeOrgan::model()->find('userID=:userid', array(':userid' => $userid)); $organName = $organ['name']; } else { if ($model['identity'] == 2) { $organ = Dealer::model()->find('userID=:userid', array(':userid' => $userid)); $organName = $organ['organName']; } else { if ($model['identity'] == 3) { $organ = Service::model()->find('userId=:userid', array(':userid' => $userid)); $organName = $organ['serviceName']; } } } Yii::app()->user->setState('organName', $organName); return $organName; }
public function actionOrgan() { $user_id = Commonmodel::getOrganID(); // $ids = $user_id; $businessContacts = BusinessContacts::model()->findAll('user_id=:user_id and Status=0', array(':user_id' => $user_id)); foreach ($businessContacts as $key => $val) { if ($val['contact_user_id']) { $ids[] = $val['contact_user_id']; } } $ids[] = $user_id; //新增的联系人不能是添加者本人 $ids = implode(',', $ids); //经销商数据 $i = 0; $model = Dealer::model()->findAll("userID not in ({$ids}) and !ISNULL(organName)"); foreach ($model as $key => $value) { $data[$i]['companyname'] = $value['organName']; $data[$i]['userID'] = $value['userID']; // $data[$key]['companytype']=$value['userID']; $result = User::model()->findByPk($value['userID']); switch ($result['identity']) { case 1: $data[$i]['companytype'] = '生产商'; break; case 2: $data[$i]['companytype'] = '经销商'; break; case 3: $data[$i]['companytype'] = '修理厂'; } $i++; } //修理厂 $model = Service::model()->findAll("userId not in ({$ids}) and !ISNULL(serviceName)"); foreach ($model as $key => $value) { $data[$i]['companyname'] = $value['serviceName']; $data[$i]['userID'] = $value['userId']; //$data[$value['userId']]['companytype']=$value['userId']; $result = User::model()->findByPk($value['userId']); switch ($result['identity']) { case 1: $data[$i]['companytype'] = '生产商'; break; case 2: $data[$i]['companytype'] = '经销商'; break; case 3: $data[$i]['companytype'] = '修理厂'; } $i++; } //生产商 // $model=Yii::app()->db->createCommand() // ->select('*') // ->from('tbl_make_organ') // ->queryAll(); $model = MakeOrgan::model()->findAll("userID not in ({$ids})"); foreach ($model as $key => $value) { $data[$i]['companyname'] = $value['name']; $data[$i]['userID'] = $value['userID']; //$data[$key]['companytype']=$value['userID']; $result = User::model()->findByPk($value['userID']); switch ($result['identity']) { case 1: $data[$i]['companytype'] = '生产商'; break; case 2: $data[$i]['companytype'] = '经销商'; break; case 3: $data[$i]['companytype'] = '修理厂'; } $i++; } $rs = array('total' => 1000, 'rows' => $data); echo json_encode($rs); }
public static function getMakeName($makeid) { $makerNanme = MakeOrgan::model()->find('userID=:userID', array(':userID' => $makeid)); return $makerNanme['name']; }
/** * 修改机构信息 */ private function updateOrgan($mobphone, $qq, $email) { $userID = Yii::app()->user->id; $usertype = User::model()->find('id=' . $userID); // 获取会员的类型 if ($usertype['identity'] == 1) { // 生产商 $bool = MakeOrgan::model()->updateByPk($userID, array('mobile_phone' => $mobphone, 'qq' => $qq)); } elseif ($usertype['identity'] == 2) { // 经销商 $bool = Dealer::model()->updateAll(array('Phone' => $mobphone, 'QQ' => $qq), 'userID=:userID', array(':userID' => $userID)); } elseif ($usertype['identity'] == 3) { // 修理厂 $bool = Service::model()->updateByPk($userID, array('serviceCellPhone' => $mobphone, 'serviceQQ' => $qq)); } else { //用户不存在 $bool = false; } return $bool; }
/** * 主营信息管理 */ public function actionMainbusiness() { $this->pageTitle = Yii::app()->name . '-' . "主营登记"; $userID = Commonmodel::getOrganID(); if ($_POST['brand'] || $_POST['cp_name'] || $_POST['delcpids']) { $message = "保存成功"; } else { $message = ''; } // if (!empty($_POST['brand'])) { // $model = MakeOrgan::model()->updateAll(array('businessBrand' => $_POST['brand']), 'userID=:userID', array(':userID' => $userID)); // } if ($_POST) { $BigName = $_POST['BigName']; $SubName = $_POST['SubName']; $CpName = $_POST['CpName']; $BigpartsID = $_POST['BigpartsID']; $SubCodeID = $_POST['SubCodeID']; $CpNameID = $_POST['CpNameID']; $cplegth = count($BigpartsID); if ($cplegth > 0) { for ($j = 0; $j < $cplegth; $j++) { $mogr = new DealerCpname(); $mogr->OrganID = $userID; $mogr->BigName = $BigName[$j]; $mogr->SubName = $SubName[$j]; $mogr->CpName = $CpName[$j]; $mogr->BigpartsID = $BigpartsID[$j]; $mogr->SubCodeID = $SubCodeID[$j]; $mogr->CpNameID = $CpNameID[$j]; $mogr->save(); } } } if (!empty($_POST['delcpids'])) { $result = DealerCpname::model()->deleteAll("ID in ({$_POST['delcpids']})"); } $model = MakeOrgan::model()->find('userID=:userID', array(':userID' => $userID)); $showcpname = DealerCpname::model()->findAll('OrganID=:userID', array(':userID' => $userID)); $this->render('mainbusiness', array('model' => $model, 'showcpnames' => $showcpname, 'message' => $message)); }
/** * 品牌厂家的详细信息 */ public function actionIndexdetail() { $userID = $_GET['maker_id']; $model = MakeOrgan::model()->find("userID=:userID", array(':userID' => $userID)); $makerpic = MakeOrganPicture::model()->findAll("userID=:userID", array(':userID' => $userID)); $this->render("indexdetail", array('model' => $model, 'makerpic' => $makerpic)); }