示例#1
0
 public static function addOutletAgent($agent_name, $agent_mobile, $agent_position, $outlet_id)
 {
     $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]);
     if (empty($outlet)) {
         return json_encode(['code' => -1, 'errMsg' => "门店不存在!({$outlet_id})"]);
     }
     $agent = self::find()->join('INNER JOIN', 'client_agent_mobile', 'client_agent.agent_id=client_agent_mobile.agent_id')->where(['name' => $agent_name, 'mobile' => $agent_mobile])->one();
     if (!empty($agent)) {
         //            return json_encode([
         //                'code'      => -1,
         //                'errMsg'    => "{$agent_name}({$agent_mobile})已存在!",
         //            ]);
     } else {
         $agent = new self();
         $agent->name = $agent_name;
         $agent->save(false);
         \Yii::$app->db->createCommand()->insert('client_agent_mobile', ['agent_id' => $agent->agent_id, 'mobile' => $agent_mobile])->execute();
     }
     $row = (new \yii\db\Query())->select('*')->from('client_agent_outlet')->where(['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id])->one();
     if (false === $row) {
         \Yii::$app->db->createCommand()->insert('client_agent_outlet', ['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id, 'position' => $agent_position])->execute();
     } else {
         return json_encode(['code' => -1, 'errMsg' => "{$agent_name}({$agent_mobile})已存在门店{$outlet->title}中!"]);
     }
     return json_encode(['code' => 0]);
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ClientOutlet::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 24]]);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($params));
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($this));
     $this->load($params);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($this));
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['outlet_id' => $this->outlet_id, 'client_id' => $this->client_id, 'supervision_organization_id' => $this->supervision_organization_id, 'category' => $this->category, 'longitude' => $this->longitude, 'latitude' => $this->latitude, 'original_office_id' => $this->original_office_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'pics', $this->pics]);
     $query->andFilterWhere(['supervision_organization_id' => ClientOrganization::findOne(['organization_id' => $this->msc_id])->getMscIdArray()]);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($query));
     return $dataProvider;
 }
示例#3
0
 public function actionOutlets()
 {
     $outlets = \app\models\ClientOutlet::find()->all();
     foreach ($outlets as $outlet) {
         $office = \app\models\MOffice::find()->where(['title' => $outlet->title])->one();
         if (!empty($office)) {
             echo "found {$outlet->title}" . PHP_EOL;
             $details = \app\models\MOfficeCampaignDetail::findAll(['office_id' => $office->office_id]);
             $pics = [];
             foreach ($details as $detail) {
                 $pic_urls = explode(',', $detail->pic_url);
                 foreach ($pic_urls as $pic_url) {
                     $from = $detail->getPicFileByMedia($pic_url);
                     $media = str_replace('.jpg', '', $pic_url);
                     $to = $outlet->getPicPathname($media);
                     copy($from, $to);
                     $pics[] = $media;
                 }
             }
             $outlet->pics = implode(",", $pics);
             $outlet->original_office_id = $office->office_id;
             $outlet->latitude = $office->lat;
             $outlet->longitude = $office->lon;
             $outlet->save(false);
         }
     }
 }
示例#4
0
 public function actionAgent($filename = 'agent.csv')
 {
     $xyunicom = \app\models\WosoClient::findOne(['title_abbrev' => '襄阳联通']);
     if (empty($xyunicom)) {
         die('不能找到襄阳联通。');
     }
     $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($filepathname, "r");
     while (!feof($fh)) {
         $contact_person = trim($fields[0]);
         $contact_person_utf8 = iconv('GBK', 'UTF-8//IGNORE', $contact_person);
         $msc_brev_name = trim($fields[1]);
         $msc_brev_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $msc_brev_name);
         $title = trim($fields[2]);
         $title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $title);
         $mobiles = explode(';', trim($fields[3]));
         //            echo "{$contact_person_utf8},{$msc_brev_name_utf8},{$title_utf8},{$fields[3]}".PHP_EOL;
         $supervision_organization = \app\models\ClientOrganization::find()->where(['like', 'title', $msc_brev_name_utf8])->andWhere(['client_id' => $xyunicom->client_id])->one();
         //            $supervision_organization = \Yii::$app->db->createCommand('select * from client_organization where title like \'%:title%\'')
         //                    ->bindValue(':title', $msc_brev_name_utf8)->queryOne();
         if (empty($supervision_organization)) {
             die("找不到{$msc_brev_name_utf8}");
         }
         //            var_dump($supervision_organization);
         $row = false;
         foreach ($mobiles as $mobile) {
             $mobile = trim($mobile);
             $row = (new \yii\db\Query())->select('*')->from('client_agent')->join('INNER JOIN', 'client_agent_mobile', ['client_agent.agent_id' => 'client_agent_mobile.agent_id'])->where(['name' => $contact_person_utf8, 'mobile' => $mobile])->one();
             if (false !== $row) {
                 break;
             }
         }
         if (false !== $row) {
             $agent = \app\models\ClientAgent::findOne(['agent_id' => $row['agent_id']]);
         } else {
             $agent = new \app\models\ClientAgent();
             $agent->name = $contact_person_utf8;
             $agent->save(false);
         }
         $outlet = \app\models\ClientOutlet::findOne(['title' => $title_utf8]);
         if (empty($outlet)) {
             $outlet = new \app\models\ClientOutlet();
             $outlet->title = $title_utf8;
             $outlet->client_id = $xyunicom->client_id;
             $outlet->telephone = $fields[3];
             $outlet->category = \app\models\ClientOutlet::CATEGORY_COOPERATED;
             $outlet->supervison_organization_id = $supervision_organization->organization_id;
             $outlet->save(false);
         } else {
             $outlet->client_id = $xyunicom->client_id;
             $outlet->telephone = $fields[3];
             $outlet->category = \app\models\ClientOutlet::CATEGORY_COOPERATED;
             $outlet->supervison_organization_id = $supervision_organization->organization_id;
             $outlet->save(false);
         }
         $row = (new \yii\db\Query())->select('*')->from('client_agent_outlet')->where(['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id])->one();
         if (false === $row) {
             \Yii::$app->db->createCommand()->insert('client_agent_outlet', ['agent_id' => $agent->agent_id, 'outlet_id' => $outlet->outlet_id, 'position' => '店主'])->execute();
         }
         foreach ($mobiles as $mobile) {
             if (strlen($mobile) != 11 || !is_numeric($mobile)) {
                 echo "[{$mobile}]非手机号码." . PHP_EOL;
             } else {
                 $row = (new \yii\db\Query())->select('*')->from('client_agent_mobile')->where(['mobile' => $mobile])->one();
                 if (false === $row) {
                     \Yii::$app->db->createCommand()->insert('client_agent_mobile', ['agent_id' => $agent->agent_id, 'mobile' => $mobile])->execute();
                 }
             }
         }
     }
     fclose($fh);
 }
