Example #1
4
 public function run()
 {
     $voting = null;
     if (is_numeric(HU::post('id_voting'))) {
         $voting = Voting::model()->onlyActive()->with('answer')->findByPk(HU::post('id_voting'));
     }
     if ($voting == null) {
         //echo CHtml::encode($this->controller->widget('vote.widgets.VoteWidget', null, true));
         return;
     }
     if (Yii::app()->vote->check($voting->id_voting)) {
         $answers = $_POST['VotingAnswer']['name'];
         $cr = new CDbCriteria();
         $cr->addColumnCondition(array('id_voting' => $voting->id_voting));
         if (is_array($answers)) {
             $cr->addInCondition('id_voting_answer', $answers);
         } else {
             if (is_numeric($answers)) {
                 $cr->addColumnCondition(array('id_voting_answer' => $answers));
             }
         }
         VotingAnswer::model()->updateCounters(array('count' => 1), $cr);
         VisitSite::saveCurrentVisit(Voting::ID_OBJECT, $voting->id_voting);
         Yii::app()->user->setState('vote_' . $voting->id_voting, time());
         // перегружаем голосовалку, чтоб обновились показатели счетчиков
         $voting = Voting::model()->onlyActive()->with('answer')->findByPk($voting->id_voting);
     }
     $voteCount = $voting->getSumVote();
     echo CHtml::encode($this->controller->renderPartial("vote.widgets.views.statistic", array('voting' => $voting, 'voteCount' => $voteCount)), null, true);
 }
 public function run()
 {
     if (is_null($this->model)) {
         return;
     }
     $model = $this->model;
     // Условия выборки
     $criteria = new CDbCriteria();
     if ($this->limit > 0) {
         $criteria->limit = (int) $this->limit;
     }
     $criteria->order = 'RAND()';
     $criteria->scopes['type'] = $model->type->id;
     $criteria->compare('t.id', '<>' . $model->id);
     if ($model->category->id == RealtyCategory::ELITE_CATEGORY_ID) {
         $criteria->compare('::rooms_number::', $model->rooms_number);
         $criteria->addInCondition('::district::', $model->district);
     } elseif ($model->category->id == RealtyCategory::COUNTRY_CATEGORY_ID) {
         $criteria->addInCondition('::direction::', $model->direction);
     }
     if ($model->category->id == RealtyCategory::COMMERCIAL_CATEGORY_ID) {
         $criteria->addInCondition('::district::', $model->district);
     }
     // Выборка объектов
     $models = RealtyItem::model()->withEavAttributes(true)->active()->with(['category', 'type', 'currency'])->findAll($criteria);
     if (empty($models)) {
         return;
     }
     $this->render($this->view, ['models' => $models]);
 }
 public function getDecisionsApproachingDeadlineByMda($mda_id)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', EacDecision::model()->getDecisionIdsFromResponsibleMdaMappings($mda_id));
     $criteria->addInCondition("datediff(deadline,now())", [14, 7, 3]);
     $decisions = EacDecision::model()->find($criteria);
     return $decisions;
 }
