コード例 #1
0
 public function actionGetBidHistory($id)
 {
     $dataAdapter = new CActiveDataProvider('Bidding', array('criteria' => array('condition' => 'fk_user = 1', 'limit' => '10', 'order' => 'id_bidding DESC')));
     $this->apiResponse['data'] = $dataAdapter->getData();
     $this->apiResponse['success'] = true;
     $this->sendResponse();
 }
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->loginRequired();
     }
     $settings = array();
     // Get user settings.
     $criteria = new CDbCriteria(array('condition' => 'uid=' . Yii::app()->user->id));
     $dataProvider = new CActiveDataProvider('DashboardPortlet', array('criteria' => $criteria));
     $data = $dataProvider->getData();
     if (isset($data[0])) {
         $userSettings = unserialize($data[0]->settings);
         foreach ($userSettings as $class => $properties) {
             $settings[$properties['column']][$properties['weight']] = array('class' => $class, 'visible' => $properties['visible'], 'weight' => $properties['weight']);
         }
         foreach ($settings as $key => $value) {
             // Sort all portlets in every column by weight.
             ksort($settings[$key]);
         }
     }
     // Use the default portlets settings if user did not set any portlet before.
     if (empty($settings)) {
         $deaultSettings = $this->getModule()->portlets;
         foreach ($deaultSettings as $class => $properties) {
             $column = isset($properties['column']) ? $properties['column'] : 0;
             $settings[$column][$properties['weight']] = array('class' => $class, 'visible' => isset($properties['visible']) ? $properties['visible'] : true, 'weight' => $properties['weight']);
         }
     }
     $this->render('index', array('portlets' => $settings));
 }
コード例 #3
0
 public function actionFeed()
 {
     Yii::import('aiajaya.extensions.efeed.*');
     // RSS 2.0 is the default type
     $feed = new EFeed();
     $feed->title = 'Gästebuch von ' . Yii::app()->name;
     $feed->description = 'Das Gästebuch vom ' . Yii::app()->name;
     $feed->addChannelTag('language', 'de-de');
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('/page/guestbook/list'));
     // * self reference
     $feed->addChannelTag('atom:link', $this->createAbsoluteUrl('/page/guestbook/feed'));
     $criteria = new CDbCriteria(array('order' => '`createDate` DESC'));
     $dataProvider = new CActiveDataProvider('Comment', array('pagination' => array('pageSize' => 0), 'criteria' => $criteria));
     foreach ($dataProvider->getData() as $comment) {
         $item = $feed->createNewItem();
         $item->title = $comment->getBaseModel()->commentName;
         $item->link = $this->createAbsoluteUrl('/page/page/get', array('key' => $comment->getBaseModel()->key));
         $item->date = $comment->createDate;
         $item->description = $comment->message;
         $item->addTag('author', $comment->name);
         //$item->addTag('guid', 'http://www.ramirezcobos.com/',array('isPermaLink'=>'true'));
         $feed->addItem($item);
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
コード例 #4
0
ファイル: UsersController.php プロジェクト: dsyman2/X2CRM
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $user = User::model()->findByPk($id);
     $dataProvider = new CActiveDataProvider('Actions', array('criteria' => array('order' => 'complete DESC', 'condition' => 'assignedTo=\'' . $user->username . '\'')));
     $actionHistory = $dataProvider->getData();
     $this->render('view', array('model' => $this->loadModel($id), 'actionHistory' => $actionHistory));
 }
コード例 #5
0
 /**
  * getListItems - Phương thức dùng để lấy dữ liệu
  */
 public function getListItems($category_id = null)
 {
     Yii::import('application.modules.products.models.ProductItem');
     $model = new ProductItem('search');
     $model->unsetAttributes();
     $criteria = new CDbCriteria();
     $criteria->order = 'created DESC';
     if ($category_id) {
         Yii::import('application.modules.products.models.ProductCategory');
         $categories = ProductCategory::model()->findByPk($category_id);
         if (!$categories) {
             return null;
         }
         $this->__category = $categories;
         $descendants = $categories->descendants()->findAll('is_active = 1');
         $arrCat = array($category_id);
         foreach ($descendants as $cat) {
             $arrCat[] = $cat->id;
         }
         $criteria->with = array('categoryitem');
         $criteria->together = true;
         foreach ($arrCat as $cat) {
             $criteria->compare('categoryitem.category_id', $cat, false, 'OR');
         }
     }
     $criteria->compare('status', 1);
     $search = new CActiveDataProvider($model, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->getModule('products')->entriesShow)));
     $data = $search->getData();
     $this->__pagination = $search->pagination;
     return $data;
 }
