Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ClientEmployee::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     \Yii::warning('yjhu_debugging: ' . \yii\helpers\Json::encode($params));
     \Yii::warning('yjhu_debugging: ' . \yii\helpers\Json::encode($this));
     $this->load($params);
     \Yii::warning('yjhu_debugging: ' . \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 = $query->joinWith('organizations');
     $query->andFilterWhere(['employee_id' => $this->employee_id, 'client_id' => $this->client_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $root_org = ClientOrganization::findOne(['organization_id' => $this->organization_id]);
     if (empty($root_org)) {
         $this->organization_id = 1;
         $root_org = ClientOrganization::findOne(['organization_id' => 1]);
     }
     $query->andFilterWhere(['client_organization.organization_id' => $root_org->getSubordinateIdArray()]);
     if (!empty($this->search_keyword)) {
         $query->leftJoin('client_employee_mobile', 'client_employee_mobile.employee_id = client_employee.employee_id');
         $query->andFilterWhere(['like', 'name', $this->search_keyword]);
         $query->orFilterWhere(['like', 'client_employee_mobile.mobile', $this->search_keyword]);
     }
     return $dataProvider;
 }
Пример #2
0
function echoJsTreeNode(ClientOutletSearch $searchModel, ClientOrganization $root)
{
    if (!$root->isMsc()) {
        return;
    }
    if ($searchModel->msc_id == $root->organization_id) {
        echo "<li data-jstree='{ \"selected\" : true, \"opened\": true }' organization_id=\"" . $root->organization_id . "\">" . $root->title;
    } else {
        echo "<li organization_id=\"" . $root->organization_id . '">' . $root->title;
    }
    if (!empty($root->directSubordinateOrganizations)) {
        echo '<ul>';
    }
    foreach ($root->directSubordinateOrganizations as $sub) {
        echoJsTreeNode($searchModel, $sub);
    }
    if (!empty($root->directSubordinateOrganizations)) {
        echo '</ul>';
    }
    echo '</li>';
}
Пример #3
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;
 }
Пример #4
0
 public function getSupervisionOrganization()
 {
     return $this->hasOne(\app\models\ClientOrganization::className(), ['organization_id' => 'supervision_organization_id']);
 }
Пример #5
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);
 }
Пример #6
0
 public function actionClientOrganization($gh_id, $openid, $organization_id, $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]);
     $organization = \app\models\ClientOrganization::findOne(['organization_id' => $organization_id]);
     $this->layout = false;
     return $this->render('client-organization', ['wx_user' => $wx_user, 'organization' => $organization, 'backwards' => $backwards]);
 }
Пример #7
0
 public function getOrganizations()
 {
     return $this->hasMany(\app\models\ClientOrganization::className(), ['organization_id' => 'organization_id'])->viaTable('client_employee_organization', ['employee_id' => 'employee_id']);
 }
Пример #8
0
 public function actionIndex()
 {
     echo 'Hello, world!!';
     //U::W(U::getQqAddress(114.253578, 30.585514));
     $arr = U::getMobileLocation('13871407676');
     if (!empty($arr['errcode'])) {
         U::W(['err', $arr]);
     } else {
         U::W($arr);
     }
     return;
     $clientOrganization = ClientOrganization::findOne(50);
     U::W($clientOrganization);
     $directSubordinateOrganizations = $clientOrganization->directSubordinateOrganizations;
     U::W($directSubordinateOrganizations);
 }
Пример #9
0
                    <div class="caption">
                        <span class="caption-subject">
                            <i class="fa fa-sitemap"></i>
                            部门
                        </span>
                        <span class="caption-helper">
                            选择部门进行过滤
                        </span>
                    </div>
                    <div class="actions"></div>
                </div>
                <div class="portlet-body">
                    <div id="organization_tree">
                            <ul>
                                <?php 
$root = \app\models\ClientOrganization::findOne(['organization_id' => 1]);
echoJsTreeNode($searchModel, $root);
?>
                            </ul>
                    </div>
                </div>
            </div>
             <div class="portlet light">
                 <div class="row">
                     <div id="member-promotion-daterange" class='pull-left' style="display:inline; margin-right: 30px;background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;">
                        <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
                        <span><?php 
echo date('Y年m月d日', strtotime('-1 month')) . ' 至 ' . date('Y年m月d日');
?>
</span> <b class="caret"></b>
                    </div>