Example #4
0
 public function actionIndex($style = null, $order = null, $manufacturer = null, $attribute = null)
 {
     if (isset($_GET['q'])) {
         $with = array();
         $category = array();
         $criteria = new CDbCriteria();
         $criteria->condition = "name like :search or description like :search";
         $criteria->params = array(':search' => "%{$_GET['q']}%");
         if (isset($_GET['category']) && $_GET['category'] > 0) {
             $category = Category::model()->findByPk($_GET['category']);
             $criteria->addCondition("category_id = {$category->id}");
         }
         $template = "type/_grid";
         if ($style == "list") {
             $template = 'type/_' . $style;
         }
         switch ($order) {
             case "price":
                 $criteria->order = "price";
                 break;
             case "created":
                 $criteria->order = "created DESC";
                 break;
             default:
                 $criteria->order = "name";
                 break;
         }
         if ($manufacturer) {
             $criteria->addInCondition("manufacturer_id", explode(',', trim($manufacturer)));
         }
         if ($attribute) {
             $crtr = new CDbCriteria();
             $crtr->addInCondition("id", explode(',', trim($attribute)));
             $opt = EntityAttributeOption::model()->findAll($crtr);
             $attrs = CHtml::listData($opt, 'id', 'option');
             $criteria->addInCondition("entityAttributeOptions.option", $attrs);
             $with = array('entityAttributeOptions' => array('together' => true));
         }
         $products = new Product();
         $total = $products->with($with)->count($criteria);
         $pages = new Pagination($total);
         $pages->pageSize = 4;
         $pages->applyLimit($criteria);
         $list = $products->with($with)->findAll($criteria);
         if (Yii::app()->request->isAjaxRequest) {
             $this->widget("ProductList", array('pages' => $pages, 'products' => $list, 'template' => $template));
             Yii::app()->end();
         }
         $this->render('index', array('models' => $list, 'pages' => $pages, 'q' => $_GET['q'], 'template' => $template, 'category' => $category));
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Example #5
0
 public function fromto($id1, $id2 = 0)
 {
     if (empty($id2)) {
         $id2 = Yii::app()->user->id;
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id_from', array($id1, $id2));
     $criteria->addInCondition('id_to', array($id1, $id2));
     $criteria->addCondition('id_to<>id_from');
     $this->getDbCriteria()->mergeWith($criteria);
     return $this;
 }
Example #6
0
 public function deactivate(Plugin $plugin)
 {
     $data = $plugin->getData();
     Yii::app()->authManager->removeAuthItemObject('list', $data['id_object_banner_place']);
     Yii::app()->authManager->removeAuthItemObject('list', $data['id_object_banner']);
     $this->uninstallAggregateViewStatisticJob();
     $this->deactivatePhpScript(self::BANNER_PHP_SCRIPT_TYPE_ID);
     //удаляем SiteModule связанных с баннерами, если таковые имеются
     $idsPhpScript = Yii::app()->db->createCommand()->select('id_php_script')->from('da_php_script')->where('id_php_script_type = "' . self::BANNER_PHP_SCRIPT_TYPE_ID . '"')->queryAll();
     if ($idsPhpScript) {
         $idsPhpScriptArray = array();
         foreach ($idsPhpScript as $idPhpScript) {
             $idsPhpScriptArray[] = $idPhpScript['id_php_script'];
         }
         //отцепляем виджеты от наборов
         $idsSiteModule = Yii::app()->db->createCommand()->select('id_module')->from('da_site_module')->where('id_php_script IN (' . implode(',', $idsPhpScriptArray) . ')')->queryAll();
         $idsSiteModuleArray = array();
         foreach ($idsSiteModule as $idSiteModule) {
             $idsSiteModuleArray[] = $idSiteModule['id_module'];
         }
         $criteria = new CDbCriteria();
         $criteria->addInCondition('id_module', $idsSiteModuleArray);
         Yii::app()->db->commandBuilder->createDeleteCommand('da_site_module_rel', $criteria)->execute();
         //удаляем сами модули
         $criteria = new CDbCriteria();
         $criteria->addInCondition('id_php_script', $idsPhpScriptArray);
         Yii::app()->db->commandBuilder->createDeleteCommand('da_site_module', $criteria)->execute();
         //Yii::app()->db->createCommand()->update('da_site_module',array('is_visible' => 0),array('in','id_php_script',$idsPhpScriptArray));
         //удаляем php_script
         $criteria = new CDbCriteria();
         $criteria->compare('id_php_script_type', self::BANNER_PHP_SCRIPT_TYPE_ID);
         Yii::app()->db->commandBuilder->createDeleteCommand('da_php_script', $criteria)->execute();
     }
     $this->updateMenu = true;
 }
Example #7
0
 /**
  *	根据菜单group array 查询菜单
  */
 public function getInfoByGroup($groups)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition("t.group", $groups);
     $criteria->order = "code";
     return $this->getRows($criteria);
 }
Example #8
0
 private function concatenatedToBuildMenu($in, $valor)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id_menu_sistema', $in);
     $criteria->compare('padre', $valor);
     $criteria->compare('estatus', 1);
     $criteria->order = 'nivel';
     $menus = Menu::model()->findAll($criteria);
     $mostrar = array();
     foreach ($menus as $menu) {
         $criteria = new CDbCriteria();
         $criteria->addInCondition('id_menu_sistema', $in);
         $criteria->compare('padre', $valor);
         $criteria->compare('estatus', 1);
         $contadorHijos = Menu::model()->count($criteria);
         if ($contadorHijos == 0) {
             $mostrar[] = array('label' => 'Inicio', 'url' => array('/site/index'));
         } else {
             $addMostrar = array('label' => $menu->nombre, 'url' => array($menu->ruta), 'style' => 'home', 'items' => $this->concatenatedToBuildMenu($in, $menu->id_menu_sistema));
             if ($menu->style != '') {
                 $addMostrar['style'] = $menu->style;
             }
             $mostrar[] = $addMostrar;
         }
     }
     return $mostrar;
 }
Example #9
0
 public function actionUserDel()
 {
     $ids = explode(',', trim(Yii::app()->request->getParam('ids')));
     $cond = new CDbCriteria();
     $cond->addInCondition('id', $ids);
     $this->ajax_return(BasicUseringroup::model()->deleteAll($cond));
 }
 /**
  * @depends testAddCondition
  * @covers CDbCriteria::addInCondition
  */
 public function testAddInCondition()
 {
     CDbCriteria::$paramCount = 0;
     $criteria = new CDbCriteria();
     $criteria->addInCondition('A', array());
     $this->assertEquals('0=1', $criteria->condition);
     $this->assertTrue(empty($criteria->params));
     // IN with one parameter should transform to =
     $criteria = new CDbCriteria();
     $criteria->addInCondition('A', array(1));
     $this->assertEquals('A=:ycp0', $criteria->condition);
     $this->assertEquals(1, $criteria->params[':ycp0']);
     // IN with null should transform to IS NULL
     $criteria = new CDbCriteria();
     $criteria->addInCondition('A', array(null));
     $this->assertEquals('A IS NULL', $criteria->condition);
     $this->assertTrue(empty($criteria->params));
     // IN with many parameters
     $criteria = new CDbCriteria();
     $criteria->addInCondition('B', array(1, 2, '3'));
     $this->assertEquals('B IN (:ycp1, :ycp2, :ycp3)', $criteria->condition);
     $this->assertEquals(1, $criteria->params[':ycp1']);
     $this->assertEquals(2, $criteria->params[':ycp2']);
     $this->assertEquals('3', $criteria->params[':ycp3']);
 }
Example #11
0
 public function actionChangeStatus(array $ids, $value = 0)
 {
     $value = $value == 1 ? true : false;
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     AdminUserGroup::model()->updateAll(array('status' => $value), $criteria);
 }
Example #12
0
 public function getPushTasks($push_ids, $push_type)
 {
     $push_tasks = array();
     $criteria = new CDbCriteria();
     $criteria->condition = 'push_type =:push_type and push_status =:push_status';
     $criteria->params = array(':push_type' => $push_type, ':push_status' => 1);
     if ($push_ids) {
         $criteria->addInCondition('id', $push_ids);
     }
     //软件名称、软件包名、下载地址、图标的地址、宣传图片的地址、广告语(两句话,通知栏展示)
     $tasks = $this->findAll($criteria);
     if ($tasks) {
         $host = Util::getHost();
         foreach ($tasks as $key => $task) {
             $push_ad_info = DreamAdPackage::model()->getAdPackageInfo($task->push_ad_id);
             if ($push_ad_info) {
                 $push_tasks[$key]['app_name'] = $push_ad_info->app_name;
                 $push_tasks[$key]['type'] = 'self';
                 $push_tasks[$key]['title'] = $task->push_title;
                 $push_tasks[$key]['content'] = $task->push_description;
                 $push_tasks[$key]['package_name'] = $push_ad_info->package_name;
                 $push_tasks[$key]['icon_url'] = $host . $push_ad_info->icon_url;
                 $push_tasks[$key]['cover_url'] = $push_ad_info->image_url ? $host . $push_ad_info->image_url : "";
                 $download_url = strpos($push_ad_info->download_url, '://') ? $push_ad_info->download_url : $host . $push_ad_info->download_url;
                 $push_tasks[$key]['download_url'] = $download_url;
             }
         }
     }
     return $push_tasks;
 }
Example #13
0
 public function run()
 {
     $this->userinfo = User::model()->findByPk($this->userid);
     $Criteria = new CDbCriteria();
     $Criteria->condition = "userid = '" . $this->userid . "' AND Iscompleted = 0";
     if ($this->userid != Yii::app()->session['login']['id']) {
         $Criteria->condition = "AND finao_status_Ispublic = 0";
     }
     $finaos = UserFinao::model()->findAll($Criteria);
     if (!empty($finaos)) {
         foreach ($finaos as $finaoids) {
             $ids[] = $finaoids->user_finao_id;
         }
         $Criteria = new CDbCriteria();
         $Criteria->group = 'tile_id';
         $Criteria->condition = "userid = '" . $this->userid . "'";
         if (!empty($ids)) {
             $Criteria->addInCondition('finao_id', $ids);
         }
         $Criteria->order = 'createddate DESC';
         $this->alltiles = UserFinaoTile::model()->findAll($Criteria);
     } else {
         $this->alltiles = "";
     }
     $uploadtypeimage = Lookups::model()->findByAttributes(array('lookup_name' => 'Image', 'lookup_type' => 'uploadtype', 'lookup_status' => 1));
     //$uploadsourcetypeimage = Lookups::model()->findByAttributes(array('lookup_type'=>'uploadsourcetype','lookup_name'=>'finao','lookup_status'=>1));
     $uploadtypevideo = Lookups::model()->findByAttributes(array('lookup_name' => 'Video', 'lookup_type' => 'uploadtype', 'lookup_status' => 1));
     //$uploadsourcetypevideo = Lookups::model()->findByAttributes(array('lookup_type'=>'uploadsourcetype','lookup_name'=>'finao','lookup_status'=>1));
     $images = Uploaddetails::model()->findAllByAttributes(array('uploadtype' => $uploadtypeimage->lookup_id, 'uploadedby' => $this->userid, 'status' => 1));
     $videos = Uploaddetails::model()->findAllByAttributes(array('uploadtype' => $uploadtypevideo->lookup_id, 'uploadedby' => $this->userid, 'status' => 1));
     $this->imgcount = count($images);
     $this->videocount = count($videos);
     $this->render('_topheader', array('tilescount' => count($this->alltiles), 'userinfo' => $this->userinfo, 'finaocount' => count($finaos), 'imgcount' => $this->imgcount, 'videocount' => $this->videocount));
 }
Example #14
0
 public function getWishListForWeb($user_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_id = {$user_id}";
     $wishlists = Wishlist::model()->findAll($criteria);
     $wishlist_arr = array();
     foreach ($wishlists as $wishlist) {
         $wishlist_arr[] = $wishlist->post_id;
     }
     //var_dump($wishlist_arr); die;
     $returnArr = array();
     $criteria_post = new CDbCriteria();
     $criteria_post->addInCondition('t.post_id', $wishlist_arr);
     $count = Posts::model()->count($criteria_post);
     $pages = new CPagination($count);
     $pages->validateCurrentPage = FALSE;
     $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE'];
     $pages->applyLimit($criteria_post);
     $posts = Posts::model()->findAll($criteria_post);
     $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
     $profile = User::model()->findByPk($user_id);
     foreach ($posts as $post) {
         $itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']);
         $returnArr[] = $itemArr;
     }
     return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed);
     // return FALSE;
 }