コード例 #6
0
ファイル: Plan.php プロジェクト: tiger2soft/travelman
 /**
  *
  * 改进:使用延迟绑定,将这个函数写在父类里面
  *返回某个用户所发布的所有计划列表
  * @return CActiveDataProvider $dataProvider  返回CActiveDataProvider对象
  * 使用attach的好处是随时绑定,不一定在初始化的时候绑定
  */
 public function getDataProvider(CFormModel &$condition)
 {
     $this->attachBehaviors(array('NearScopeBehavior' => array('class' => 'ext.behavior.NearScopeBehavior', 'latitude' => $condition->latitude, 'longitude' => $condition->longitude)));
     $dataProvider = new CActiveDataProvider(Plan::model()->unexpired()->near()->with('user'), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($this->addCondition($condition));
     return $dataProvider;
 }
コード例 #7
0
 public function actionExcel($id)
 {
     $po = $this->loadModel($id);
     $poItemCriteria = new CDbCriteria();
     $poItemCriteria->with = array('material');
     $poItemCriteria->compare('po_number', $id);
     $poItemDataProvider = new CActiveDataProvider('PoItems', array('criteria' => $poItemCriteria, 'pagination' => false));
     Yii::import('ext.phpexcel.XPHPExcel');
     $objPHPExcel = XPHPExcel::createPHPExcel();
     $objReader = PHPExcel_IOFactory::createReader('Excel5');
     $objPHPExcel = $objReader->load(Yii::app()->basePath . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "PO_Template.xls");
     $objPHPExcel->getProperties()->setCreator(Yii::app()->user->name)->setLastModifiedBy(Yii::app()->user->name)->setTitle("PO Order-" . $id);
     //->setSubject("Office 2007 XLSX Test Document")
     //->setDescription("Sales Order#")
     //->setKeywords("office 2007 openxml php")
     //->setCategory("Test result file");
     // Add the data
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C2', $po->po_number)->setCellValue('C3', Yii::app()->dateFormatter->formatDateTime($po->maturity_date, "short", null))->setCellValue('C4', Yii::app()->dateFormatter->formatDateTime($po->created, "short", null))->setCellValue('C5', Yii::app()->dateFormatter->formatDateTime($po->updated, "short", null))->setCellValue('E2', $po->comp->name)->setCellValue('E3', $po->contact)->setCellValue('E4', $po->contact_telephone)->setCellValue('C6', $po->paymentTerm->description)->setCellValue('C7', $po->is_open ? "Open" : "Closed")->setCellValue('A8', "Comments:\r" . $po->comments);
     $row = 13;
     //$i = 1;
     // Write the sale items now
     $items = $poItemDataProvider->getData();
     foreach ($items as $item) {
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $row, $item->material->cat->description . "-" . $item->material->description)->setCellValue("D" . $row, $item->qty)->setCellValue("E" . $row, $item->qty_units)->setCellValue("F" . $row, $item->unit_price)->setCellValue("G" . $row, $item->price_units)->setCellValue("H" . $row, $item->qty_recieved)->setCellValue("I" . $row, $item->qty_diff);
         //$i++;
         $row++;
     }
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     // Redirect output to a client’s web browser
     //header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename=' . '"PurchaseOrder-' . $id . '.xls"');
     header('Cache-Control: max-age=0');
     $objWriter->save('php://output');
 }
