Example #1
0
 /**
  * 获得地区名称
  * @return string
  */
 public static function getAreaNameById($id)
 {
     $areaLists = \Yii::$app->cache->get('cache_area');
     if (!$areaLists) {
         $area = Area::find()->where('1=1')->orderBy('id asc')->all();
         foreach ($area as $one) {
             $areaLists[$one->areaID] = $one->area;
         }
         \Yii::$app->cache->set('cache_area', $areaLists);
     }
     return $areaLists[$id];
 }
Example #2
0
 /**
  * 初始化与系统地址有关的文件缓冲
  */
 public static function initSysaddress()
 {
     $sysaddress = array();
     //配置ID与地区匹配缓冲
     $province = Province::find()->where('1=1')->orderBy('id asc')->all();
     $city = City::find()->where('1=1')->orderBy('father asc,id asc')->all();
     $area = Area::find()->where('1=1')->orderBy('father asc,id asc')->all();
     foreach ($province as $value) {
         $sysaddress['province'][$value->provinceID] = $value->province;
     }
     foreach ($city as $value) {
         $sysaddress['city'][$value->cityID] = $value->city;
     }
     foreach ($area as $value) {
         $sysaddress['area'][$value->areaID] = $value->area;
     }
     //配置多级联动操作相关缓冲
     $sysaddress['province_option'] = '';
     foreach ($province as $value) {
         $sysaddress['province_option'] .= '<option value="' . $value->provinceID . '">' . $value->province . '</option>';
     }
     $sysaddress['province_option'] = '<select name="province" class="qys_common_provice contactField requiredField">' . $sysaddress['province_option'] . '</select>';
     #获得所有城市列表并按照省份排序
     #先从缓冲获得数据
     $i = 0;
     $city_list_fit = '';
     foreach ($city as $value) {
         if ($value->father !== $i) {
             $city_list_fit .= '</select><select name="city" class="qys_common_city_' . $value->father . ' contactField requiredField">';
             $i = $value->father;
         }
         $city_list_fit .= '<option value="' . $value->cityID . '">' . $value->city . '</option>';
     }
     $city_list_fit .= '</select>';
     $city_list_fit = substr($city_list_fit, 9);
     $sysaddress['city_option'] = $city_list_fit;
     #获得所有城市列表并按照省份排序
     #先从缓冲获得数据
     $i = 0;
     $area_list_fit = '';
     foreach ($area as $value) {
         if ($value->father !== $i) {
             $area_list_fit .= '</select><select name="area" class="qys_common_area_' . $value->father . ' contactField requiredField">';
             $i = $value->father;
         }
         $area_list_fit .= '<option value="' . $value->areaID . '">' . $value->area . '</option>';
     }
     $area_list_fit .= '</select>';
     $area_list_fit = substr($area_list_fit, 9);
     $sysaddress['area_option'] = $area_list_fit;
     \Yii::$app->cache->set('sys_address', $sysaddress);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Area::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     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(['id' => $this->id]);
     $query->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'city', $this->city]);
     return $dataProvider;
 }
Example #4
0
<?php

/**
 * Created by PhpStorm.
 * User: JFog
 * Date: 7/16/2015
 * Time: 12:33 AM
 */