Example #15
0
    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.
        $criteria = new CDbCriteria();
        $criteria->select = 't.*, (SELECT min(d.identifier) from dataset d LEFT JOIN dataset_author da ON da.dataset_id = d.id WHERE da.author_id = t.id) as minDoi';
        $criteria->compare('id', $this->id);
        $criteria->compare('LOWER(surname)', strtolower($this->surname), true);
        $criteria->compare('LOWER(middle_name)', strtolower($this->middle_name), true);
        $criteria->compare('LOWER(first_name)', strtolower($this->first_name), true);
        $criteria->compare('LOWER(orcid)', strtolower($this->orcid), true);
        $criteria->compare('gigadb_user_id', $this->gigadb_user_id);
        if ($this->dois_search) {
            $sql = <<<EO_SQL
SELECT author_id FROM dataset_author
WHERE dataset_id in (
SELECT dataset.id FROM dataset WHERE identifier LIKE '%{$this->dois_search}%'
)
EO_SQL;
            $connection = Yii::app()->db;
            $command = $connection->createCommand($sql);
            $criteria->addInCondition('t.id', $command->queryColumn());
        }
        $sort = new CSort();
        $sort->attributes = array('surname' => array('asc' => 'surname ASC', 'desc' => 'surname DESC'), 'middle_name' => array('asc' => 'middle_name ASC', 'desc' => 'middle_name DESC'), 'first_name' => array('asc' => 'first_name ASC', 'desc' => 'first_name DESC'), 'orcid' => array('asc' => 'orcid ASC', 'desc' => 'orcid DESC'), 'dois_search' => array('asc' => 'minDoi ASC', 'desc' => 'minDoi DESC'));
        return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => $sort));
    }
 public function actionBatchDelete()
 {
     if (Yii::app()->user->checkAccess('deleteFeedback') == false) {
         throw new CHttpException(403);
     }
     $idList = Yii::app()->request->getPost('id', array());
     if (count($idList) > 0) {
         $criteria = new CDbCriteria();
         $criteria->addInCondition('id', $idList);
         $feedbacks = Feedback::model()->findAll($criteria);
         $flag = 0;
         foreach ($feedbacks as $feedback) {
             if ($feedback->delete()) {
                 $answer = Answer::model()->deleteAll('feedback_id=:feedbackID', array(':feedbackID' => $feedback->primaryKey));
                 $flag++;
             }
         }
         if ($flag > 0) {
             $this->setFlashMessage('问题咨询 已成功删除');
         } else {
             $this->setFlashMessage('问题咨询 删除失败', 'warn');
         }
     } else {
         $this->setFlashMessage('没有记录被选中', 'warn');
     }
     $this->redirect(array('index'));
 }
 public function actionAll()
 {
     $model = Notify::model();
     $user_id = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->with = ['status' => ['select' => ['status.id', 'status.notify_id', 'status.user_id', 'status.read_status', 'IF(status.date_showed, status.date_showed, "' . date('c') . '") as date_showed'], 'on' => 'status.user_id = :user_id']];
     $criteria->params = [':user_id' => $user_id, ':all_users' => Notify::All_USERS, ':type' => Notify::TYPE_DEFAULT, ':today' => date('c'), ':user_date_create' => $model->getUserDateCreate($user_id)];
     $criteria->addCondition('t.user_id=:user_id OR t.user_id=:all_users');
     if ($model->isGroupSupport() && $model->getUserGroups($user_id)) {
         $criteria->addInCondition('t.group_id', $model->getUserGroups($user_id), 'OR');
     }
     $criteria->addCondition('(t.date_create >= :user_date_create AND t.date_show<=:today) AND  (IF(date_end, :today <= date_end, 1) OR status.user_id IS NOT NULL)');
     $criteria->addCondition('t.type = :type');
     $criteria->order = 'date_showed desc, t.date_show desc';
     $count = Notify::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = Yii::app()->notify->numberDisplayInAll;
     $pages->applyLimit($criteria);
     $notifications = Notify::model()->findAll($criteria);
     $ids = array_keys(array_filter(CHtml::listData($notifications, 'id', 'status.read_status'), function ($var) {
         return $var == 0;
     }));
     if ($ids) {
         Notify::changeReadStatusByIds($ids, $user_id, Notify::READ);
         $notifications = Notify::model()->findAll($criteria);
     }
     $this->render('all', ['notifications' => $notifications, 'pages' => $pages]);
 }
 public function deEmpleado($idEmpleado)
 {
     $finalArray = array();
     $empleadoCommand = array();
     //para el Empleado
     $params = array(':idEmpleado' => $idEmpleado, ':entidadTipo' => Empleado::model()->tableName());
     $commad = Yii::app()->db->createCommand()->select('*')->from('actividad_sistema')->where('entidad_id = :idEmpleado AND entidad_tipo=:entidadTipo');
     $commad->params = $params;
     $empleadoCommand = $commad->queryAll();
     $finalArray = $empleadoCommand;
     //        $finalArray = array_merge($deudaClienteCommand, $clienteCommand);
     //        $finalArray = array_merge($finalArray, $transaClienteCommand);
     //        $finalArray = array_merge($finalArray, $clienteMailCommand);
     $arrayId = array();
     foreach ($finalArray as $dato) {
         array_push($arrayId, $dato['id']);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $arrayId);
     $criteria->compare('entidad_tipo', $this->entidad_tipo, true);
     $criteria->compare('entidad_id', $this->entidad_id);
     $criteria->compare('tipo', $this->tipo, true);
     $criteria->compare('usuario_id', $this->usuario_id);
     $criteria->compare('fecha', $this->fecha, true);
     $criteria->compare('detalle', $this->detalle, true);
     $criteria->order = 'fecha DESC';
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => $this->pageSize)));
 }