コード例 #8
0
 /**
  * Manages all models.
  */
 public function actionDashboard()
 {
     /* Wall Post */
     $model = new OmmuWalls();
     /* Get Walll */
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish';
     $criteria->params = array(':publish' => 1);
     $criteria->order = 'creation_date DESC';
     $dataProvider = new CActiveDataProvider('OmmuWalls', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
     $data = '';
     $wall = $dataProvider->getData();
     if (!empty($wall)) {
         foreach ($wall as $key => $item) {
             $data .= Utility::otherDecode($this->renderPartial('/wall/_view', array('data' => $item), true, false));
         }
     }
     $pager = OFunction::getDataProviderPager($dataProvider);
     if ($pager[nextPage] != '0') {
         $summaryPager = 'Displaying 1-' . $pager[currentPage] * $pager[pageSize] . ' of ' . $pager[itemCount] . ' results.';
     } else {
         $summaryPager = 'Displaying 1-' . $pager[itemCount] . ' of ' . $pager[itemCount] . ' results.';
     }
     $nextPager = $pager['nextPage'] != 0 ? Yii::app()->createUrl('wall/get', array($pager['pageVar'] => $pager['nextPage'])) : 0;
     $this->pageTitle = Yii::t('phrase', 'Welcome') . ', ' . Yii::app()->user->displayname . '!';
     $this->pageDescription = Yii::t('phrase', 'Welcome to your social network control panel. Here you can manage and modify every aspect of your social network. Directly below, you will find a quick snapshot of your social network including some useful statistics.');
     $this->pageMeta = '';
     $this->render('application.webs.admin.admin_dashboard', array('model' => $model, 'data' => $data, 'pager' => $pager, 'summaryPager' => $summaryPager, 'nextPager' => $nextPager));
 }
コード例 #9
0
 public function actionIndex()
 {
     $with = array('active_keywords');
     $whereType = "and t.type='" . Globals::TYPE_REGISTRATION . "' and active_keywords.type='" . Globals::TYPE_ACTIVE . "'";
     $this->layout = '//layouts/memberList';
     $dataProvider = new CActiveDataProvider('ActiveModel', array('criteria' => array('order' => 't.id DESC', 'with' => $with, 'condition' => "t.wechatId = {$this->wechatInfo->id} {$whereType}", 'together' => true), 'pagination' => array('pageSize' => Page::SIZE, 'pageVar' => 'page')));
     $this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'wechatInfo' => $this->wechatInfo));
 }
コード例 #10
0
 public function actionIndex()
 {
     $roleDataProvider = new CActiveDataProvider('AuthItem', array('criteria' => array('condition' => 'type=2')));
     echo '<pre>';
     var_dump($roleDataProvider->getData());
     echo '</pre>';
     exit;
     $this->render('index');
 }
コード例 #11
0
 public function getRoomTypeList()
 {
     $dataProvider = new CActiveDataProvider('RoomType');
     $roomTypes = $dataProvider->getData();
     $roomTypesDropdown = array();
     foreach ($roomTypes as $roomType) {
         $roomTypesDropdown[$roomType->id] = $roomType->description;
     }
 }
コード例 #12
0
 /**
  * @param bool $ajax
  */
 public function actionIndex($ajax = false)
 {
     if ($ajax) {
         $dataProvider = new CActiveDataProvider('SurveillanceSections', ['criteria' => ['condition' => "tool='surveillance'", 'select' => 'sectionId, sectionName, description']]);
         echo CJSON::encode(['aaData' => $dataProvider->getData()]);
         return;
     }
     $this->render('index');
 }
コード例 #13
0
 public function run($args)
 {
     ignore_user_abort(true);
     set_time_limit(0);
     $dataProvider = new CActiveDataProvider('Category', array('criteria' => array('order' => 'id ASC'), 'pagination' => false));
     foreach ($dataProvider->getData() as $category) {
         echo $category->name;
     }
 }
コード例 #14
0
ファイル: SiteController.php プロジェクト: nellka/mebel
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     //$this->redirect('/card/index');
     //$dataProvider=new CActiveDataProvider('Product');
     $dataProvider = new CActiveDataProvider('Product', array('pagination' => array('pageSize' => 100)));
     $products = $dataProvider->getData();
     $model = new Order();
     $this->render('index', compact('model', 'products'));
 }
コード例 #15
0
 /**
  * Lists all models.
  * @param $ajax bool
  */
 public function actionIndex($ajax = false)
 {
     if ($ajax) {
         $dataProvider = new CActiveDataProvider('EconomicMethods', ['criteria' => ['with' => ['econMethodGroup']]]);
         //			print_r($dataProvider->getData()); die;
         echo json_encode(['aaData' => ModelToArray::convertModelToArray($dataProvider->getData())]);
         return;
     }
     $this->render('index');
 }
コード例 #16
0
 public function actionFindUser($group, $term)
 {
     $dataProvider = new CActiveDataProvider('User', array('criteria' => array('select' => array('id', 'email')), 'pagination' => array('pageSize' => 500)));
     $criteria = $dataProvider->getCriteria();
     $criteria->compare('email', $term, true);
     $result = CHtml::listData($dataProvider->getData(), 'id', 'email');
     $members = Yii::app()->db->createCommand()->select('userid')->from(AuthAssignment::model()->tableName())->where('itemname=:group', array(':group' => $group))->queryColumn();
     echo CJSON::encode(array_diff_key($result, array_flip($members)));
     Yii::app()->end();
 }
