예제 #1
0
 public function actionOrders()
 {
     //		$this->render('index', array(
     //			'cargoes' => $cargoes,
     //			'transports' => $transports,
     //			'tenders' => $tenders,
     //			'model' => $model,
     //		));
     Cargo::disableDefaultScope();
     $cargo = new CActiveDataProvider('Cargo', array('criteria' => array('condition' => 'cargo.active = 1 and userId = :id', 'params' => array(':id' => Yii::app()->user->getModel()->primaryKey))));
     Transport::disableDefaultScope();
     $transport = new CActiveDataProvider('Transport', array('criteria' => array('condition' => 'transport.active = 1 and userId = :id', 'params' => array(':id' => Yii::app()->user->getModel()->primaryKey))));
     $tender = new CActiveDataProvider('Tender', array('criteria' => array('condition' => 'tender.active = 1 and userId = :id', 'params' => array(':id' => Yii::app()->user->getModel()->primaryKey))));
     $this->render('orders', array('transports' => $transport, 'tenders' => $tender, 'cargoes' => $cargo));
 }
예제 #2
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        $model = new Favorite('search');
        $model->unsetAttributes();
        // clear any default values
        if (isset($_REQUEST['Favorite'])) {
            $model->attributes = $_GET['Favorite'];
        }
        //		$favorites = Favorite::model()->findAll('modelName LIKE :t ',array(':t' => '%'.$model->modelName.'%'));
        $favorites = Favorite::model()->findAllBySql('
		select f.* FROM Favorite `f`
		LEFT JOIN Tender ON tenderId = modelId AND modelName=\'Tender\'
		LEFT JOIN Transport ON transportId = modelId AND modelName=\'Transport\'
		LEFT JOIN Cargo ON cargoId = modelId AND modelName=\'Cargo\'
		LEFT JOIN User ON User.userId = modelId AND modelName=\'User\'
		where
		f.userId = :u AND
		modelName LIKE :t AND (
			NOT ISNULL( tenderId )
			OR NOT ISNULL( cargoId )
			OR NOT ISNULL( User.userId )
			OR NOT ISNULL( transportId )
		)', array(':t' => '%' . $model->modelName . '%', ':u' => Yii::app()->user->id));
        $ids = array();
        foreach ($favorites as $it) {
            $ids[$it['modelName']][] = Yii::app()->db->quoteValue($it['modelId']);
        }
        /**
         * Disable all defaults scopes 
         */
        Cargo::disableDefaultScope();
        Transport::disableDefaultScope();
        Tender::disableDefaultScope();
        User::disableDefaultScope();
        $cargoes = new CActiveDataProvider('Cargo', array('criteria' => array('condition' => 'cargo.cargoId in (' . ($ids['Cargo'] ? implode(',', $ids['Cargo']) : 0) . ')'), 'pagination' => false));
        $transports = new CActiveDataProvider('Transport', array('criteria' => array('condition' => 'transport.type = ' . Transport::TRANSPORT . ' AND  transport.transportId in (' . ($ids['Transport'] ? implode(',', $ids['Transport']) : 0) . ')'), 'pagination' => false));
        $tenders = new CActiveDataProvider('Tender', array('criteria' => array('condition' => 'tender.tenderId in (' . ($ids['Tender'] ? implode(',', $ids['Tender']) : -1) . ')'), 'pagination' => false));
        $users = new CActiveDataProvider('User', array('criteria' => array('condition' => 'User.userId in (' . ($ids['User'] ? implode(',', $ids['User']) : -1) . ')'), 'pagination' => false));
        $this->render('index', array('cargoes' => $cargoes, 'transports' => $transports, 'tenders' => $tenders, 'users' => $users, 'model' => $model));
    }
예제 #3
0
<?php

switch ($data['modelName']) {
    case "Transport":
        Transport::disableDefaultScope();
        $model = Transport::model('Transport')->findByPk($data['key']);
        echo $this->renderPartial('application.views.transport._view', array('data' => $model));
        break;
    case "Cargo":
        Cargo::disableDefaultScope();
        $model = Cargo::model()->findByPk($data['key']);
        echo $this->renderPartial('application.views.cargo._view', array('data' => $model));
        break;
    case "Tender":
        $model = Tender::model()->findByPk($data['key']);
        echo $this->renderPartial('application.views.tender._view', array('data' => $model));
        break;
    case "User":
        $model = User::model()->findByPk($data['key']);
        echo $this->renderPartial('application.views.user._view', array('data' => $model));
        break;
    default:
        echo "Не правильные данные обратитесь к администратору.";
}