Example #19
0
 /**
  * Searches for stuff
  */
 public function actionSearch()
 {
     $query = isset($_GET['q']) ? $_GET['q'] : null;
     // Scope
     $users = null;
     $shares = null;
     if ($query != null) {
         // Make the criteria object
         $userCriteria = new CDbCriteria();
         $searchCriteria = new CDbCriteria();
         // If there is a @ symbol, do a user search
         preg_match_all('/@([A-Za-z0-9\\/\\.]*)/', $query, $matches);
         $mentions = implode(',', $matches[1]);
         if (!empty($matches[1])) {
             $userCriteria->addInCondition('username', $matches[1]);
             $users = User::model()->findAll($userCriteria);
             // Remove the @users from the remaining query
             foreach ($matches[1] as $u) {
                 $query = str_replace('@' . $u, '', $query);
             }
         }
         // Do a like Query
         $searchCriteria->addSearchCondition('text', $query);
         $searchCriteria->limit = 30;
         $shares = Share::model()->findAll($searchCriteria);
     }
     // Render the search
     $this->render('search', array('users' => $users, 'shares' => $shares));
 }
 public function actionEvents()
 {
     /**
      * @var $task Task
      * @var $cmd CDbCommand
      */
     $result = array('success' => 1);
     if (isset($_GET['from']) && isset($_GET['to'])) {
         $start = date(Task::DF_INTER, intval($_GET['from']) / 1000);
         $end = date(Task::DF_INTER, intval($_GET['to']) / 1000);
         //echo $start."\n".$end;
         $criteria = new CDbCriteria();
         $criteria->addBetweenCondition('start_date', $start, $end);
         if ($this->_user()->role == User::ROLE_USER) {
             $cmd = Yii::app()->db->createCommand();
             $taskIds = $cmd->select('task_id')->from(Job::model()->tableName())->where('organization_id = :id AND (updated_at BETWEEN :start AND :end)', array(':id' => $this->_user()->organization_id, ':start' => $start, ':end' => $end))->queryColumn();
             $criteria->addInCondition('id', $taskIds);
         }
         $tasks = Task::model()->findAll($criteria, array('order' => array('priority' => 'DESC')));
         $data = array();
         foreach ($tasks as $task) {
             $data[] = array('id' => $task->id, 'title' => $task->name, 'url' => Yii::app()->createUrl('task/view', array('id' => $task->id)), 'start' => strtotime($task->created_at) . '000', 'end' => strtotime($task->created_at) + 1800 . '000', 'class' => 'priority-' . $task->priority);
         }
         $result['result'] = $data;
     }
     $this->renderJSON($result);
 }
