本文整理汇总了PHP中Apartment::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Apartment::model方法的具体用法?PHP Apartment::model怎么用?PHP Apartment::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apartment
的用法示例。
在下文中一共展示了Apartment::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddPaid
public function actionAddPaid($id = 0, $withDate = 0)
{
$model = new AddToAdForm();
$paidServices = PaidServices::model()->findAll('id != ' . PaidServices::ID_ADD_FUNDS);
$paidServicesArray = CHtml::listData($paidServices, 'id', 'name');
$request = Yii::app()->request;
$data = $request->getPost('AddToAdForm');
if ($data) {
$apartmentId = $request->getPost('ad_id');
$withDate = $request->getPost('withDate');
$model->attributes = $data;
if ($model->validate()) {
$apartment = Apartment::model()->findByPk($apartmentId);
$paidService = PaidServices::model()->findByPk($model->paid_id);
if (!$paidService || !$apartment) {
throw new CException('Not valid data');
}
if (PaidServices::applyToApartment($apartmentId, $paidService->id, $model->date_end)) {
echo CJSON::encode(array('status' => 'ok', 'apartmentId' => $apartmentId, 'html' => $apartment->getPaidHtml($withDate, true)));
Yii::app()->end();
}
} else {
echo CJSON::encode(array('status' => 'err', 'html' => $this->renderPartial('_add_to_form', array('id' => $apartmentId, 'model' => $model, 'withDate' => $withDate, 'paidServicesArray' => $paidServicesArray), true)));
Yii::app()->end();
}
}
$renderData = array('id' => $id, 'model' => $model, 'withDate' => $withDate, 'paidServicesArray' => $paidServicesArray);
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('_add_to_ad', $renderData);
} else {
$this->render('_add_to_ad', $renderData);
}
}
示例2: checkStatusAd
public static function checkStatusAd()
{
$activePaids = ApartmentPaid::model()->findAll('date_end <= NOW() AND status=' . ApartmentPaid::STATUS_ACTIVE);
foreach ($activePaids as $paid) {
$paid->status = ApartmentPaid::STATUS_NO_ACTIVE;
if ($paid->paid_id == PaidServices::ID_SPECIAL_OFFER || $paid->paid_id == PaidServices::ID_UP_IN_SEARCH) {
$apartment = Apartment::model()->findByPk($paid->apartment_id);
if ($apartment) {
$apartment->scenario = 'update_status';
if ($paid->paid_id == PaidServices::ID_SPECIAL_OFFER) {
$apartment->is_special_offer = 0;
$apartment->update(array('is_special_offer'));
}
if ($paid->paid_id == PaidServices::ID_UP_IN_SEARCH) {
$apartment->date_up_search = new CDbExpression('NULL');
$apartment->update(array('date_up_search'));
}
}
}
if (!$paid->update(array('status'))) {
//deb($paid->getErrors());
}
}
$adEndActivity = Apartment::model()->with('user')->findAll('t.date_end_activity <= NOW() AND t.activity_always != 1 AND (t.active=:status OR t.owner_active=:status)', array(':status' => Apartment::STATUS_ACTIVE));
foreach ($adEndActivity as $ad) {
$ad->scenario = 'update_status';
if (isset($ad->user) && $ad->user->isAdmin == 1) {
$ad->active = Apartment::STATUS_INACTIVE;
} else {
$ad->active = Apartment::STATUS_INACTIVE;
$ad->owner_active = Apartment::STATUS_INACTIVE;
}
$ad->save(false);
}
}
示例3: isUserAd
public static function isUserAd($apartmentId = null, $ownerId = null)
{
if ($apartmentId && $ownerId) {
if (Apartment::model()->findByAttributes(array('id' => $apartmentId, 'owner_id' => $ownerId))) {
return true;
}
return false;
}
return false;
}
示例4: actionSetCount
public function actionSetCount()
{
$sql = "SELECT COUNT(id) AS count_img, id_object FROM {{images}} GROUP BY id_object";
$res = Yii::app()->db->createCommand($sql)->queryAll();
foreach ($res as $item) {
$model = Apartment::model()->findByPk($item['id_object']);
if ($model) {
$model->count_img = $item['count_img'];
$model->update(array('count_img'));
} else {
echo 'not found model with id = ' . $item['id_object'] . '<br>';
}
}
deb($res);
}
示例5: prepareItems
private function prepareItems($xmlWriter = null)
{
$this->criteria->limit = param('module_rss_itemsPerFeed', 20);
$items = Apartment::model()->findAll($this->criteria);
if ($items) {
foreach ($items as $item) {
$xmlWriter->startElement("item");
$xmlWriter->writeElement('title', CHtml::encode($item->getStrByLang('title')));
$xmlWriter->writeElement('link', $item->getUrl());
$xmlWriter->writeElement('description', $this->getDescription($item));
$xmlWriter->writeElement('pubDate', $this->getDateFormat(strtotime($item->date_updated)));
$xmlWriter->endElement();
// end item
}
}
}
示例6: actionComplain
public function actionComplain($isFancy = 0)
{
$id = Yii::app()->request->getParam('id', 0);
if (!$id) {
throw404();
}
$model = new $this->modelName();
$modelApartment = Apartment::model()->findByPk($id);
if (!$modelApartment) {
throw404();
}
if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
$model->attributes = $_POST[$this->modelName];
$model->apartment_id = $id;
$model->session_id = Yii::app()->session->sessionId;
$model->user_id = 0;
$model->user_ip = Yii::app()->controller->currentUserIp;
$model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
if (!Yii::app()->user->isGuest) {
$model->email = Yii::app()->user->email;
$model->name = Yii::app()->user->username;
$model->user_id = Yii::app()->user->id;
}
if ($model->validate()) {
if ($this->checkAlreadyComplain($model->apartment_id, $model->user_id, $model->session_id)) {
if ($model->save(false)) {
$notifier = new Notifier();
$notifier->raiseEvent('onNewComplain', $model);
Yii::app()->user->setFlash('success', tt('Thanks_for_complain', 'apartmentsComplain'));
$model = new $this->modelName();
// clear fields
}
} else {
Yii::app()->user->setFlash('notice', tt('your_already_post_complain', 'apartmentsComplain'));
}
}
}
if ($isFancy) {
Yii::app()->clientscript->scriptMap['jquery.js'] = false;
Yii::app()->clientscript->scriptMap['jquery.min.js'] = false;
Yii::app()->clientscript->scriptMap['jquery-ui.min.js'] = false;
$this->renderPartial('complain_form', array('model' => $model, 'apId' => $id, 'isFancy' => true, 'modelApartment' => $modelApartment), false, true);
} else {
$this->render('complain_form', array('model' => $model, 'apId' => $id, 'modelApartment' => $modelApartment, 'wtf' => 'huilo'));
}
}
示例7: getSimilarAds
public function getSimilarAds($inCriteria = null)
{
if ($inCriteria === null) {
$criteria = new CDbCriteria();
$criteria->addCondition('active = ' . Apartment::STATUS_ACTIVE);
if (param('useUserads')) {
$criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
}
$criteria->order = $this->getTableAlias() . '.id ASC';
} else {
$criteria = $inCriteria;
}
Yii::import('application.modules.apartments.helpers.apartmentsHelper');
$similarAds = array();
$similarAds['apartments'] = Apartment::model()->cache(param('cachingTime', 1209600), Apartment::getImagesDependency())->with(array('images'))->findAll($criteria);
return is_array($similarAds['apartments']) && count($similarAds['apartments']) ? $similarAds['apartments'] : '';
}
示例8: getApartments
public static function getApartments($limit = 10, $usePagination = 1, $all = 1, $criteria = null)
{
$pages = array();
Yii::app()->getModule('apartments');
if ($criteria === null) {
$criteria = new CDbCriteria();
}
if (!$all) {
$criteria->addCondition('t.deleted = 0');
$criteria->addCondition('t.active = ' . Apartment::STATUS_ACTIVE);
if (param('useUserads')) {
$criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
}
}
$sort = new CSort('Apartment');
$sort->attributes = array('price' => 'price', 'date_created' => 'date_created');
if (!$criteria->order) {
$sort->defaultOrder = 't.date_up_search DESC, t.sorter DESC';
}
$sort->applyOrder($criteria);
$sorterLinks = self::getSorterLinks($sort);
$criteria->addCondition('t.owner_id = 1 OR t.owner_active = 1');
$criteria->addInCondition('t.type', Apartment::availableApTypesIds());
$criteria->addInCondition('t.price_type', array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true)));
// find count
$apCount = Apartment::model()->count($criteria);
if ($usePagination) {
$pages = new CPagination($apCount);
$pages->pageSize = $limit;
$pages->applyLimit($criteria);
} else {
$criteria->limit = $limit;
}
if (issetModule('seo')) {
$criteria->with = array('seo');
}
// $apartments = Apartment::model()
// ->cache(param('cachingTime', 1209600), Apartment::getImagesDependency())
// ->with(array('images'))
// ->findAll($criteria);
return array('pages' => $pages, 'sorterLinks' => $sorterLinks, 'apCount' => $apCount, 'criteria' => $criteria);
}
示例9: getLabel
public function getLabel()
{
if ($this->standard_type == self::STANDARD_TYPE_NEW) {
return $this->getStrByLang('label');
} else {
return Apartment::model()->getAttributeLabel($this->field);
}
}
示例10: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest) {
throw404();
}
$this->setActiveMenu('my_payments');
$request = Yii::app()->request;
$ad_id = $request->getParam('id', 0);
$paid_id = $request->getParam('paid_id');
$isFancy = $request->getParam('isFancy', 0);
$paySubmit = $request->getParam('pay_submit');
$tariffId = $request->getParam('tariffid', 0);
if ($paySubmit) {
$optionId = $request->getParam('option_id');
$paySystemId = $request->getParam('pay_id');
$amount = $request->getParam('amount', 0);
$error = 0;
// Если это поплнение баланса
if ($paid_id == PaidServices::ID_ADD_FUNDS && $amount <= 0) {
$this->setActiveMenu('my_balance');
Yii::app()->user->setFlash('error', tc('Please specify the amount of the payment'));
$error = 1;
}
Yii::app()->getModule('payment');
$paysystem = Paysystem::model()->findByPk($paySystemId);
if (!$paysystem) {
throw404();
}
# покупка тарифного плана
if ($tariffId && issetModule('tariffPlans')) {
$tariffPlanInfo = TariffPlans::getFullTariffInfoById($tariffId);
$paidOption = new PaidOptions();
$paidOption->id = 0;
if (!$tariffPlanInfo || $tariffPlanInfo['active'] == TariffPlans::STATUS_INACTIVE) {
throw404();
}
if ($tariffPlanInfo['price'] && $tariffPlanInfo['price'] > 0) {
// Если оплата тарифа с баланса пользователя
if ($paySystemId == Paysystem::ID_BALANCE) {
$user = User::model()->findByPk(Yii::app()->user->id);
if ($user->balance < $tariffPlanInfo['price']) {
Yii::app()->user->setFlash('error', tc('Please refill the balance'));
$error = 2;
$this->redirect(array('/tariffPlans/main/index'));
}
}
} else {
# бесплатный тариф
Yii::app()->user->setFlash('error', tt('Selected tariff plan is free. Please contact the site administrator for transit to this tariff.', 'tariffPlans'));
$error = 2;
$this->redirect(array('/tariffPlans/main/index'));
}
} else {
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$ad = Apartment::model()->findByPk($ad_id);
$paidOption = PaidOptions::model()->findByPk($optionId);
if (!$ad || !$paidOption || !isset($paidOption->paidService)) {
throw404();
}
// Если оплата платной услуги с баланса пользователя
if ($paySystemId == Paysystem::ID_BALANCE) {
$user = User::model()->findByPk(Yii::app()->user->id);
if ($user->id != $ad->owner_id || $ad->deleted) {
throw404();
}
if ($user->balance < $paidOption->price) {
Yii::app()->user->setFlash('error', tc('Please refill the balance'));
$error = 2;
}
}
}
}
$paysystem->createPayModel();
if ($paysystem->payModel === null) {
throw404();
}
if ($error == 0) {
// Создаем платеж и ставим ему статус "Ожидает оплаты"
$payment = new Payments();
$payment->user_id = Yii::app()->user->id;
$payment->paid_id = $paid_id;
if ($paid_id != PaidServices::ID_ADD_FUNDS) {
$payment->paid_option_id = $paidOption->id;
}
$payment->apartment_id = $ad_id;
$payment->tariff_id = $tariffId;
if ($tariffId && issetModule('tariffPlans')) {
$payment->amount = $tariffPlanInfo['price'];
} else {
$payment->amount = $paid_id == PaidServices::ID_ADD_FUNDS ? $amount : $paidOption->price;
}
$payment->currency_charcode = Currency::getDefaultCurrencyModel()->char_code;
$payment->status = Payments::STATUS_WAITPAYMENT;
$payment->paysystem_id = $paysystem->id;
$payment->save();
/*echo '<pre>';
print_r($payment->getErrors());
echo '</pre>';
exit;*/
// Передаем платеж на обработку в модель платежки.
//.........这里部分代码省略.........
示例11: getLabel
public function getLabel()
{
if ($this->type == self::TYPE_DEFAULT) {
return Apartment::model()->getAttributeLabel($this->field);
} else {
return $this->getStrByLang('label');
}
}
示例12: tt
<p>
<strong><?php
echo tt('Settings for the field', 'formdesigner');
?>
</strong>: <?php
echo Apartment::model()->getAttributeLabel($model->field);
?>
</p>
<?php
/** @var CustomForm $form */
$form = $this->beginWidget('CustomForm', array('id' => 'form-designer-filter'));
echo $form->errorSummary($model);
echo CHtml::hiddenField('id', $model->id);
echo CHtml::hiddenField('FormDesigner[save]', $model->id);
echo $form->dropDownListRow($model, 'view_in', FormDesigner::getViewInList());
echo '<br>';
echo $form->checkBoxRow($model, 'visible');
echo '<br>';
echo $form->checkBoxListRow($model, 'objTypesArray', ApartmentObjType::getList());
echo '<br>';
$this->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => 'tip', 'type' => 'string'));
echo '<div class="clear"></div>';
echo '<br>';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'icon' => 'ok white', 'label' => $model->isNewRecord ? tc('Add') : tc('Save')));
$this->endWidget();
示例13: actionMainsearch
public function actionMainsearch($rss = null)
{
$countAjax = Yii::app()->request->getParam('countAjax');
$href = Yii::app()->getBaseUrl(true) . '/' . Yii::app()->request->getPathInfo();
Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
unset($href);
if (Yii::app()->request->getParam('currency')) {
setCurrency();
$this->redirect(array('mainsearch'));
}
$criteria = new CDbCriteria();
$criteria->addCondition('active = ' . Apartment::STATUS_ACTIVE);
if (param('useUserads')) {
$criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
}
$criteria->addInCondition('type', Apartment::availableApTypesIds());
$this->sApId = (int) Yii::app()->request->getParam('sApId');
if ($this->sApId) {
$criteria->addCondition('id = :sApId');
$criteria->params[':sApId'] = $this->sApId;
$apCount = Apartment::model()->count($criteria);
if ($countAjax && Yii::app()->request->isAjaxRequest) {
$this->echoAjaxCount($apCount);
}
if ($apCount) {
$apartmentModel = Apartment::model()->findByPk($this->sApId);
Yii::app()->controller->redirect($apartmentModel->getUrl());
Yii::app()->end();
}
}
// rooms
if (issetModule('selecttoslider') && param('useRoomSlider') == 1) {
$roomsMin = Yii::app()->request->getParam('room_min');
$roomsMax = Yii::app()->request->getParam('room_max');
if ($roomsMin || $roomsMax) {
$criteria->addCondition('num_of_rooms >= :roomsMin AND num_of_rooms <= :roomsMax');
$criteria->params[':roomsMin'] = $roomsMin;
$criteria->params[':roomsMax'] = $roomsMax;
$this->roomsCountMin = $roomsMin;
$this->roomsCountMax = $roomsMax;
}
} else {
$rooms = Yii::app()->request->getParam('rooms');
if ($rooms) {
if ($rooms == 4) {
$criteria->addCondition('num_of_rooms >= :rooms');
} else {
$criteria->addCondition('num_of_rooms = :rooms');
}
$criteria->params[':rooms'] = $rooms;
$this->roomsCount = $rooms;
}
}
// floor
if (issetModule('selecttoslider') && param('useFloorSlider') == 1) {
$floorMin = Yii::app()->request->getParam('floor_min');
$floorMax = Yii::app()->request->getParam('floor_max');
if ($floorMin || $floorMax) {
$criteria->addCondition('floor >= :floorMin AND floor <= :floorMax');
$criteria->params[':floorMin'] = $floorMin;
$criteria->params[':floorMax'] = $floorMax;
$this->floorCountMin = $floorMin;
$this->floorCountMax = $floorMax;
}
} else {
$floor = Yii::app()->request->getParam('floor');
if ($floor) {
$criteria->addCondition('floor = :floor');
$criteria->params[':floor'] = $floor;
$this->floorCount = $floor;
}
}
// square
if (issetModule('selecttoslider') && param('useSquareSlider') == 1) {
$squareMin = Yii::app()->request->getParam('square_min');
$squareMax = Yii::app()->request->getParam('square_max');
if ($squareMin || $squareMax) {
$criteria->addCondition('square >= :squareMin AND square <= :squareMax');
$criteria->params[':squareMin'] = $squareMin;
$criteria->params[':squareMax'] = $squareMax;
$this->squareCountMin = $squareMin;
$this->squareCountMax = $squareMax;
}
} else {
$square = Yii::app()->request->getParam('square');
if ($square) {
$criteria->addCondition('square <= :square');
$criteria->params[':square'] = $square;
$this->squareCount = $square;
}
}
$location = (int) Yii::app()->request->getParam('location_id');
$subLocation = (int) Yii::app()->request->getParam('sublocation_id');
$region = (int) Yii::app()->request->getParam('region_id');
if ($subLocation) {
if (empty($region)) {
$criteria->addCondition('sublocation_id = :sublocation_id AND location_id = :location_id');
$criteria->params[':sublocation_id'] = $subLocation;
$criteria->params[':location_id'] = $location;
} else {
//.........这里部分代码省略.........
示例14: actionChooseNewOwner
public function actionChooseNewOwner()
{
$apId = Yii::app()->request->getParam('id');
if (!$apId) {
throw404();
}
$modelApartment = Apartment::model()->findByPk($apId);
if (!$modelApartment) {
throw404();
}
$this->modelName = 'ChangeOwner';
$model = new ChangeOwner();
$modelUser = new User('search');
$modelUser->resetScope();
$modelUser->unsetAttributes();
// clear any default values
if (isset($_GET['User'])) {
$modelUser->attributes = $_GET['User'];
}
$modelUser->active = 1;
if (Yii::app()->request->isPostRequest) {
if (isset($_POST)) {
$futureOwner = isset($_POST['itemsSelected']) && isset($_POST['itemsSelected'][0]) ? $_POST['itemsSelected'][0] : '';
$futureApartments = array($apId);
$model->setAttributes(array('futureOwner' => $futureOwner, 'futureApartments' => array($apId)));
if ($model->validate()) {
if ($futureOwner && is_array($futureApartments)) {
$sql = 'UPDATE {{apartment}} SET owner_id = ' . $futureOwner . ' WHERE id IN (' . implode(', ', $futureApartments) . ')';
Yii::app()->db->createCommand($sql)->execute();
$sql = 'UPDATE {{images}} SET id_owner = ' . $futureOwner . ' WHERE id_object IN (' . implode(', ', $futureApartments) . ')';
Yii::app()->db->createCommand($sql)->execute();
Yii::app()->cache->flush();
Yii::app()->user->setFlash('success', tc('Success'));
Yii::app()->controller->redirect(array('admin'));
}
}
}
}
$renderData = array('apId' => $apId, 'model' => $model, 'modelUser' => $modelUser, 'modelApartment' => $modelApartment);
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('change_owner', $renderData, false, true);
} else {
$this->render('change_owner', $renderData);
}
}
示例15: tc
if (isset($_GET['Apartment'])) {
$modelAds->attributes = $_GET['Apartment'];
}
?>
<h1 class="title highlight-left-right">
<span>
<?php
echo tc('My listings');
?>
</span>
</h1>
<div class="clear"></div><br />
<?php
$user = HUser::getModel();
$typeId = isset($_GET['type']) ? (int) $_GET['type'] : 1;
$rentorders = Apartment::model()->findAll('type=:typeId AND owner_id=:userId', [':typeId' => $typeId, ':userId' => $user->id]);
$this->renderPartial('//modules/userads/views/index', array('model' => $modelAds->onlyAuthOwner()->notDeleted(), 'rentorders' => $rentorders));
} else {
$this->pageTitle .= ' - ' . tc('My data');
$this->breadcrumbs = array(tc('Control panel') => Yii::app()->createUrl('/usercpanel'), tc('My data'));
?>
<h1 class="title highlight-left-right">
<span>
<?php
echo tc('My data');
?>
</span>
</h1>
<div class="clear"></div><br />