示例#5
0
文件: Custom.php 项目: noikiy/wowewe
 public function getManageOutlet()
 {
     return $this->hasOne(\app\models\ClientOutlet::className(), ['original_office_id' => 'office_id', 'client_id' => 'client_id']);
 }
示例#6
0
 public function actionClientOutletEmployeeEdit($gh_id, $openid, $backwards = true, $pop = false)
 {
     if (!$backwards) {
         \app\models\utils\BrowserHistory::delete($gh_id, $openid);
         \app\models\utils\BrowserHistory::push($gh_id, $openid);
     } else {
         if ($pop) {
             \app\models\utils\BrowserHistory::pop($gh_id, $openid);
         } else {
             \app\models\utils\BrowserHistory::push($gh_id, $openid);
         }
     }
     $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     $this->layout = false;
     $is_agent = $_GET['is_agent'];
     $outlet_id = $_GET['outlet_id'];
     if ($is_agent) {
         $agent_id = $_GET['entity_id'];
         $entity = \app\models\ClientAgent::findOne(['agent_id' => $agent_id]);
     } else {
         $employee_id = $_GET['entity_id'];
         $entity = \app\models\ClientEmployee::findOne(['employee_id' => $employee_id]);
     }
     $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]);
     return $this->render('client-outlet-employee-edit', ['wx_user' => $wx_user, 'entity' => $entity, 'is_agent' => $is_agent, 'outlet' => $outlet, 'backwards' => $backwards]);
 }
示例#7
0
文件: yggl1.php 项目: noikiy/wowewe
    <header class="bar bar-nav">

      <a class="icon icon-left-nav pull-left" id="btn_back" onclick="back2pre();"></a>

      <h1 class="title">
      <!--
      <img src="../web/images/comm-icon/iconfont-liwu.png?v5" width="18">&nbsp;
      -->
       员工管理
      </h1>

    </header>

    <?php 
$outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]);
?>

    <!-- Wrap all non-bar HTML in the .content div (this is actually what scrolls) -->
    <div class="content">
    <p class="content-padded">
      <table width="100%" border=0 style="padding:3px;text-align:center">
      <tr>

        <td width=100%>
          <button class="btn btn-positive btn-block">
    
              <?php 
echo $outlet->title;
?>
员工总数
示例#8
0
 /**
  * Finds the ClientOutlet model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ClientOutlet the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ClientOutlet::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#9
0
 public function getOutlets()
 {
     return $this->hasMany(\app\models\ClientOutlet::className(), ['supervision_organization_id' => 'organization_id']);
 }
示例#10
0
 public function actionYgglxiugaiajax()
 {
     $is_agent = $_GET['is_agent'];
     $entity_id = $_GET['entity_id'];
     $outlet_id = $_GET['outlet_id'];
     $mobile = $_GET['mobile'];
     $position = $_GET['position'];
     $outlet = \app\models\ClientOutlet::findOne(['outlet_id' => $outlet_id]);
     if ($is_agent) {
         $ret = $outlet->alterAgent($entity_id, $mobile, $position);
     } else {
         $ret = $outlet->alterEmployee($entity_id, $mobile, $position);
     }
     if (false === $ret) {
         return json_encode(['code' => -1]);
     } else {
         return json_encode(['code' => 0]);
     }
 }
示例#11
0
文件: MUser.php 项目: noikiy/wowewe
 public function getPromoteOutlet()
 {
     return $this->hasOne(\app\models\ClientOutlet::className(), ['original_office_id' => 'belongto']);
 }
示例#12
0
文件: MOffice.php 项目: noikiy/wowewe
 public function getOutlet()
 {
     return $this->hasOne(ClientOutlet::className(), ['original_office_id' => 'office_id']);
 }