Example #21
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             foreach ((array) $ids as $id) {
                 $softModel = Soft::model()->findByPk($id);
                 if ($softModel) {
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_icon);
                     Uploader::deleteFile(ROOT_PATH . $softModel->soft_file);
                 }
             }
             Soft::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Soft::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Soft::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
Example #22
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $sortOrder = Yii::app()->request->getParam('sortOrder');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'sortOrder':
             //推荐内容排序
             foreach ($ids as $id) {
                 Recommend::model()->updateByPk($id, array('sort_order' => $sortOrder[$id]));
             }
             break;
         case 'unCommend':
             //取消推荐内容
             Recommend::model()->deleteAll($criteria);
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
Example #23
0
 public function checkAccumulationPeriod()
 {
     if ($this->hasErrors()) {
         return false;
     }
     /** Sensor validate */
     if (isset($this->accumulation_period) && $this->accumulation_period != 0) {
         foreach ($this->getSensorFeatureCode() as $feature_code) {
             if (!in_array($feature_code, $this->accumulate_features)) {
                 $this->addError('accumulation_period', 'Please fix the following input errors: Accumulation only applies to rain, sun duration and solar radiation. If you want to see accumulated rain or sun, make sure you do not select other features. Please select \'Rain\', \'Sun Radiation\' or \'Sun Duration\' and click \'Filter\' again');
                 return false;
             }
         }
     }
     /** station validate */
     $qb = new CDbCriteria();
     $qb->select = ['event_message_period', 'station_id_code'];
     $qb->addInCondition('station_id', $this->station_id);
     if (isset($this->accumulation_period) && $this->accumulation_period != 0 && ($stations = Station::model()->findAll($qb))) {
         $stations_error = array();
         foreach ($stations as $station) {
             if ($station->event_message_period > $this->accumulation_period) {
                 $stations_error[] = $station->station_id_code;
             }
         }
         if (count($stations_error)) {
             $this->addError('event_message_period', 'The period you selected is smaller than the weather message interval in stations ' . implode(',', $stations_error) . '. Please increase the period and click \'Filter\' again.');
         }
     }
     if ($this->hasErrors('accumulation_period')) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $acdm_terms = AcademicTerm::model()->findAll('current_sem=1');
     $data = array();
     foreach ($acdm_terms as $list) {
         $data[] = $list['academic_term_id'];
     }
     $criteria->addInCondition('t.academic_name_id', $data, 'OR');
     $criteria->with = array('rel_batch_academic_period_id', 'rel_batch_academic_id', 'rel_division');
     $criteria->compare('rel_division.division_code', $this->division_code, true);
     //
     $criteria->compare('rel_batch_academic_period_id.academic_term_period', $this->academic_term_period, true);
     $criteria->compare('rel_batch_academic_id.academic_term_name', $this->academic_term_name, true);
     $criteria->compare('batch_id', $this->batch_id);
     $criteria->compare('batch_organization_id', $this->batch_organization_id);
     $criteria->compare('batch_created_by', $this->batch_created_by);
     $criteria->compare('batch_creation_date', $this->batch_creation_date, true);
     $criteria->compare('batch_code', $this->batch_code);
     $criteria->compare('t.branch_id', $this->branch_id);
     $criteria->compare('div_id', $this->div_id);
     $criteria->compare('academic_period_id', $this->academic_period_id);
     $criteria->compare('academic_name_id', $this->academic_name_id);
     $batch_data = new CActiveDataProvider(get_class($this), array('criteria' => $criteria));
     $_SESSION['batch_records'] = $batch_data;
     return $batch_data;
 }
