Exemplo n.º 1
0
 /**
  * 登记入库
  */
 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));
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 /**
  * 添加联系人页面
  */
 public function actionAddcontacts()
 {
     if ($_GET['id']) {
         $model = MakeContacts::model()->findByPk($_GET['id']);
     } else {
         $model = new MakeContacts();
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'make-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     CommonForm::Add('MakeContacts', 'contacts');
     $this->render('addcontacts', array('model' => $model));
 }