public function actionEditmoreinfo($user_id) { $user_more_info = UserInfoAR::model()->findByPk($user_id); $this->assign('user_more', $user_more_info); $maritalStatus = MaritalStatus::model()->findAll(); // 'MaritalStatus', 'marital_status_id'), $hometown = Hometown::model()->findAll(); // 'Province', 'hometown_id'), $nation = Nation::model()->findAll(); // 'Nation', 'nation_id'), $bodyType = BodyType::model()->findAll(); // 'BodyType', 'body_type_id'), $education = Education::model()->findAll(); // 'Education', 'education_id'), $school = School::model()->findAll(); // 'School', 'school_id'), $province = Province::model()->findAll(); // 'Province', 'province_id'), $job = Job::model()->findAll(); // '$maritalSta, $this->assign('maritalStatus', $maritalStatus); $this->assign('hometown', $hometown); $this->assign('nation', $nation); $this->assign('bodyType', $bodyType); $this->assign('education', $education); $this->assign('school', $school); $this->assign('province', $province); $this->assign('job', $job); }
public static function getLocation($ward_id, $district_id, $province_id) { $ward_type = null; $ward_name = null; $district_type = null; $district_name = null; $province_type = null; $province_name = null; if (isset($ward_id)) { $ward = Ward::model()->findByPk($ward_id); if ($ward) { $ward_type = $ward->type; $ward_name = $ward->name; } } if (isset($district_id)) { $district = District::model()->findByPk($district_id); if ($district) { $district_type = $district->type; $district_name = $district->name; } } if (isset($province_id)) { $province = Province::model()->findByPk($province_id); if ($province) { $province_type = $province->type; $province_name = $province->name; } } return $ward_type . " " . $ward_name . ", " . $district_type . " " . $district_name . ", " . $province_type . " " . $province_name; }
public function getDropdown() { global $dataDropdown; $dataDropdown = array(); $parents = Province::model()->findALl('t.status=1 ORDER BY t.name'); foreach ($parents as $parent) { $dataDropdown[$parent->id] = $parent->name; } return $dataDropdown; }
public function actionListCity() { // $data=::model()->findAll('referid=:referid', if (isset($_POST['provinceId'])) { $provinceId = $_POST['provinceId']; } $cities = Province::model()->findByPk($provinceId)->cities; // $data=CHtml::listData($data,'id','name'); foreach ($cities as $city) { echo CHtml::tag('option', array('value' => $city->id), CHtml::encode($city->name), true); } }
public static function saveProAddress(UserProudctAddress $userprodaddress, $user_id) { $_POST['UserProudctAddress']['province'] = 'xx'; $_POST['UserProudctAddress']['city'] = 'xx'; $_POST['UserProudctAddress']['area'] = 'xx'; $_POST['UserProudctAddress']['sysaddress'] = 'xx'; if (isset($_POST['province'])) { $_POST['UserProudctAddress']['province'] = $_POST['province']; $provincename = Province::model()->find("provinceID=:proid", array(":proid" => $_POST['UserProudctAddress']['province'])); if ($provincename) { $_POST['UserProudctAddress']['sysaddress'] = $provincename->province; } } if (isset($_POST['city'])) { $_POST['UserProudctAddress']['city'] = $_POST['city']; $cityname = City::model()->find("cityID=:cityid", array(":cityid" => $_POST['UserProudctAddress']['city'])); if ($cityname) { $_POST['UserProudctAddress']['sysaddress'] .= $cityname->city; } } if (isset($_POST['area'])) { $_POST['UserProudctAddress']['area'] = $_POST['area']; $areaname = Area::model()->find("areaID=:areaid", array(":areaid" => $_POST['UserProudctAddress']['area'])); if ($areaname) { $_POST['UserProudctAddress']['sysaddress'] .= $areaname->area; } } $_POST['UserProudctAddress']['user_id'] = $user_id; $userprodaddress->setAttributes($_POST['UserProudctAddress']); foreach ((array) $_POST['UserProudctAddress'] as $key => $value) { if (trim($value) == '') { $userprodaddress->addError($key, "字段不能为空"); break; } } if (!$userprodaddress->getErrors()) { $userprodaddress->setAttribute('addtime', time()); $userprodaddress->setAttribute('addip', Yii::app()->request->userHostAddress); if ($userprodaddress->validate()) { if ($userprodaddress->isNewRecord) { $result = $userprodaddress->save(); } else { $result = $userprodaddress->update(); } if (!$result) { $userprodaddress->addError("realname", "更新失败"); } } else { $userprodaddress->addError("realname", "更新失败"); } } return $userprodaddress; }
/** *用户有可能输入四种情况: * 1.景点名 * 2.城市名 * 3.国家名 * 4.省的名字 * 5.一个数据库没有的名字 * 6.要从行政数据库里面查找名字 */ public function authenticate($location) { //先判断这是否是一个景点名 if ($this->find('name=:name', array(':name' => $location))) { return $this->_flag = self::SECENIC; } else { if (City::model()->loadModel($location)) { return $this->_flag = self::CITY; } else { if (Province::model()->loadModel($location)) { return $this->_flag = self::PROVINCE; } else { return $this->_flag = self::INVAILD; } } } }
/** * 地区联动 */ public function actionUpdateDistricts() { $areastring = "area_"; $data = Yii::app()->cache->get($areastring . (int) $_POST['idCity']); if (!$data) { $dataArea = Area::model()->findAll('father=:idCity', array(':idCity' => (int) $_POST['idCity'])); if (!$dataArea) { $dataArea = City::model()->findAll('cityID=:idCity', array(':idCity' => (int) $_POST['idCity'])); if (!$dataArea) { $dataArea = Province::model()->findAll('provinceID=:idCity', array(':idCity' => (int) $_POST['idCity'])); $data = CHtml::listData($dataArea, 'provinceID', 'province'); } else { $data = CHtml::listData($dataArea, 'cityID', 'city'); } } else { $data = CHtml::listData($dataArea, 'areaID', 'area'); } Yii::app()->cache->set($areastring . (int) $_POST['idCity'], $data); } echo "<option value=''>选择区域</option>"; foreach ($data as $value => $name) { echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true); } }
<div class="panel panel-default" style="color: black"> <div class="panel-header"> <a href="<?php echo yii::app()->baseUrl; ?> /city/export" class="btn btn-primary"><i class="fa fa fa-download"></i> Export</a> <a href="<?php echo yii::app()->baseUrl; ?> /city/import" class="btn btn-primary"><i class="fa fa fa-upload"></i> Import</a> <a href="<?php echo yii::app()->baseUrl; ?> /city/clear" onclick="return confirm('Yakin ingin menghapus semua data provinsi?')" class="btn btn-primary"><i class="fa fa fa-trash"></i>Bersihkan Data</a> </div> <div class="pael-body"> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'city-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), array('name' => 'province_code', 'value' => 'isset($data->province->name)?$data->province->name:""', 'filter' => Province::model()->getOptionsCodeName()), 'name', array('class' => 'bootstrap.widgets.TbButtonColumn')))); ?> </div> </div>
public function actionArticleOfArea() { $criteria = new CDbCriteria(); $criteria->addCondition("t.active=1"); $criteria->addCondition("t.delete=0"); $criteria->order = "t.order, t.id DESC"; if (isset($_POST['Province']) && isset($_POST['District'])) { if ((int) $_POST['District'] > 0) { $criteria->addCondition("t.scope=" . (int) $_POST['District']); } else { if ((int) $_POST['Province'] > 0) { $province = Province::model()->findByPk((int) $_POST['Province']); if ($province === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $arrayIDs = array(); foreach ($province->districts as $district) { $arrayIDs[] = $district->id; } $criteria->addInCondition("t.scope", $arrayIDs); } } } $count = ArticleOfArea::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = Config::model()->getValueByKey('rowsperpagearticle'); $pages->applyLimit($criteria); $models = ArticleOfArea::model()->findAll($criteria); $pageTitle = Yii::t('site', 'Guitar các tỉnh'); $metaDescription = Config::model()->getValueByKey('metadescription'); $metaKeywords = Config::model()->getValueByKey('metakeywords'); $this->pageTitle = $pageTitle . ' - ' . Config::model()->getValueByKey('sitetitle'); $this->metaDescription = $metaDescription; $this->metaKeywords = $metaKeywords; // danh sach cac category $criteria = new CDbCriteria(); $criteria->addCondition("t.active=1"); $criteria->addCondition("t.delete=0"); $criteria->addCondition("t.id!=1"); $criteria->order = "t.order, t.id DESC"; $categories = ArticleCategories::model()->findAll($criteria); $this->render('articleOfArea', array('models' => $models, 'categories' => $categories, 'pages' => $pages)); }
</div> <div class="form-group"> <label class="control-label col-lg-3 col-md-3 col-sm-4 col-xs-4">พระถูกสร้างที่จังหวัด<small> *</small></label> <div class="col-lg-3 col-md-4 col-sm-4 col-xs-8"> <select class="form-control input-lg" name="province" id="province" required> <option value="" selected>-- กรุณาเลือก --</option> <?php foreach ($listRegion as $index => $region) { ?> <optgroup label=" ภูมิภาค <?php echo $region->reg_name; ?> " style="font-weight: bold;"> <?php $listProvince = Province::model()->findAll(array('condition' => 'reg_id = ' . $region->reg_id, 'order' => 'pro_name_th')); ?> <?php foreach ($listProvince as $index => $province) { ?> <?php if ($province->pro_id == $sacredObject->pro_id) { ?> <option value="<?php echo $province->pro_id; ?> " selected><?php echo $province->pro_name_th; ?> </option> <?php
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'city-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->dropDownListRow($model, "province_code", Province::model()->getOptionsCodeName(), array("prompt" => "Pilih Provinsi", "class" => "autocomplete")); ?> <?php echo $form->textFieldRow($model, 'code', array('class' => 'span5', 'maxlength' => 256)); echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 256)); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Tambah' : 'Simpan')); ?> <!--<a href="<?php // echo yii::app()->baseUrl; ?> /city/admin" class="btn btn-primary">Batal</a>--> </div>
public function actionInputPharmacy() { $this->checkLogin(); $ward = Ward::model()->findAll(); $district = District::model()->findAll(); $province = Province::model()->findAll(); $this->render('inputPharmacy', array('ward' => $ward, 'district' => $district, 'province' => $province)); }
public function exportExcel($objPHPExcel, $models) { $sheet = $objPHPExcel->getActiveSheet(); $row = 1; $referenceRow = 2; $reference = Province::model()->findAll(); //Write main data that used on import to cell if ($models) { foreach ($models as $model) { $provinceCode = $model->province_code; $cityCode = str_replace($provinceCode . '.', '', $model->code); $sheet->setCellValueExplicit('A' . ++$row, $provinceCode, PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValueExplicit('B' . $row, $cityCode, PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValue('C' . $row, isset($model->name) ? $model->name : NULL); } } //Write reference data to cell if ($reference) { foreach ($reference as $data) { $sheet->setCellValueExplicit('D' . ++$referenceRow, isset($data->code) ? $data->code : NULL, PHPExcel_Cell_DataType::TYPE_STRING); $sheet->setCellValue('E' . $referenceRow, isset($data->name) ? $data->name : NULL); } } $objPHPExcel->getActiveSheet()->setTitle('Daftar Kota'); }
public function actionSearchUser() { $model = new SearchUserForm(); if (Yii::app()->request->isAjaxRequest) { if (isset($_POST['SearchUserForm'])) { if ($_POST['SearchUserForm']['username'] !== '') { $model->username = $_POST['SearchUserForm']['username']; } else { $model->attributes = $_POST['SearchUserForm']; } $criteria = $model->getCriteria(); //Page manager $count = User::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = 16; $pages->applyLimit($criteria); $searchResult = User::model()->findAll($criteria); $this->renderPartial('_searchUserResult', array('searchResult' => $searchResult, 'pages' => $pages)); } } else { $provinces = Province::model()->findAll(); $provinces = CHtml::listData($provinces, 'idProvince', 'name'); $criteria = $model->getCriteria(); //Page manager $count = User::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = 16; $pages->applyLimit($criteria); $searchResult = User::model()->findAll($criteria); $this->render('searchUser', array('searchResult' => $searchResult, 'pages' => $pages, 'model' => $model, 'provinces' => $provinces)); } }
<?php $this->widget('ext.jqrelcopy.JQRelcopy', array('id' => 'copylink', 'removeText' => '<i></i>', 'removeHtmlOptions' => array('class' => 'fa fa-fw fa-trash'), 'options' => array('copyClass' => 'newcopy', 'limit' => 5, 'clearInputs' => true, 'excludeSelector' => '.skipcopy'))); ?> <a id="copylink" href="#" rel=".copy">Copy</a> <div class="copy"> <?php echo CHtml::dropDownList('code[]', "string", Subcomponent::model()->getSubcomponentOptions(), array('prompt' => 'Pilih Paket Pekerjaan')); ?> <?php echo CHtml::dropDownList('ppk_code[]', "string", Ppk::model()->getPpkOptions(), array('prompt' => 'Pilih PPK')); ?> </br> <?php echo CHtml::dropDownList('province_code[]', "string", Province::model()->getOptionsCodeName(), array('prompt' => 'Pilih Provinsi')); ?> <?php echo CHtml::dropDownList('city_code[]', "string", City::model()->getOptionsCodeName(), array('prompt' => 'Pilih Kab/Kota')); ?> </div> </br> </br> <div class="clearfix"></div>
<?php $this->widget('ext.dropDownChain.VDropDownChain', array('parentId' => 'province', 'childId' => 'city', 'url' => 'package/getCity', 'valueField' => 'code', 'textField' => 'name')); $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'package-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?> <?php echo $form->errorSummary($model); if ($model->isNewRecord) { ?> <?php echo $form->dropDownList($model, 'code', Subcomponent::model()->getSubcomponentOptions(), array("prompt" => "Pilih Paket")); } echo $form->dropDownList($model, 'province_code', Province::model()->getOptionsCodeName(), array("prompt" => "Pilih Provinsi", 'id' => 'province')); ?> <?php echo $form->dropDownList($model, 'city_code', City::model()->getOptionsCodeName(), array("prompt" => "Pilih Kota", 'id' => 'city')); ?> <?php echo $form->dropDownList($model, 'ppk_code', Ppk::model()->getPpkOptions(), array("prompt" => "Pilih PPK")); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Tambah' : 'Simpan')); ?> </div>
<?php $this->breadcrumbs = array('Cities' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List City', 'url' => array('index')), array('label' => 'Create City', 'url' => array('create'))); ?> <h1>Manage Cities</h1> <div> <?php echo CHtml::link('Add City', array('city/create')); ?> </div> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'city-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'summaryText' => '', 'pager' => array('header' => '', 'firstPageLabel' => '| <', 'lastPageLabel' => '> |', 'nextPageLabel' => '>', 'prevPageLabel' => '<'), 'columns' => array('city_id', array('name' => 'province_id', 'type' => 'html', 'value' => '$data->province->province_name', 'sortable' => TRUE, 'filter' => CHtml::listData(Province::model()->findAll(), 'province_id', 'province_name')), 'city_name', array('class' => 'CButtonColumn', 'template' => '{update} {delete}'))));
<div id="qys_address_show"> <select name="province" class="qys_common_provice form-control"> <?php #获得所有省份列表 #先从缓冲获得数据 $provice_list = Yii::app()->cache->get("qys_common_provice"); if (!$provice_list) { $provice_list = Province::model()->findAll("1=1 order by id asc"); } if ($provice_list) { foreach ($provice_list as $value) { echo '<option value="' . $value->provinceID . '">' . $value->province . '</option>'; } Yii::app()->cache->set("qys_common_provice", $provice_list); } else { echo '<option value="0">无法加载</option>'; } ?> </select> <?php #获得所有城市列表并按照省份排序 #先从缓冲获得数据 $city_list_fit = Yii::app()->cache->get("qys_common_city"); //$city_list_fit=FALSE; if (!$city_list_fit) { $city_list = City::model()->findAll("1=1 order by father asc,id asc"); if ($city_list) { $i = 0; $city_list_fit = ''; foreach ($city_list as $value) { if ($value->father !== $i) {
/** * Check completeness data of master * @return boolean */ public function checkMaster() { $complete = false; $ppk = Ppk::model()->exists(); $satker = Satker::model()->exists(); $activity = Activity::model()->exists(); $output = Output::model()->exists(); $suboutput = Suboutput::model()->exists(); $component = Component::model()->exists(); $subcomponent = Subcomponent::model()->exists(); $account = Account::model()->exists(); $province = Province::model()->exists(); $city = City::model()->exists(); if ($ppk && $satker && $activity && $output && $suboutput & $component && $subcomponent && $account && $province && $city) { $complete = TRUE; } return $complete; }
<div class="panel panel-warning" id="boxPrakreungRegion"> <div class="panel-heading" role="tab" id="headingOne"> <h6 class="panel-title" style="font-size: 0.6em;"> <?php echo $listRegion->reg_name; ?> (<?php echo $listRegion->cnt; ?> จังหวัด)<i class="glyphicon glyphicon-chevron-down"></i> </h6> </div> <div class="panel-collapse"> <div class="panel-body"> <?php $listProvinceByRegion = Province::model()->findAllByAttributes(array('reg_id' => $listRegion->reg_id), array('order' => 'pro_name_th')); foreach ($listProvinceByRegion as $key => $province) { ?> <div class="checkbox"> <label> <input type="checkbox" value="<?php echo $province->pro_id; ?> "> <?php echo $province->pro_name_th; ?> </label> </div> <?php }
/** * Export Data to Excel */ public function actionExport() { /** Get model */ $models = Province::model()->findAll(); /** Error reporting */ $this->excelErrorReport(); /** PHPExcel_IOFactory */ $objReader = new PHPExcel(); $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $path = Yii::app()->basePath . '/../export/province.xlsx'; $pathExport = Yii::app()->basePath . '/../files/Master Provinsi.xlsx'; $objPHPExcel = $objReader->load($path); $objPHPExcel->setActiveSheetIndex(0); /* " Add new data to template" */ $this->exportExcel($objPHPExcel, $models); /** Export to excel* */ $this->excel($objPHPExcel, $pathExport); readfile($pathExport); unlink($pathExport); exit; }
public function actionGetMapHouse() { ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); $criteria->select = 'id,municipality,lp_dol,num_kit,construction_year,depth,front_ft,br,addr,house_image,longitude,latitude,area,bath_tot'; /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.construction_year asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.construction_year desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id if (!empty($_POST['country']) && trim($_POST['country']) != 'undefined') { $criteria->addCondition("t.city_id = :city_id"); $criteria->params += array(':city_id' => intval($_POST['country'])); } //district_id if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { $criteria->addCondition("t.district_id = :district_id"); $criteria->params += array(':district_id' => intval($_POST['district'])); } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.bath_tot = :bath_tot"); $criteria->params += array(':bath_tot' => intval($_POST['housebaths'])); } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]) * 10000; $maxPrice = intval($price[1]) * 10000; if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br >= :br"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br = :br"); } } $criteria->params += array(':br' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { $criteria->addSearchCondition('propertyType_id', $_POST['housetype']); } //根据地区名字搜索 if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { $city = trim($_POST['city']); $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); } //建造年份 if (!empty($_POST['houseyear'])) { //$year = explode(',', $_POST['houseyear']); $year = $_POST['houseyear']; //$minYear = intval($year[0]); // $maxYear = intval($year[1]); $criteria->addCondition("t.yr_built = :year"); $criteria->params += array(':year' => $year); } //lat and long selection if (!empty($_POST['bounds'])) { $latlon = explode(',', $_POST['bounds']); $minLat = floatval($latlon[0]); $maxLat = floatval($latlon[2]); $minLon = floatval($latlon[1]); $maxLon = floatval($latlon[3]); $criteria->addCondition("t.latitude <= :maxLat"); $criteria->params += array(':maxLat' => $maxLat); $criteria->addCondition("t.latitude >= :minLat"); $criteria->params += array(':minLat' => $minLat); $criteria->addCondition("t.longitude <= :maxLon"); $criteria->params += array(':maxLon' => $maxLon); $criteria->addCondition("t.longitude >= :minLon"); $criteria->params += array(':minLon' => $minLon); } $criteria->with = array('mname', 'propertyType'); //$criteria->with = array('municipality'=>array('select'=>array('municipality_cname')),'propertyType'); $house = House::model()->findAll($criteria); $maxmarkers = 2000; $totalcount = count($house); $result['Data']['Total'] = $totalcount; //error_log(count($house)); //数据重组 $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); if (!empty($house) && $totalcount < $maxmarkers) { error_log("HouseList Start:" . $totalcount); $result['Message'] = '成功'; $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); foreach ($house as $val) { $mapHouseList = array(); $mapHouseList['Beds'] = $val->br; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->num_kit; $mapHouseList['GeocodeLat'] = $val->latitude; $mapHouseList['GeocodeLng'] = $val->longitude; $mapHouseList['Address'] = $val->addr; $mapHouseList['sqft'] = $val->sqft; $mapHouseList['Price'] = $val->lp_dol / 10000; $mapHouseList['Id'] = $val->id; $mapHouseList['HouseType'] = !empty($val->propertyType->name) ? $val->propertyType->name : '其他'; $mapHouseList['MunicipalityName'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $mapHouseList['CountryName'] = $val->municipality; $mapHouseList['Country'] = $val->city_id; $mapHouseList['Money'] = 'CAD'; //$area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; $mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->yr_built; $result['Data']['MapHouseList'][] = $mapHouseList; //数据总数拼装 if (!empty($countryInfo)) { $provinceInfo = Province::model()->findByPk($countryInfo->province_id); } if (intval($_POST['zoom']) < 14 && intval($_POST['zoom']) >= 6) { $result['Data']['AreaHouseCount'][$val->municipality]['Count']['NameCn'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['HouseCount'] += 1; //$result['Data']['AreaHouseCount'][$val->city_id]['Count'] ['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLat'] = !empty($val->mname->lat) ? $val->mname->lat : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLng'] = !empty($val->mname->lng) ? $val->mname->lng : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } else { if (intval($_POST['zoom']) < 6) { if (!empty($provinceInfo)) { $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLat'] = $provinceInfo->lat; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLng'] = $provinceInfo->lnt; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$provinceInfo->id]['List'][] = $mapHouseList; } } } } //} else { // $result['IsError'] = true; // $result['Message'] = '无数据'; } if (!empty($house) && $totalcount >= $maxmarkers) { error_log("City Count Start:" . $totalcount); $result['Message'] = '成功'; foreach ($house as $val) { $result['Data']['AreaHouseCount'][$val->municipality]['Count']['NameCn'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['HouseCount'] += 1; //$result['Data']['AreaHouseCount'][$val->city_id]['Count'] ['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLat'] = !empty($val->mname->lat) ? $val->mname->lat : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLng'] = !empty($val->mname->lng) ? $val->mname->lng : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } } //error_log(json_encode($result)) ; } //error_log(json_encode($result)) ; echo json_encode($result); }
var url=' . CJSON::encode(Yii::app()->baseUrl . "/package/childUpdate") . '; var packageCode=arr.model["code"]; var ppkCode=arr.model["ppk_code"]; var provinceCode=arr.model["province_code"]; var cityCode=arr.model["city_code"]; $.ajax({ url: url, dataType: "json", data: { code: packageCode, cityCode: cityCode, provinceCode: provinceCode, ppkCode:ppkCode, }, }); }')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'province_code', 'sortable' => false, 'value' => 'isset($data->province->name)?$data->province->name:"-"', 'filter' => Province::model()->getOptionsCodeName(), 'editable' => array('type' => 'select', 'url' => $this->createUrl('editable'), 'placement' => 'bottom', 'inputclass' => 'span3', 'source' => Province::model()->getOptionsCodeName(), 'success' => 'js: function(data) { var arr=JSON.parse(data); var url=' . CJSON::encode(Yii::app()->baseUrl . "/package/childUpdate") . '; var packageCode=arr.model["code"]; var ppkCode=arr.model["ppk_code"]; var provinceCode=arr.model["province_code"]; var cityCode=arr.model["city_code"]; $.ajax({ url: url, dataType: "json", data: { code: packageCode, cityCode: cityCode, provinceCode: provinceCode, ppkCode:ppkCode, },
public function getNativePlaceProvince() { $province = Province::model()->findByPk($this->nativePlaceProvinceId); return is_null($province) ? false : $province->province_name; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Province the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Province::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionUpload() { parent::actionUpload(); $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/'; // folder for uploaded files $file = $folder . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $row = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row > 0) { $model = City::model()->findByPk((int) $data[0]); if ($model === null) { $model = new City(); } $model->cityid = (int) $data[0]; $province = Province::model()->findbyattributes(array('provincename' => $data[1])); if ($province !== null) { $model->provinceid = $province->provinceid; } $model->cityname = $data[2]; $model->recordstatus = (int) $data[3]; try { if (!$model->save()) { $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]); } } catch (Exception $e) { $this->messages = $this->messages . $e->getMessage(); } } $row++; } } else { $this->messages = $this->messages . ' memory or harddisk full'; } fclose($handle); } else { $this->messages = $this->messages . ' check your directory permission'; } if ($this->messages == '') { $this->messages = 'success'; } echo $this->messages; }
public function actionProvinceDelete($id) { if (Province::model()->findByPk($id)->delete()) { $this->redirect(array('sacred/indexProvince')); } }
public function getRows($pq) { $rows = $pq->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']"); $n = count($rows); echo 'Jumlah propinsi: ' . $n . " \n"; $count = 0; foreach ($rows as $value) { $count++; $row = pq($value); $kolom_provinsi = $row->find('td:eq(1) > a'); $nama_provinsi = $kolom_provinsi->text(); $link_provinsi = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolom_provinsi->attr('href')) . '&perhal=1000'; echo sprintf("Memproses propinsi %d dari %d\n", $count, $n); echo sprintf("Propinsi: %s Link: %s\n", $nama_provinsi, $link_provinsi); $province = Province::model()->findByAttributes(array('name' => $nama_provinsi)); if (!$province instanceof Province) { $province = new Province(); $province->name = $nama_provinsi; if (!$province->save()) { throw new CException('Cannot save province'); } } $countdistrict = 0; $pqDist = phpQuery::newDocumentHtml($this->getContents($link_provinsi)); $rowsDist = $pqDist->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']"); $nDist = count($rowsDist); $countDist = 0; foreach ($rowsDist as $valueDist) { $countDist++; $rowDist = pq($valueDist); switch ($rowDist->find('td:eq(2)')->text()) { case 'Kota': $tipeDist = 'kota'; break; default: case 'Kab.': $tipeDist = 'kabupaten'; break; } $kolomDist = $rowDist->find('td:eq(3) > a'); $namaDist = $kolomDist->text(); $linkDist = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomDist->attr('href')) . '&perhal=1000'; echo sprintf("Memproses distrik " . $province->name . " %d dari %d\n", $countDist, $nDist); echo sprintf("Distrik: %s Link: %s\n", $namaDist, $linkDist); $distrik = District::model()->findByAttributes(array('name' => $namaDist, 'province_id' => $province->id, 'type' => $tipeDist)); if (!$distrik instanceof District) { $distrik = new District(); $distrik->name = $namaDist; $distrik->type = $tipeDist; $distrik->province_id = $province->id; if (!$distrik->save()) { throw new CException('Cannot save district'); } } $pqZone = phpQuery::newDocumentHtml($this->getContents($linkDist)); $rowsZone = $pqZone->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']"); $nZone = count($rowsZone); $countZone = 0; foreach ($rowsZone as $valueZone) { $countZone++; $rowZone = pq($valueZone); $kolomZone = $rowZone->find('td:eq(4) > a'); $namaZone = $kolomZone->text(); $linkZone = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomZone->attr('href')) . '&perhal=1000'; echo sprintf("Memproses zone %d dari %d\n", $countZone, $nZone); echo sprintf("zone: %s Link: %s\n", $namaZone, $linkZone); $new_zone = false; $zone = Zone::model()->findByAttributes(array('name' => $namaZone, 'district_id' => $distrik->id)); if (!$zone instanceof Zone) { $zone = new Zone(); $zone->name = $namaZone; $zone->active = 1; $zone->district_id = $distrik->id; if (!$zone->save()) { throw new CException('Cannot save Zone'); } $new_zone = true; } echo 'sukses saving zone' . "\n"; $countArea = 0; $pqArea = phpQuery::newDocumentHtml($this->getContents($linkZone)); $rowsArea = $pqArea->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']"); $nArea = count($rowsArea); // Let's speed up things a bit $trans = Yii::app()->db->beginTransaction(); foreach ($rowsArea as $valueArea) { $countArea++; $rowArea = pq($valueArea); $kolomArea = $rowArea->find('td:eq(2) > a'); $kolomKodePos = $rowArea->find('td:eq(1)'); $namaArea = $kolomArea->text(); $kodePos = $kolomKodePos->text(); $linkKodePos = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomArea->attr('href')) . '&perhal=1000'; $area = $new_zone ? null : Area::model()->findByAttributes(array('name' => $namaArea, 'zone_id' => $zone->id)); if (!$area instanceof Area) { $area = new Area(); $area->name = $namaArea; $area->postcode = $kodePos; $area->zone_id = $zone->id; if (!$area->save()) { throw new CException('Cannot save area'); } } echo 'Sukses Saving Code Post' . "/n kode pos adalah " . $area->postcode . "\n"; } $trans->commit(); } } } }
echo $form->labelEx($model, 'entry_address'); ?> <?php echo $form->textArea($model, 'entry_address', array('cols' => 43, 'rows' => 3)); ?> <?php echo $form->error($model, 'entry_address'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'entry_province_id'); ?> <?php echo $form->dropDownList($model, 'entry_province_id', CHtml::listData(Province::model()->findAll(), 'province_id', 'province_name'), array('empty' => '--please select--')); ?> <?php echo $form->error($model, 'entry_province_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'entry_city_id'); ?> <?php echo $form->dropDownList($model, 'entry_city_id', CHtml::listData(City::model()->findAll(), 'city_id', 'city_name'), array('empty' => '--please select--')); ?> <?php echo $form->error($model, 'entry_city_id');
public function actionGetMapHouse() { $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); // $criteria->join = 'join city_id as b on b.id = t.city_id'; // $criteria->join .= ' join propertyType_id as c on c.id = t.propertyType_id'; /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.yr_built asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.yr_built desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id if (!empty($_POST['country']) && trim($_POST['country']) != 'undefined') { $criteria->addCondition("t.city_id = :city_id"); $criteria->params += array(':city_id' => intval($_POST['country'])); } //district_id if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { $criteria->addCondition("t.district_id = :district_id"); $criteria->params += array(':district_id' => intval($_POST['district'])); } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.toilet_num = :toilet_num"); $criteria->params += array(':toilet_num' => intval($_POST['housebaths'])); } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]); $maxPrice = intval($price[1]); if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br_plus >= :bedroom_num"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br_plus = :bedroom_num"); } } $criteria->params += array(':br_plus' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { if ($_POST['housetype'] == 1) { $criteria->addCondition('type_own1_out="Detached"'); } elseif ($_POST['housetype'] == 2) { $criteria->addCondition('type_own1_out="Townhouse" or type_own1_out="Att∕Row∕Twnhouse" or type_own1_out="Triplex" or type_own1_out="Fourplex" or type_own1_out="Multiplex"'); } elseif ($_POST['housetype'] == 3) { $criteria->addCondition('lp_dol>3000000'); } elseif ($_POST['housetype'] == 4) { $criteria->addCondition('type_own1_out="Semi-Detached" or type_own1_out="Link" or type_own1_out="Duplex"'); } elseif ($_POST['housetype'] == 5) { $criteria->addCondition('type_own1_out="Cottage" or type_own1_out="Rural Resid"'); } elseif ($_POST['housetype'] == 6) { $criteria->addCondition('type_own1_out="Farm"'); } elseif ($_POST['housetype'] == 7) { $criteria->addCondition('type_own1_out="Vacant Land"'); } elseif ($_POST['housetype'] == 8) { $criteria->addCondition('type_own1_out="Mobile/Trailer" or type_own1_out="Det W/Com Elements" or type_own1_out="Store W/Apt/offc"'); } // $criteria->addCondition("t.propertyType_id = :propertyType_id"); // $criteria->params += array(':propertyType_id' => intval($_POST['housetype'])); } //根据地区名字搜索 if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { $city = trim($_POST['city']); $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); } //建造年份 if (!empty($_POST['houseyear'])) { $year = explode(',', $_POST['houseyear']); $minYear = intval($year[0]); $maxYear = intval($year[1]); if ($maxYear != 0 || $minYear != 0) { if ($maxYear > $minYear) { $criteria->addCondition("t.yr <= :maxYear"); $criteria->params += array(':maxYear' => $maxYear); } $criteria->addCondition("t.yr >= :minYear"); $criteria->params += array(':minYear' => $minYear); } } $house = House::model()->findAll($criteria); //经纬度范围 if ((empty($_POST['city']) || trim($_POST['city']) == '州名/市名(中英)') && empty($_POST['country']) && !empty($_POST['city'])) { if (!empty($house)) { $bound = explode(',', $_POST['bounds']); foreach ($house as $key => $val) { $jingweidu = actionGetCodeAddress2($val->country . $val->community . $val->addr); if (floatval($val->latitude) >= floatval($bound[0]) && floatval($jingweidu['lat']) <= floatval($bound[2]) && floatval($jingweidu['lng']) >= floatval($bound[1]) && floatval($jingweidu['lng']) <= floatval($bound[3])) { } else { unset($house[$key]); } } } } $count = count($house); //数据重组 if (!empty($house)) { $result['Message'] = '成功'; $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); foreach ($house as $key => $val) { $jingweidu = actionGetCodeAddress2($val->country . $val->community . $val->addr); $mapHouseList = array(); $mapHouseList['Beds'] = $val->br_plus; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->kit_plus; $mapHouseList['GeocodeLat'] = $jingweidu['lat']; $mapHouseList['GeocodeLng'] = $jingweidu['lng']; $mapHouseList['Address'] = $val->addr; $mapHouseList['Price'] = $val->lp_dol; $mapHouseList['Id'] = $val->id; $propertyType = PropertyType::model()->findByPk($val->propertyType_id); $mapHouseList['HouseType'] = !empty($propertyType) ? $propertyType->name : ''; $countryInfo = City::model()->findByPk($val->city_id); $mapHouseList['CountryName'] = !empty($countryInfo) ? $countryInfo->name : ''; $mapHouseList['Country'] = $val->city_id; $mapHouseList['Money'] = 'CAD'; $area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; $mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->construction_year; $result['Data']['MapHouseList'][] = $mapHouseList; //数据总数拼装 if (!empty($countryInfo)) { $provinceInfo = Province::model()->findByPk($countryInfo->province_id); } if (intval($_POST['zoom']) < 10 && intval($_POST['zoom']) >= 6) { $result['Data']['AreaHouseCount'][$val->city_id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['GeocodeLng'] = !empty($countryInfo) ? $countryInfo->lnt : ''; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->city_id]['List'][] = $mapHouseList; } else { if (intval($_POST['zoom']) < 6) { if (!empty($provinceInfo)) { $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLat'] = $provinceInfo->lat; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLng'] = $provinceInfo->lnt; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$provinceInfo->id]['List'][] = $mapHouseList; } } } } } else { $result['IsError'] = true; $result['Message'] = '无数据'; } } echo json_encode($result); }