Example #25
0
 public function displayDataset($ids)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition("id", $ids);
     $datasets = Dataset::model()->findAll($criteria);
     $this->generateFeed($datasets);
 }
Example #26
0
 public function actionPosts($name)
 {
     $tag = urldecode($name);
     $this->setSiteTitle(t('tag_posts', 'main', array('{name}' => $tag)));
     // @todo 关键字的描述没有指定
     $this->setPageKeyWords($tag);
     $this->setPageDescription(t('tag_posts_page_description', 'main', array('{name}' => $tag)));
     cs()->registerMetaTag('all', 'robots');
     $cmd = app()->getDb()->createCommand()->select('p.id')->from(TABLE_TAG . ' t')->where('t.name = :tagname', array(':tagname' => $tag))->join(TABLE_POST_TAG . ' pt', 'pt.tag_id = t.id')->join(TABLE_POST . ' p', 'p.id = pt.post_id');
     $ids = $cmd->queryColumn();
     if (count($ids) > 0) {
         $criteria = new CDbCriteria();
         if (param('post_list_type') == POST_LIST_TYPE_TITLE) {
             $criteria->select = array('t.id', 't.title', 't.visit_nums', 't.comment_nums', 't.create_time');
         }
         $criteria->order = 't.istop, t.create_time desc, t.id desc';
         $criteria->addInCondition('t.id', $ids)->addCondition('t.state = :state');
         $criteria->params += array(':state' => POST_STATE_ENABLED);
         $count = Post::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->setPageSize(param('postCountOfTitleListPage'));
         $pages->applyLimit($criteria);
         $posts = Post::model()->findAll($criteria);
     }
     $listType = param('post_list_type');
     $view = $listType == POST_LIST_TYPE_SUMMARY ? '/post/_summary_list' : '/post/_title_list';
     $blockTitle = t('tag_posts', 'main', array('{name}' => $tag));
     $data = array('blockTitle' => $blockTitle, 'posts' => $posts, 'pages' => $pages);
     $postListHtml = $this->renderPartial($view, $data, true);
     $this->render('posts', array('postListHtml' => $postListHtml));
 }