use common\components\helpers\Show;
use common\components\helpers\Convert;
use common\models\Area;
use common\models\Center;
use common\models\Station;
$areaList = Area::find()->all();
$centerList = Center::find()->all();
$query = Station::find()->select('id, name')->where([]);
if (isset($_GET['area']) && $_GET['area'] > 0) {
    $query->andWhere(['area_id' => $_GET['area']]);
}
if (isset($_GET['center']) && $_GET['center'] > 0) {
    $query->andWhere(['center_id' => $_GET['center']]);
}
$collections = $query->all();
$stationList[] = ['id' => '0', 'name' => 'Chọn trạm'];
if (!empty($collections)) {
    foreach ($collections as $col) {
        $stationList[] = ['id' => $col['id'], 'name' => $col['name']];
    }
}
//print '<pre>'; print_r($stationList); die;
?>
Example #5
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Area::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Example #6
0
                <h4 class="panel-title">
                    <i class="glyphicon glyphicon-phone"></i><span style="margin-right: 10px;">Danh sách trạm</span>
                </h4>
            </div>
        </div>

        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'summary' => false, 'columns' => [['attribute' => 'name', 'options' => ['width' => '15%']], ['attribute' => 'center_id', 'format' => 'text', 'filter' => Center::_prepareDataSelect(Center::find()->all(), 'id', 'name', false), 'value' => function ($model) {
    if ($model->center_id > 0) {
        $center = Center::findOne($model->center_id);
        if ($center) {
            return $center->name;
        }
    }
    return null;
}, 'options' => ['width' => '10%']], ['attribute' => 'area_id', 'format' => 'text', 'filter' => Area::_prepareDataSelect(Area::find()->all(), 'id', 'name', false), 'value' => function ($model) {
    $area = Area::findOne($model->area_id);
    return $area->name;
}, 'options' => ['width' => '10%']], ['attribute' => 'address'], ['label' => 'Báo động', 'format' => 'html', 'value' => function ($model) {
    $securitySensor = SensorStatus::findOne(['station_id' => $model->id, 'sensor_id' => Sensor::ID_SECURITY]);
    $label = Sensor::getSecurityStatus($securitySensor['value']);
    if ($securitySensor['value'] == Sensor::SECURITY_ON) {
        return Show::decorateString($label, 'good');
    } else {
        if ($securitySensor['value'] == Sensor::SECURITY_OFF) {
            return Show::decorateString($label, 'bad');
        }
    }
}, 'options' => ['width' => '10%']], ['attribute' => 'status', 'format' => 'html', 'filter' => $statusData, 'value' => function ($model) {
    if ($model->status == Station::STATUS_CONNECTED) {
        $html = Show::decorateString($model->getStatus($model->status), 'good');
Example #7
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     // parse data
     $parseData = ['model' => $model];
     // check if not has dc status and sensor status, then create them
     //if (!$model->dc_equip_status) $this->initDc($id);
     if (!$model->sensor_status) {
         $this->initSensor($id);
     }
     // get all equipment
     $parseData['equipments'] = Equipment::findAll(['active' => Equipment::STATUS_ACTIVE]);
     // get equipment of station
     $parseData['equipmentIds'] = $model->equipment;
     // get all power equipment
     $parseData['powerEquipments'] = PowerEquipment::find()->all();
     // get equipment of station
     $parseData['powerEquipmentIds'] = $model->power_equipment;
     // get dc equipment of this station
     $parseData['dcEquipmentIds'] = $model->dc_equip_ids;
     // get all dc equipment
     $parseData['dcEquipments'] = DcEquipment::find()->where(['active' => DcEquipment::STATUS_ACTIVE])->all();
     // get area
     $areaCollections = Area::find()->all();
     $parseData['areas'] = Area::_prepareDataSelect($areaCollections, 'id', 'name');
     // get center
     $centerCollections = Center::find()->all();
     $parseData['centers'] = Center::_prepareDataSelect($centerCollections, 'id', 'name');
     // get station types
     $typeCollection = StationType::findAll(['active' => StationType::STATUS_ACTIVE]);
     $parseData['types'] = Station::_prepareDataSelect($typeCollection, 'type', 'name');
     // change left menu
     $this->setDetailLeftMenu($id);
     $post = Yii::$app->request->post();
     if ($post) {
         $model->load($post);
         if ($model->validate()) {
             $model->save();
             // get new model
             $newModel = $this->findModel($id);
             // update equipment
             if (isset($post['equipments'])) {
                 $this->setEquipment($post['equipments'], $newModel);
             }
             // update power equipment
             if (isset($post['dc_equipments'])) {
                 $this->setPowerEquipment($post['power_equipments'], $newModel);
             }
             // update dc equipment
             if (isset($post['dc_equipments'])) {
                 $this->setDcEquipment($post['dc_equipments'], $newModel);
             }
             //write log action
             Log::logControl(Yii::$app->user->id, Log::ACTION_UPDATE_STATION, $id);
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', $parseData);
 }
Example #8
0
 /**
  * get catList
  * @author Cangzhou Wu<*****@*****.**>
  * @param $cat_id
  * @param bool $city  city list flag
  * @return array
  */
 public function getList($cat_id, $city = true)
 {
     $cities = Area::find()->where(['parent_id' => $cat_id])->all();
     $catList = [];
     if ($city) {
         foreach ($cities as $s) {
             $catList[] = ['id' => $s->area_id, 'name' => $s->name];
         }
     } else {
         foreach ($cities as $s) {
             $catList['out'][] = ['id' => $s->area_id, 'name' => $s->name];
         }
         $catList['selected'] = $s->area_id;
     }
     return $catList;
 }
Example #9
0
?>
</h3>
    
        <p class="action">
            <?php 
echo Html::a('会员列表', ['index'], ['class' => 'btn btn-success']);
?>
        </p>
    </div>

    <?php 
Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['consignee', ['header' => Html::a('地址', 'javascript:;'), 'content' => function ($model) {
    $area = Area::find()->where(['id' => [$model->province, $model->city, $model->district]])->asArray()->all();
    $str = '';
    foreach ($area as $val) {
        $str .= $val['name'] . ' ';
    }
    if ($model->default == 1) {
        $str .= '<span style="color: red">[默认]</span>';
    }
    $str .= '<br/>' . $model->address;
    return $str;
}], ['header' => Html::a('联系方式', 'javascript:;'), 'content' => function ($model) {
    $data = '手机:' . $model->mobile . '<br/>邮编:' . $model->zipcode;
    return $data;
}]]]);
?>
    <?php 
Example #10
0
 public function actionIndex()
 {
     // default time duration
     $timePoints = Convert::currentTimePoints();
     $getBy = Yii::$app->request->get('get_by');
     if ($getBy == 'week') {
         $timePoints = Convert::currentWeekTimePoints();
     } else {
         if ($getBy == 'month') {
             $timePoints = Convert::currentMonthTimePoints();
         }
     }
     $whereClause = ['sst.sensor_id' => Sensor::ID_SECURITY];
     // get station ids by role
     $role = new Role();
     if (!$role->isAdministrator) {
         $position = $role->getPosition();
         $stationIds = Station::getByRole($position, Yii::$app->user->id);
         $whereClause['s.id'] = $stationIds;
     }
     // get data
     $query = new Query();
     $stations = $query->select('s.area_id, s.status AS station_status, sst.value AS sensor_value, count(w.id) AS total_warning, max(w.warning_time) AS last_warning_time')->from('station s')->leftJoin('sensor_status sst', 'sst.station_id = s.id')->leftJoin('warning w', 'w.station_id = s.id')->where($whereClause)->groupBy('s.id')->all();
     // data
     $parseData = [];
     $data = [];
     // get areas
     $areas = Area::find()->all();
     $parseData['areas'] = $areas;
     if (!empty($areas)) {
         $notHave = [];
         foreach ($areas as $area) {
             $have = 0;
             $data[$area['id']]['has_warning'] = 0;
             $data[$area['id']]['no_warning'] = 0;
             $data[$area['id']]['security_on'] = 0;
             $data[$area['id']]['security_off'] = 0;
             $data[$area['id']]['connected'] = 0;
             $data[$area['id']]['lost_connect'] = 0;
             $data[$area['id']]['last_warning_time'] = 0;
             // security and connect stations
             if (!empty($stations)) {
                 foreach ($stations as $station) {
                     if ($station['area_id'] == $area['id']) {
                         $have = 1;
                         // warnings
                         if ($station['total_warning'] > 0 && $station['last_warning_time'] >= $timePoints['start'] && $station['last_warning_time'] <= $timePoints['end']) {
                             $data[$area['id']]['has_warning']++;
                             $data[$area['id']]['last_warning_time'] = $station['last_warning_time'] > $data[$area['id']]['last_warning_time'] ? $station['last_warning_time'] : $data[$area['id']]['last_warning_time'];
                         } else {
                             $data[$area['id']]['no_warning']++;
                         }
                         // status
                         if ($station['station_status'] == Station::STATUS_CONNECTED) {
                             $data[$area['id']]['connected']++;
                         } else {
                             if ($station['station_status'] == Station::STATUS_LOST) {
                                 $data[$area['id']]['lost_connect']++;
                             }
                         }
                         // security mode
                         if ($station['sensor_value'] == Sensor::SECURITY_ON) {
                             $data[$area['id']]['security_on']++;
                         } else {
                             if ($station['sensor_value'] == Sensor::SECURITY_OFF) {
                                 $data[$area['id']]['security_off']++;
                             }
                         }
                     }
                 }
             }
             if ($have == 0) {
                 $notHave[] = $area['id'];
             }
         }
         if (!empty($notHave)) {
             foreach ($notHave as $not) {
                 unset($data[$not]);
             }
         }
     }
     $parseData['data'] = $data;
     return $this->render('station', $parseData);
 }
?>
	<p>(in kg)</p>
    <?php 
echo $form->field($model2, 'weight')->textInput();
?>

    <?php 
echo $form->field($model2, 'religion')->textInput(['maxlength' => true]);
?>
	
	<h2>Academic Background</h2>
	<?php 
echo $form->field($model3, 'location')->textInput(['maxlength' => true]);
?>
	<?php 
echo $form->field($model3, 'location')->dropDownList(ArrayHelper::map(Area::find()->all(), 'id', 'location'), ['prompt' => 'Select HS location']);
?>

    <?php 
echo $form->field($model3, 'type')->dropDownList(['MAPSA' => 'MAPSA', 'Public School' => 'Public School'], ['prompt' => '']);
?>

    <?php 
echo $form->field($model3, 'hs_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model3, 'section')->textInput();
?>

    <?php