Page 1 of 1

how to solve empty ads issue

PostPosted: 20 Nov 2014, 14:30
by andipas
Change in the file Apartment.php (protected/modules/apartments/models/Apartment.php) the method "beforeSave" for the following code

Code: Select all

    
public function beforeSave()
    {
        if (!
$this->square) {
            
$this->square 0;
        }

        if (!
$this->land_square) {
            
$this->land_square 0;
        }

        
$userInfo User::model()->findByPk($this->owner_id, array('select' => 'isAdmin'));

        if (
$this->isNewRecord) {
            
$this->owner_id $this->owner_id $this->owner_id Yii::app()->user->id;

            if (
$userInfo && $userInfo->isAdmin == 1) {
                
$this->owner_active self::STATUS_ACTIVE;
            }

            
$maxSorter Yii::app()->db->createCommand()
                ->
select('MAX(sorter) as maxSorter')
                ->
from($this->tableName())
                ->
queryScalar();
            
$this->sorter $maxSorter 1;

            if (
$this->obj_type_id == 0) {
                
$this->obj_type_id Yii::app()->db->createCommand('SELECT MIN(id) FROM {{apartment_obj_type}}')->queryScalar();
            }
        }

        if (!
isFree()) {
            
$defaultCurrencyCharCode Currency::getDefaultCurrencyModel()->char_code;

            if (
$defaultCurrencyCharCode != $this->in_currency) {

                
$this->price = (int)Currency::convert($this->price$this->in_currency$defaultCurrencyCharCode);

                if (isset(
$this->price_to) && $this->price_to) {
                    
$this->price_to = (int)Currency::convert($this->price_to$this->in_currency$defaultCurrencyCharCode);
                }
            }
        }

        switch (
$this->type) {
            case 
self::TYPE_SALE:
                
$this->price_type self::PRICE_SALE;
                break;

            case 
self::TYPE_BUY:
                
$this->price_type self::PRICE_BUY;
                break;

            case 
self::TYPE_RENTING:
                
$this->price_type self::PRICE_RENTING;
                break;

            case 
self::TYPE_CHANGE:
                
$this->price_type self::PRICE_CHANGE;
                break;
        }

        if (isset(
$_POST['set_period_activity']) && $_POST['set_period_activity'] == && $this->period_activity) {
            
$list self::getPeriodActivityList();
            if (isset(
$list[$this->period_activity])) {
                if (
$this->period_activity == 'always') {
                    
$this->activity_always 1;
                } else {
                    
$this->date_end_activity date('Y-m-d'strtotime($this->period_activitytime()));
                    
$this->activity_always 0;
                }
            }
        }

        return 
parent::beforeSave();
    }