コード例 #17
0
 /**
  * Lists all models.
  * @param $ajax bool
  */
 public function actionIndex($ajax = false)
 {
     if ($ajax) {
         $dataProvider = new CActiveDataProvider('EvaAttributesAssessmentMethods', ['criteria' => ['with' => ['evaAttributes']]]);
         //print_r(ModelToArray::convertModelToArray($dataProvider->getData())); die;
         echo json_encode(['aaData' => ModelToArray::convertModelToArray($dataProvider->getData())]);
         return;
     }
     $this->render('index');
 }
コード例 #18
0
ファイル: NavPage.php プロジェクト: stan5621/jp_edu_online
 /**
  * 将page组装成nav item
  * Enter description here ...
  */
 public static function getPageItems()
 {
     $pageDataProvider = new CActiveDataProvider('BottomText', array('criteria' => array('order' => 'weight asc ')));
     $items = array();
     foreach ($pageDataProvider->getData() as $page) {
         $item['content'] = $page->content;
         $items[] = $item;
     }
     return $items;
 }
コード例 #19
0
ファイル: Mensajesd.php プロジェクト: hipogea/zega
 public function listarcorreos($ideven, $externo)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id, true);
     $criteria->compare('correodestinatario', $this->correodestinatario, true);
     $criteria->addCondition('hidevento=' . $externo);
     $criteria->addCondition("esinterno='" . $ideven . "'");
     $prove = new CActiveDataProvider($this, array('criteria' => $criteria));
     return $prove->getdata();
 }
コード例 #20
0
ファイル: GroupController.php プロジェクト: 00606/wechat
 public function actionUser()
 {
     $this->layout = '//layouts/list';
     $group = GroupModel::model()->findall();
     foreach ($group as $v) {
         $groupList[$v->group_id] = $v->name;
     }
     $dataProvider = new CActiveDataProvider('UserModel', array('criteria' => array('order' => 'uid desc'), 'pagination' => array('pageSize' => Page::SIZE)));
     $this->render('userList', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'group' => $groupList));
 }
