Exemple #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $filtersForm = new FiltersForm();
     if (isset($_GET['FiltersForm'])) {
         $filtersForm->filters = $_GET['FiltersForm'];
     }
     $sessions = $filtersForm->filter(Yii::app()->RadData->get_sessions());
     $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
     if (!empty($_GET['pageSize'])) {
         $pageSize = $_GET['pageSize'];
     }
     $itemsProvider = new CArrayDataProvider($sessions, array('pagination' => array('pageSize' => $pageSize), 'sort' => array('attributes' => array('login', 'host', 'ip', 'nas', 'time'))));
     $this->render('index', compact('itemsProvider', 'filtersForm'));
 }
 public function actionSearchTopics($string, $progId = null, $semesterId = null)
 {
     $college = College::getUserCollege();
     $this->areaLarge = $college->college_name;
     $this->areaSmall = Yii::t('forum', 'forum.area.search');
     if (!empty($progId)) {
         $this->areaSmall .= " (In " . Program::model()->findByPk($progId)->program_name;
         if (!empty($semesterId)) {
             $this->areaSmall .= " / " . Semester::model()->findByPk($semesterId)->semester_name;
         }
         $this->areaSmall .= " )";
     }
     $this->canPost = false;
     Yii::log($string);
     $threads = Thread::model()->searchTopics($string, $college->college_id, $progId, $semesterId);
     Yii::log(CVarDumper::dumpAsString($threads));
     $topicRows = array();
     foreach ($threads as $i => $thread) {
         $row = array('id' => $thread['thread_id'], 'topic' => $thread['title'], 'program_name' => $thread['program_name'], 'program' => $thread['program_id'], 'semester' => CHtml::link($thread['semester_name'], array('viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id'])), 'progCode' => $thread['program_code'], 'postDate' => $thread['date_created'], 'numReplies' => $thread['reply_count']);
         $topicRows[] = $row;
     }
     $gridColumns = array(array('name' => 'topic', 'header' => 'Topic', 'type' => 'raw', 'value' => 'CHtml::link($data["topic"], array("post/readTopic", "id" => $data["id"]));'), array('name' => 'program_name', 'header' => 'Program', 'type' => 'raw', 'value' => 'CHtml::link($data["program_name"], array("programView", "programId" => $data["program"]));'), array('name' => 'semester', 'header' => 'Semester', 'type' => 'raw'), array('name' => 'postDate', 'header' => 'Post Date', 'filter' => false, 'value' => 'Yii::app()->timeagoFormat->timeago(new DateTime($data["postDate"]))'), array('name' => 'numReplies', 'header' => 'Replies', 'filter' => false));
     $filtersForm = new FiltersForm();
     if (isset($_GET['FiltersForm'])) {
         $filtersForm->filters = $_GET['FiltersForm'];
     }
     $filteredData = $filtersForm->filter($topicRows);
     $forumGridData = new CommunityArrayDataProvider(array_values($filteredData), array('sort' => array('attributes' => array('topic', 'program', 'postDate', 'numReplies')), 'pagination' => array('pageSize' => Yii::app()->params['forum_pageSize'])));
     $forumGridData->setPagination(false);
     $this->emptyText = "No topics could be found";
     $this->render('topics', array('gridColumns' => $gridColumns, 'forumGridData' => $forumGridData, 'filtersForm' => $filtersForm));
 }
 public function actionFindMentors()
 {
     $error = '';
     $domMentors = Yii::app()->db->createCommand("select u.id,sb.name as \"sname\", d.name as \"dname\",username  ,fname,lname,email,activated,disable\r\n\r\n\r\n          from domain_mentor dm, user_domain ud, user u, subdomain sb, domain d\r\n\r\n          where  dm.user_id=u.id and ud.user_id = u.id and ud.user_id = dm.user_id\r\n\r\n\t\tand sb.id = ud.subdomain_id and\r\n\r\n\t\tsb.domain_id = ud.domain_id and d.id = ud.domain_id")->queryAll();
     //$domMentors = User::model()->findAll();
     $filtersForm = new FiltersForm();
     if (isset($_GET['FiltersForm'])) {
         $filtersForm->filters = $_GET['FiltersForm'];
     }
     // Get rawData and create dataProvider
     $filteredData = $filtersForm->filter($domMentors);
     $dataProviderCompined = new CArrayDataProvider($filteredData, array('pagination' => array('pageSize' => 10)));
     $this->render('findMentors', array('domMentors' => $domMentors, 'dataProviderCompined' => $dataProviderCompined, 'filtersForm' => $filtersForm, 'error' => $error));
 }
Exemple #4
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $this->layout = "landing";
     $filtersForm = new FiltersForm();
     if (isset($_GET['FiltersForm'])) {
         $filtersForm->filters = $_GET['FiltersForm'];
     }
     // $user  = Yii::app()->user->name;
     // $id = Nasabah::model()->find("username='******'")->id_nasabah;
     // $status = Pengguna::model()->find('user=:un',array(':un'=>"$user"))->status;
     $dataProvider = Yii::app()->db->createCommand()->select('*')->from('team')->queryAll();
     // $string_model =  json_encode($dataProvider);
     $filteredData = $filtersForm->filter($dataProvider);
     $model = new CArrayDataProvider($filteredData, array('sort' => array('attributes' => array('id', 'name', 'username', 'skype')), 'pagination' => array('pageSize' => 10)));
     $this->render('admin', array('model' => $model, 'filtersForm' => $filtersForm));
 }
 public function actionDogovora($id_isp)
 {
     if (isset($id_isp) && is_numeric($id_isp)) {
         $filtersForm = new FiltersForm();
         if (isset($_GET['FiltersForm'])) {
             $filtersForm->filters = $_GET['FiltersForm'];
         }
         // Get rawData and create dataProvider
         // $rawData=User::model()->findAll();
         $dogovor_by_ispolnitel = Ispolnitel::model()->getDogovora($id_isp);
         $filteredData = $filtersForm->filter($dogovor_by_ispolnitel);
         //   $dataProvider=new CArrayDataProvider($filteredData);
         $count = count($dogovor_by_ispolnitel);
         $model = new CArrayDataProvider($filteredData, array('keyField' => 'dogovor_number', 'id' => 'dogovor_number', 'totalItemCount' => (int) $count, 'sort' => array('attributes' => array('name', 'dogovor_number', 'created_date', 'summa_dogovora_nachalnaya', 'contragent_name'), 'defaultOrder' => array('dogovor_number' => CSort::SORT_ASC)), 'pagination' => array('pageSize' => 10)));
         // Render
         /* $this->render('index', array(
                'filtersForm' => $filtersForm,
                'dataProvider' => $dataProvider,
            ));*/
         $this->render('dogovora', array('filtersForm' => $filtersForm, 'dogovor_info' => $model));
     } else {
         $this->actionAdmin();
     }
     // var_dump($dogovor_by_ispolnitel);
     //  exit();
     /*
                 $posts = new CSqlDataProvider($posts, array(
                     'keyField' => 'dogovor_number',
                     'id' => 'dogovor_number',
                     'totalItemCount' => (int)391,
                     'sort' => array(
                         'attributes' => array(
                             'dogovor_number', 'created_date', 'id_contragent',
                         ),
                         'defaultOrder' => array(
                             'dogovor_number' => CSort::SORT_ASC, //default sort value
                         ),
                     ),
                     'pagination' => array(
                         'pageSize' => 20,
                     ),
                 ));
     */
 }