예제 #1
0
파일: CommonForm.php 프로젝트: zwq/unpei
 /**
  * 登记入库
  */
 public function Add($modelName, $return)
 {
     $user_id = Commonmodel::getOrganID();
     if ($_POST[$modelName]) {
         $post = $_POST[$modelName];
         if ($modelName == 'MakeEmpowerDealer') {
             $make = MakeEmpowerDealer::model()->findByPk($post['id']);
             if (empty($make)) {
                 $telephone = $_POST['telephone'];
                 $dealer = Dealer::model()->find("Phone='{$telephone}'");
                 if (empty($dealer)) {
                     Yii::app()->db->createCommand()->insert('tbl_user', array('username' => $telephone, 'password' => md5($telephone), 'email' => $telephone . '@jiaparts.com', 'status' => '1', 'create_at' => date('Y-m-d H-i-s', time()), 'identity' => '2'));
                     $newuserID = Yii::app()->db->getLastInsertID();
                     Yii::app()->db->createCommand()->insert('tbl_profiles', array('user_id' => $newuserID));
                     Yii::app()->db->createCommand()->insert('tbl_dealer', array('userID' => $newuserID, 'organName' => $post['organName'], 'jiapartsId' => $telephone, 'loginPassword' => md5($telephone), 'Phone' => $telephone));
                     $post['dealer_id'] = Yii::app()->db->getLastInsertID();
                 } else {
                     $post['dealer_id'] = $dealer->id;
                 }
                 $make = new MakeEmpowerDealer();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeContacts') {
             $make = MakeContacts::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeContacts();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeDistributionBusiness') {
             $make = MakeDistributionBusiness::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeDistributionBusiness();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeStorageService') {
             $make = MakeStorageService::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeStorageService();
             }
             $post['up_userID'] = $user_id;
         } elseif ($modelName == 'MakeTechniqueService') {
             $make = MakeTechniqueService::model()->findByPk($post['id']);
             if (empty($make)) {
                 $make = new MakeTechniqueService();
             }
             $post['up_userID'] = $user_id;
             $post['serviceTime'] = $_POST['beginWeek'] . '至' . $_POST['endWeek'] . ' ' . $_POST['beginHour'] . '-' . $_POST['endHour'];
         }
         $make->attributes = $post;
         $make->save();
         $this->redirect(array($return));
     }
 }
예제 #2
0
 /**
  * 单个删除列表中的数据
  */
 public function actionDelete()
 {
     if ($_GET['id']) {
         switch ($_GET['key']) {
             case 'emp':
                 $return = MakeEmpowerDealer::model()->deleteByPk($_GET['id']);
                 break;
             case 'tech':
                 $return = MakeTechniqueService::model()->deleteByPk($_GET['id']);
                 break;
             case 'cont':
                 $return = MakeContacts::model()->deleteByPk($_GET['id']);
                 break;
             case 'dis':
                 $return = MakeDistributionBusiness::model()->deleteByPk($_GET['id']);
                 break;
             case 'emca':
                 $return = MakeEmpowerCategory::model()->deleteByPk($_GET['id']);
                 MakeEmpowerCategoryRelation::model()->deleteAll("cate_id = {$_GET['id']}");
                 break;
             case 'stor':
                 $return = MakeStorageService::model()->deleteByPk($_GET['id']);
                 break;
         }
     }
     echo $return;
 }
예제 #3
0
 /**
  * 检查授权经销商登记使用的手机号是否存在
  */
 public function actionCheckorgan()
 {
     $telephone = $_GET['telephone'];
     $organName = $_GET['organName'];
     $user_id = Commonmodel::getOrganID();
     $model = Dealer::model()->findAll("Phone='{$telephone}' and organName!='{$organName}'");
     if (!empty($model)) {
         $result = 1;
     } else {
         $model2 = Dealer::model()->findAll("Phone!='{$telephone}' and organName='{$organName}'");
         if (!empty($model2)) {
             $result = 2;
         } else {
             $model1 = MakeEmpowerDealer::model()->findAll("organName='{$organName}' and up_userID = {$user_id}");
             if (!empty($model1)) {
                 $result = 3;
             } else {
                 $dealer = Dealer::model()->find("Phone='{$telephone}' and organName='{$organName}'");
                 $model3 = MakeEmpowerDealer::model()->findAll("dealer_id='{$dealer->id}' and up_userID = {$user_id}");
                 if (!empty($model3)) {
                     $result = 4;
                 } else {
                     $result = 100;
                 }
             }
         }
     }
     echo json_encode($result);
 }
예제 #4
0
 public function actionEmpowerdealer()
 {
     $this->layout = '//layouts/dealer';
     $models = MakeEmpowerDealer::model()->findAll();
     //var_dump($models);
     $this->render('empowerdealer', array('models' => $models));
 }