コード例 #21
0
ファイル: DefaultController.php プロジェクト: kostya1017/our
    public function actionIndex($confirm = 0)
    {
        $this->layout = '//layouts/column1';
        if ($confirm) {
            $this->render('cvconfirm');
        } else {
            $formModel = new JobForm();
            $cvModel = new JobCv();
            $job = new Job();
            $jobProvider = new CActiveDataProvider('Job', array('criteria' => array('condition' => 'active = 1', 'order' => 'category_id ASC, title ASC'), 'pagination' => false));
            $jobCategory = JobCategory::model()->findAll();
            foreach ($jobProvider->getData() as $data) {
                $formModel->{$data['id']} = null;
            }
            if (isset($_POST['JobForm'])) {
                $listJob = '<ul>';
                $oneChecked = false;
                foreach ($_POST['JobForm'] as $key => $item) {
                    if (is_numeric($key) && $item == '1') {
                        $oneChecked = true;
                        $jobChecked = Job::model()->findByPk($key);
                        $listJob .= '<li>' . $jobChecked->title . ' (' . $jobChecked->category->name . ')</li>';
                    }
                }
                $listJob .= '</ul>';
                $cvModel->date = date('Y-m-d H:i:s');
                $cvModel->cv = $_POST['JobCv']['cv'];
                if (!$oneChecked) {
                    $cvModel->addError('cv', Yii::t('jobModule.common', 'Vous devez cocher au moins un emploi'));
                } elseif ($cvModel->save()) {
                    foreach ($_POST['JobForm'] as $attribute => $value) {
                        if (is_numeric($attribute) && $value == '1') {
                            $jobId = (int) $attribute;
                            Yii::app()->db->createCommand('INSERT INTO job_job_cv (job_id, job_cv_id) VALUES (:job_id, :job_cv_id)')->execute(array(':job_id' => $jobId, ':job_cv_id' => $cvModel->id));
                        }
                    }
                    $subject = 'Postulation pour une offre d’emploi';
                    $body = '
					<p>Bonjour,<br/><br/>
					Vous avez reçu une candidature pour un ou plusieurs emplois à partir du site Web d`Arianne Phosphate Inc.<br/>
					' . $listJob . '<br/>
					<a href="' . $this->createAbsoluteUrl('admincv/read', array('id' => $cvModel->id)) . '">Voir les détails de la candidature</a><br/><br/>
					</p>
					';
                    $attachment = "./" . $cvModel->cvHandler->dir . "/" . Helper::encodeFileName($cvModel->cv);
                    if (($mailerError = Helper::sendMail($this->module->cvEmail, $subject, $body, $attachment)) !== true) {
                        throw new CHttpException(500, $mailerError);
                    }
                    $this->redirect($this->createUrl('index', array('confirm' => 1)));
                }
            }
            $this->render('index', array('jobProvider' => $jobProvider, 'categories' => $jobCategory, 'formModel' => $formModel, 'cvModel' => $cvModel));
        }
    }
コード例 #22
0
ファイル: CompaniesController.php プロジェクト: asopin/portal
 public function actionView($id)
 {
     $company = Company::model()->findByPk($id);
     if (!$company) {
         throw new CHttpException(404, 'Company not found');
     }
     $usersDataProvider = new CActiveDataProvider(User::class);
     $usersDataProvider->setData($company->users);
     $usersDataProvider->sort = false;
     $this->render('view', ['company' => $company, 'usersDataProvider' => $usersDataProvider]);
 }
コード例 #23
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $relationComponent = new RelationComponent();
     $friends = $relationComponent->getfriends();
     $criteria->addInCondition('userId', $friends);
     $criteria->order = 'photoId DESC';
     $dataProvider = new CActiveDataProvider('Photo', array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($criteria);
     $this->page($dataProvider);
     $this->render('index');
 }
コード例 #24
0
ファイル: CustomerController.php プロジェクト: zwq/unpei
 public function actionSelfquestion()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'ID DESC';
     $criteria->addCondition("Promoter = '" . Yii::app()->user->getOrganID() . "'");
     //接收表单数据(查询条件)
     $title = Yii::app()->request->getParam("Title");
     $organName = Yii::app()->request->getParam("OrganName");
     $state = Yii::app()->request->getParam("State");
     if (!empty($title)) {
         $criteria->addSearchCondition("Title", "{$title}");
     }
     if (!empty($organName)) {
         $criteria->addSearchCondition("OrganName", "{$organName}");
     }
     if (!empty($state)) {
         $criteria->addCondition("State = {$state}");
     }
     $dataProvider = new CActiveDataProvider('Question', array('criteria' => $criteria, 'pagination' => array('pageSize' => '15')));
     $data = $dataProvider->getData();
     foreach ($data as $key => $val) {
         $val['SubmitTime'] = date("Y-m-d h:i:s", $val['SubmitTime']);
         //状态
         if ($val['State'] == 1) {
             $val['State'] = "待分配";
         } elseif ($val['State'] == 2) {
             $val['State'] = "待解答";
         } elseif ($val['State'] == 3) {
             $val['State'] = "待反馈";
         } elseif ($val['State'] == 4) {
             $val['State'] = "完结";
         } elseif ($val['State'] == 5) {
             $val['State'] = "重新开启";
         } elseif ($val['State'] == 6) {
             $val['State'] = "待回访";
         }
         //类型
         if ($val['Type'] == 1) {
             $val['Type'] = "账号问题";
         } elseif ($val['Type'] == 2) {
             $val['Type'] = "交易问题";
         } elseif ($val['Type'] == 3) {
             $val['Type'] = "商品问题";
         } elseif ($val['Type'] == 4) {
             $val['Type'] = "数据问题";
         } elseif ($val['Type'] == 5) {
             $val['Type'] = "意见和建议";
         } elseif ($val['Type'] == 6) {
             $val['Type'] = "其他";
         }
     }
     $this->render("selfquestion", array('dataProvider' => $dataProvider, 'title' => $title, 'organName' => $organName, 'state' => $state));
 }
コード例 #25
0
 public function actionAdmin()
 {
     $title = Yii::app()->request->getParam('title', false);
     $criteria = new CDbCriteria();
     $criteria->order = 'id desc';
     if ($title) {
         $criteria->compare('title', $title, true);
     }
     $dataProvider = new CActiveDataProvider('DreamApp');
     $dataProvider->setCriteria($criteria);
     $this->render('admin', array('title' => $title, 'dataProvider' => $dataProvider));
 }
コード例 #26
0
ファイル: Relation.php プロジェクト: tiger2soft/travelman
 /**
  * 返回某个关系的列表。应该按照用户名的大小写来排序,但是这里暂时成了按照注册日期来排序的!
  * @param  $type  填写四个:friends,follows,fans,blacks
  * @return CActiveDataProvider  返回CActiveDataProvider对象
  */
 public function getList($type)
 {
     $relationComponent = new RelationComponent();
     $function = 'get' . $type;
     $list = $relationComponent->{$function}();
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.userId', $list);
     $criteria->order = 't.userId desc';
     $dataProvider = new CActiveDataProvider(User::model(), array('pagination' => array('pageSize' => 20)));
     $dataProvider->setCriteria($criteria);
     return $dataProvider;
 }
コード例 #27
0
ファイル: NewsController.php プロジェクト: hntvu/db_for_site
 /**
  * Lists all models.
  */
 public function actionIndex($controller, $alias = NULL)
 {
     if ($alias != NULL) {
         $model = new News();
         $criteria = new CDbCriteria();
         $criteria->join = 'INNER JOIN menu c ON c.id = t.idmenu';
         $criteria->condition = 'c.alias="' . $alias . '"' . ' AND c.controller ="' . $controller . '"';
         $criteria->order = 'datecreate DESC';
         $dataProvider = new CActiveDataProvider('News', array('criteria' => $criteria, 'pagination' => array('pageSize' => 3)));
         $model = $dataProvider->getData();
         $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
     }
 }
コード例 #28
0
ファイル: ArticleController.php プロジェクト: piond/new_rsud
 protected function getArticleTags($id)
 {
     $tag = array();
     $criteria = new CDbCriteria(array('alias' => '_articletags', 'condition' => '_articletags.article_id=' . $id, 'with' => array('tags' => array('alias' => '_tags', 'order' => 'tag'))));
     $dataProvider = new CActiveDataProvider('Articletags', array('criteria' => $criteria));
     foreach ($dataProvider->getData() as $tags) {
         $_tagsId = $tags['tags']['tag_id'];
         $_tagName = $tags['tags']['tag'];
         $tag[$_tagsId] = $_tagName;
     }
     $tag = implode($tag, ',');
     return $tag;
 }
コード例 #29
0
 /**
  * Manages all models.
  */
 public function actionIndex($cat = null)
 {
     if (!$cat) {
         $cat = SnapUtil::config('boxomatic/supplier_product_feature_category');
     }
     $BoxoCart = new BoxoCart();
     if (isset($_GET['set-date'])) {
         $BoxoCart->setDelivery_date_id($_GET['set-date']);
     }
     if (isset($_POST['BoxoCart']['location_id'])) {
         $BoxoCart->location_id = $_POST['BoxoCart']['location_id'];
         $this->refresh();
     }
     if (isset($_POST['Order']) && isset($_POST['add_to_cart'])) {
         if ($BoxoCart->addItems($_POST['Order'])) {
             Yii::app()->user->setFlash('success', 'Item added to cart.');
             #redirect to category
             if ($cat == 'box') {
                 $this->redirect(array('shop/index', 'date' => Yii::app()->request->getParam('date'), 'cat' => SnapUtil::config('boxomatic/redirectBoxCategory')));
             }
         }
         $this->refresh();
     }
     if (isset($_POST['Order']) && (isset($_POST['update_cart']) || isset($_POST['checkout']))) {
         if ($BoxoCart->updateItems($_POST['Order'])) {
             Yii::app()->user->setFlash('success', 'Cart updated.');
         }
         if (isset($_POST['checkout'])) {
             $this->redirect(array('shop/checkout'));
         }
         $this->refresh();
     }
     $userId = Yii::app()->user->id;
     $User = BoxomaticUser::model()->findByPk($userId);
     $Category = Category::model()->findByPk($cat);
     $DeliveryDate = false;
     $dpProducts = false;
     $Location = $BoxoCart->Location;
     if ($Location) {
         if (!$BoxoCart->DeliveryDate) {
             $DeliveryDate = $BoxoCart->getNextDeliveryDate();
         } else {
             $DeliveryDate = $BoxoCart->DeliveryDate;
         }
         $BoxoCart->setDelivery_date_id($DeliveryDate->id);
         $products = SupplierProduct::getAvailableItems($DeliveryDate->id, $cat);
         $dpProducts = new CActiveDataProvider('SupplierProduct');
         $dpProducts->setData($products);
     }
     $this->render('index', array('dpProducts' => $dpProducts, 'DeliveryDate' => $DeliveryDate, 'Category' => $Category, 'Customer' => $User, 'curCat' => $cat, 'BoxoCart' => $BoxoCart, 'Location' => $Location));
 }
コード例 #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,
        ));
    }