public function actionView($id) { $lesson = $this->loadModel($id); $userId = $this->_cookiesGet('userId'); $userType = $this->_cookiesGet('userType'); $this->_seoTitle = '课程 - ' . $lesson->name; //取报名人数 $actual_students_criteria = new CDbCriteria(); $actual_students = StudentLesson::model()->count($actual_students_criteria->addCondition("lesson_id =" . $id)); $lesson->actual_students = $actual_students; $teacher = Teacher::model()->findByPk($lesson->teacher_id); $place = Place::model()->findByPk($lesson->place_id); //教学环境图片显示 $imageList = $this->_gets->getParam('imageList'); $imageListSerialize = XUtils::imageListSerialize($imageList); //判断学员已收藏的课程 if ($userType === 'student') { $is_focus = StudentLesson::model()->findByAttributes(array('student_id' => $userId, 'lesson_id' => $id, 'is_collection' => 1)); } if ($imageList) { $imageList = $imageListSerialize['data']; } elseif ($place->pic_other) { $imageList = unserialize($place->pic_other); } $this->render('view', array('is_focus' => $is_focus, 'isJoin' => $this->isJoin($userId, $id, 1), 'userType' => $userType, 'lesson' => $lesson, 'place' => $place, 'teacher' => $teacher, 'imageList' => $imageList)); }
public function actionUpdatePlace() { $model = Place::model()->findByPk($_GET['id']); if (isset($_POST['Place'])) { $model->attributes = $_POST['Place']; $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(192, 470))); $adr = XUpload::upload($_FILES['pic_adr'], array('thumb' => true, 'thumbSize' => array(498, 364))); $other = XUpload::upload($_FILES['pic_other'], array('thumb' => true, 'thumbSize' => array(900, 600))); if (is_array($file)) { $model->pic = $file['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if (is_array($adr)) { $model->pic_adr = $adr['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if (is_array($other)) { $model->pic_other = $other['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if ($model->validate() && $model->save()) { $this->redirect(array('/host/default/myplace')); } } $this->render('addplace', array('model' => $model)); }
public function actionUpdatePlace() { $model = Place::model()->findByPk($_GET['id']); $imageList = $this->_gets->getParam('imageList'); $imageListSerialize = XUtils::imageListSerialize($imageList); if (isset($_POST['Place'])) { $model->attributes = $_POST['Place']; $model->pic_other = $imageListSerialize['dataSerialize']; $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(192, 470))); $adr = XUpload::upload($_FILES['pic_adr'], array('thumb' => true, 'thumbSize' => array(498, 364))); if (is_array($file)) { $model->pic = $file['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if (is_array($adr)) { $model->pic_adr = $adr['paththumbname']; @unlink($_POST['oAttach']); @unlink($_POST['oThumb']); } if ($model->validate() && $model->save()) { $this->redirect(array('/host/default/myplace')); } } if ($imageList) { $imageList = $imageListSerialize['data']; } elseif ($model->pic_other) { $imageList = unserialize($model->pic_other); } $this->render('addplace', array('model' => $model, 'imageList' => $imageList)); }
public function loadModel($id) { $model = Place::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionView($id) { // require a place id as param // retrieve a place from db using the id $places = Place::model()->findAllByAttributes(array('id' => $id)); // organise place object into an array $rows = array(); foreach ($places as $place) { $rows[] = array('id' => $place->id, 'type' => $place->type, 'name' => $place->name, 'detail' => $place->detail, 'pic' => $place->pic, 'comments' => $this->getComments($place->id)); } // render view a place page with a place info $this->render('view', array('places' => $places)); }
public function actionView($id) { $lesson = $this->loadModel($id); $userId = $this->_cookiesGet('userId'); $userType = $this->_cookiesGet('userType'); $this->_seoTitle = '课程 - ' . $lesson->name; //取报名人数 $actual_students_criteria = new CDbCriteria(); $actual_students = StudentLesson::model()->count($actual_students_criteria->addCondition("lesson_id =" . $id)); $lesson->actual_students = $actual_students; $teacher = Teacher::model()->findByPk($lesson->teacher_id); $place = Place::model()->findByPk($lesson->place_id); //判断学员已收藏的课程 if ($userType === 'student') { $is_focus = StudentLesson::model()->findByAttributes(array('student_id' => $userId, 'lesson_id' => $id, 'is_collection' => 1)); } $this->render('view', array('is_focus' => $is_focus, 'isJoin' => $this->isJoin($userId, $id, 1), 'userType' => $userType, 'lesson' => $lesson, 'place' => $place, 'teacher' => $teacher)); }
public function actionListName($type, $term) { $term = addcslashes($term, '%_'); $criteria = new CDbCriteria(); if (strlen($type) == 0) { // if not select a type, create criteria with only name LIKE $criteria->condition = "name LIKE :term"; $criteria->params = array(':term' => "%{$term}%"); } else { // if select a type, create criteria with name LIK and the selected type $criteria->condition = "name LIKE :term AND type=:type"; $criteria->params = array(':term' => "%{$term}%", ':type' => $type); } // get only 'name' from table $criteria->select = "name"; $places = Place::model()->findAll($criteria); $names = array(); foreach ($places as $place) { $names[] = $place->name; } echo json_encode($names); }
public function actionIndex() { $this->_seoTitle = '中国传统文化教育|东方美学|中式精致生活|我要去上课'; $placeCriteria = new CDbCriteria(); $teacherCriteria = new CDbCriteria(); $picCriteria = new CDbCriteria(); $placeCriteria->limit = '3'; $placeCriteria->order = 'id DESC'; $placeCriteria->addCondition('status = :status'); $placeCriteria->params[':status'] = 1; $teacherCriteria->limit = '8'; $teacherCriteria->order = 'id DESC'; $teacherCriteria->addCondition('status = :status'); $teacherCriteria->params[':status'] = 1; $picCriteria->limit = '4'; $picCriteria->order = 'id DESC'; $picCriteria->addCondition('check_status = :check_status'); $picCriteria->params[':check_status'] = 1; $lesson = Lesson::model()->findByAttributes(array('id' => '5')); $place = Place::model()->findAll($placeCriteria); $teacher = Teacher::model()->findAll($teacherCriteria); $pic = Lesson::model()->findAll($picCriteria); $this->render('index', array('place' => $place, 'teacher' => $teacher, 'lesson' => $lesson, 'pic' => $pic)); }
protected function beforeDelete() { //delete images for these records if uploaded $placeInfo = Place::model()->find('createdByUserId=' . Yii::app()->user->getId() . ' AND title is NULL'); if (count($placeInfo) > 0) { $fileInfos = File::model()->findAll("recordId=" . $placeInfo->id . " AND recordType='Place'"); if (count($fileInfos) > 0) { foreach ($fileInfos as $fileInfo) { $dirPath = $fileInfo->fullPath . '/'; if (GalleryImage::model()->findByPk($fileInfo->id)->delete()) { if (@rmdir($dirPath)) { return true; } } } } } return true; }
public function actionReview() { $message = false; $place = Place::model()->findByPk($_GET['id']); $host = Host::model()->findByPk($place['host_id']); $model = PlaceReview::model()->findByAttributes(array('place_id' => $_GET['id'], 'teacher_id' => $this->_user['masterId'])); if (!count($model)) { $model = new PlaceReview(); } if (isset($_POST['PlaceReview'])) { $model->attributes = $_POST['PlaceReview']; $model->place_id = $_GET['id']; $model->teacher_id = $this->_user['masterId']; if ($model->save()) { $message = true; } } $this->render('review', array('place' => $place, 'host' => $host, 'message' => $message, 'model' => $model)); }
public function run() { $criteria = new CDbCriteria(); $list = Place::model()->findAll($criteria); $this->render('place', array('list' => $list)); }
<script type="text/javascript">CKEDITOR.replace( 'editor'); </script> <div class="margin-left-15"> <p>Từ khóa về sản phẩm</p> <?php $this->widget('CAutoComplete', array('model' => $model, 'attribute' => 'tags', 'url' => array('suggestTags'), 'multiple' => true, 'htmlOptions' => array('size' => 50))); ?> <p class="hint">Bạn có thể chọn nhiều từ khóa cho sản phẩm.</p> <?php echo $form->error($model, 'tags'); ?> </div> <div class="margin-left-15"> <p>Khu vực</p> <?php echo $form->dropDownList($model, 'status', CHtml::listData(Place::model()->findAll(), 'id', 'name'), array('class' => 'btn btn-default')); ?> <?php echo $form->error($model, 'status'); ?> </div> <div class="margin-left-15"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Tạo bài đăng' : 'Lưu', array('class' => 'btn btn-default')); ?> </div> <?php $this->endWidget();
/** * @param $id * @param string $mode * @throws CHttpException */ public function actionShowMap($id, $mode = 'map') { $this->layout = '//layouts/popup-iframe'; $park = $this->loadModel($id); if (!$park->location->latitude || !$park->location->longitude) { throw new CHttpException(404, 'Park map not defined'); } $parks = Place::model()->findAll(['scopes' => 'onlyActive']); $this->render("//MapView/default", array('id' => $id, 'latitude' => $park->location->latitude, 'longitude' => $park->location->longitude, 'type' => 'park', 'mode' => $mode, 'mapDim' => ['w' => '80%', 'h' => ''], 'parks' => $parks, 'nearestTransport' => true)); }
</div> <div class=" margin-left-15"> <p>Số điện thoại</p> <?php echo $form->textField($model, 'phone', array('class' => 'form-control input-traodoi')); ?> <?php echo $form->error($model, 'phone'); ?> </div> <div class=" margin-left-15"> <p>Khu vực sống</p> <?php echo $form->dropDownList($model, 'place_id', CHtml::listData(Place::model()->findAll(), 'id', 'name'), array('class' => 'form-control input-traodoi')); ?> <?php echo $form->error($model, 'place_id'); ?> </div> <div class=" margin-left-15"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Tạo tài khoản' : 'Lưu', array('class' => 'btn btn-default')); ?> </div> <?php $this->endWidget(); ?>
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate() { if (isset($_GET['errorLocate'])) { Yii::app()->user->setFlash('warning', 'Sorry, we couldn\'t set up your location automatically. Please enter it manually below:'); } // Login required if (null !== Yii::app()->user) { $user_id = Yii::app()->user->id; } else { $this->redirect(Yii::app()->getModule('user')->loginUrl); } // create a default location if no entry exists UserLocation::model()->createDefault($user_id); $model = $this->loadModelByUser($user_id); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['UserLocation'])) { $model->attributes = $_POST['UserLocation']; // lookup gps coordinate from address $location_results = $model->lookupGeoLatLon($model['address'], $model['city'], $model['state_id'], $model['country_id']); $model->gps = new CDbExpression("geomfromtext('" . $location_results['gps'] . "')"); // lookup neighborhood $model->neighborhood_id = Neighborhoods::model()->lookupFromLatLon($location_results['gps']); // new: add user to neighborhood when they set location $neighborhood_place = Place::model()->find(array('condition' => 'neighborhood_id=:neighborhood_id', 'params' => array(':neighborhood_id' => $model->neighborhood_id))); if ($neighborhood_place !== null) { Place::model()->join($user_id, $neighborhood_place['id']); // use place->id } if ($model->save()) { UserLocation::model()->setLocationFlag($user_id); Yii::app()->user->setFlash('location_saved', 'Your location settings have been saved. Now you can join or create places near you.'); $this->redirect(Yii::app()->baseUrl . '/place/near'); } } $this->render('update', array('model' => $model)); }
private function addMember($email, $slug) { $u = User::model()->find(array('select' => 'id', 'condition' => 'email=:email', 'params' => array(':email' => $email))); $p = Place::model()->find(array('select' => 'id', 'condition' => 'slug=:slug', 'params' => array(':slug' => $slug))); $x = Place::model()->join($u->id, $p->id); }
echo $form->labelEx($model, 'address'); ?> <?php echo $form->textArea($model, 'address', array('class' => 'textarea')); ?> <?php echo $form->error($model, 'address'); ?> </div> <!-- <div class="row"> <?php echo $form->labelEx($model, 'place_id'); ?> <?php echo $form->dropDownList($model, 'place', CHtml::listData(Place::model()->findAll(), 'id', 'other_names'), array('prompt' => 'None')); ?> <?php echo $form->error($model, 'place_id'); ?> </div>--> <div class="row"> <?php echo $form->labelEx($model, 'district_id'); ?> <?php echo $form->dropDownList($model, 'district', CHtml::listData(District::model()->findAll(), 'id', 'name'), array('prompt' => 'None')); ?> <?php echo $form->error($model, 'district_id');
public static function place() { return CHtml::listData(Place::model()->desc()->findAll(), 'place_id', 'name'); }
</div> </div> <div class="form-group"> <label for="inputPlace" class="col-xs-2 control-label">授课场地:</label> <div class="col-xs-6"> <?php $placeBooking = PlaceBooking::model()->findAllByAttributes(array('teacher_id' => $this->_user['masterId'])); if ($placeBooking == null) { echo $form->textField($model, 'place_id', array('class' => 'form-control', 'placeholder' => '您暂未预定场地', 'value' => '', 'readonly' => 'readonly')); echo $form->error($model, 'place_id'); } else { foreach ($placeBooking as $pbs) { $place = Place::model()->findAllByAttributes(array('id' => $pbs->place_id)); foreach ($place as $ps) { $value = (int) $ps->id; $text = $ps->name; $placeList[$value] = (string) $text; } } echo $form->dropDownList($model, 'place_id', $placeList, array('id' => 'inputPlace', 'class' => 'form-control selectpicker show-menu-arrow', 'data-size' => '12', 'title' => '请选择您所预订的场地')); echo $form->error($model, 'place_id'); } ?> </div> </div> <div class="form-group has-feedback"> <label for="inlineNumNon-exclusive" class="col-xs-2 control-label">人数上限:</label>
public function actionOutOfDates() { $dates = json_encode(Yii::app()->request->getParam('dates')); $id = Yii::app()->request->getParam('place_id'); $model = Place::model()->findByPk($id); $model->out_of_dates = $dates; $model->save(); die(CJSON::encode(array('status' => 'success'))); }
<p class="danhmuc_tag">Thông tin tài khoản</p> <?php $i = 1; foreach ($criteria as $data) { ?> <?php $model = Place::model()->findByPk($data->place_id); ?> <div class="row"> <div class="col-sm-3"> <img class="imageavarar margin-left-15" src="<?php echo Yii::app()->request->baseUrl; ?> /images/images/aa.jpg"> </div> <div class="col-sm-9 row"> <div class="col-sm-3 nplr"> Tên </div> <div class="col-sm-9"> <?php echo $data->username; ?> </div> <div class="col-sm-3 nplr"> Số điện thoại </div> <div class="col-sm-9"> <?php