Example #27
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             Comment::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Comment::model()->updateAll(['status' => Comment::STATUS_SHOW], $criteria);
             break;
         case 'hide':
             //隐藏
             Comment::model()->updateAll(['status' => Comment::STATUS_HIDE], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
 public function run()
 {
     if (empty($this->model) || empty($this->attribute) || !$this->model->hasAttribute($this->attribute) || $this->model->{$this->attribute} == '') {
         return;
     }
     $productIds = trim($this->model->{$this->attribute});
     $productIds = trim($productIds, ',');
     $productIds = explode(',', $productIds);
     if (empty($productIds)) {
         return;
     }
     array_walk($productIds, function ($data) {
         return (int) trim($data);
     });
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.id', $productIds);
     //$criteria->order = 't.category_id ASC, t.sort ASC';
     $criteria->order = 'FIELD(t.id, ' . implode(',', $productIds) . ')';
     if ($this->limit > 0) {
         $criteria->limit = (int) $this->limit;
     }
     $models = Product::model()->published()->findAll($criteria);
     //Yii::app()->user->setState('activeProductsList', CJSON::encode(Product::model()->getProductsTotalList(true, $criteria)));
     $this->render($this->view, array('models' => $models, 'model' => $this->model, 'title' => $this->title));
 }
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $acdm_terms = AcademicTerm::model()->findAll('current_sem=1');
     //print_r($acdm_terms);exit;
     $data = array();
     foreach ($acdm_terms as $list) {
         $data[] = $list['academic_term_id'];
     }
     $criteria = new CDbCriteria();
     $criteria->select = array('distinct(student_fees_master_student_transaction_id), fees_master_table_id, student_info.student_enroll_no,student_info.student_roll_no,student_info.student_enroll_no,student_info.student_first_name,fees_master.fees_master_name');
     $criteria->join = 'LEFT JOIN student_info ON (student_info.student_info_transaction_id = t.student_fees_master_student_transaction_id) LEFT JOIN fees_master ON (fees_master.fees_master_id = t.fees_master_table_id) ';
     $criteria->addInCondition('fees_master.fees_academic_term_name_id', $data, 'OR');
     $criteria->compare('student_fees_master_id', $this->student_fees_master_id);
     $criteria->compare('student_fees_master_student_transaction_id', $this->student_fees_master_student_transaction_id);
     $criteria->compare('student_info.student_first_name', $this->student_first_name, true);
     $criteria->compare('student_info.student_enroll_no', $this->student_enroll_no, true);
     $criteria->compare('student_info.student_roll_no', $this->student_roll_no, true);
     $criteria->compare('fees_master_table_id', $this->fees_master_table_id);
     $criteria->compare('fees_master.fees_master_name', $this->fees_master_name, true);
     $criteria->compare('student_fees_master_details_id', $this->student_fees_master_details_id);
     $criteria->compare('fees_details_amount', $this->fees_details_amount);
     $criteria->compare('student_fees_master_org_id', $this->student_fees_master_org_id);
     $criteria->compare('student_fees_master_created_by', $this->student_fees_master_created_by);
     $criteria->compare('student_fees_master_creation_date', $this->student_fees_master_creation_date, true);
     $dp = new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'student_fees_master_id DESC')));
     $dp->setTotalItemCount(count($this->findAll($criteria)));
     return $dp;
 }
Example #30
-1
    /**
     * This is the default 'index' action that is invoked
     * when an action is not explicitly requested by users.
     */
    public function actionIndex($selector = 'all')
    {
        // renders the view file 'protected/views/site/index.php'
        // using the default layout 'protected/views/layouts/main.php'

        $criteria= new CDbCriteria;
        $criteria->alias = 'course';
        $criteria->order = 'rating DESC';
        if ($selector !== 'all'){
            if ($selector == 'junior'){
                $criteria->addInCondition('level', array('intern','strong junior','junior'));
            } else {
                $criteria->condition = 'level=:level';
                $criteria->params = array(':level'=>$selector);
            }
        }

        $dataProvider = new CActiveDataProvider('Course', array(
            'criteria' => $criteria,
            'Pagination'=>false,
        ));

        $total = $dataProvider->getTotalItemCount();
        $count1 =round($total/2);
        $count2 = $total - $count1;

        $this->render('index', array(

            'dataProvider' => $dataProvider,
            'count1' => $count1,
            'count2' => $count2,
        ));
    }