当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchHandler::setGroupby方法代码示例

本文整理汇总了PHP中SearchHandler::setGroupby方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHandler::setGroupby方法的具体用法?PHP SearchHandler::setGroupby怎么用?PHP SearchHandler::setGroupby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchHandler的用法示例。


在下文中一共展示了SearchHandler::setGroupby方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run


//.........这里部分代码省略.........
         }
     }
     // if the filters aren't empty, apply them one by one
     if (!empty($options['filter'])) {
         // loop through filter lines
         foreach (range(1, 3) as $number) {
             if (!isset($filter_cc)) {
                 $filter_cc = new ConstraintChain();
             }
             // filter line 1 will never have an operator
             if ($number === 1) {
                 $operator = 'AND';
             } else {
                 $operator = $options['filter']['filter_' . $number . '_operator'];
             }
             $field = $options['filter']['filter_' . $number . '_field'];
             $condition = $options['filter']['filter_' . $number . '_condition'];
             $value = $options['filter']['filter_' . $number . '_value'];
             // if we're dealing with a valid filter line...
             if (($number === 1 or !empty($operator)) and !empty($value)) {
                 // add the field to the display fields
                 if (!array_search($field, $display_fields)) {
                     $display_fields = array_merge($display_fields, array($field));
                 }
                 // add the filter to the contraint chain
                 $filter_cc->add(new Constraint($field, $condition, $value), $operator);
             }
         }
     }
     // NB: The follow idField is being passed by reference... it isn't passing a value, instead recieving one back
     $do = $report->createDataObject($display_fields, $idField, $this->getColumns($report->tablename));
     $doc = new DataObjectCollection($do);
     $sh = new SearchHandler($doc, FALSE);
     $sh->setGroupby($display_fields);
     $sh->setOrderby($display_fields);
     if (!isset($this->_data['Search'])) {
         $this->_data['Search'] = array();
     }
     // we don't need a condition here... always display the search box
     $this->search = $report->createSearch($search_fields, $this->_data['Search']);
     $cc = $this->search->toConstraintChain();
     $cc->removeByField('report_id');
     $sh->addConstraintChain($cc);
     // if the filter constraint chain has been set, use it
     if (isset($filter_cc)) {
         $sh->addConstraintChain($filter_cc);
     }
     $measure_fields = array_merge(array('' => 'report'), $measure_fields);
     /// merge the aggregate methods array in with the display fields array
     // the aggregate methods array is preset as an array to allow for empty values
     // we don't use the array_merge function as we want to maintain keys (representing position)
     $display_fields = (array) $display_fields + (array) $aggregate_methods;
     if (count($aggregate_fields) === 0) {
         $this->view->set('aggregate_count', 0);
     }
     // sort display fields by key (position)
     ksort($display_fields);
     // prepend the id field to the display fields...
     // at this stage the items are in order, so keys don't matter
     $display_fields = array_merge(array($idField), $display_fields);
     $sh->setFields($display_fields);
     $data = $doc->load($sh, null, RETURN_ROWS);
     $this->view->set('total_records', $doc->total_records);
     $headings = $doc->getHeadings();
     // loop through headings...
     foreach ($headings as $key => $field) {
开发者ID:uzerpllp,项目名称:uzerp,代码行数:67,代码来源:ReportsController.php

示例2: select_products

 public function select_products()
 {
     $s_data = array();
     // so set context from calling module
     if (isset($this->_data['slmaster_id'])) {
         $s_data['slmaster_id'] = $this->_data['slmaster_id'];
     }
     if (isset($this->_data['parent_id'])) {
         $s_data['parent_id'] = $this->_data['parent_id'];
     }
     $this->setSearch('sordersSearch', 'selectProduct', $s_data);
     $slmaster_id = $this->search->getValue('slmaster_id');
     $this->view->set('slmaster_id', $slmaster_id);
     $slcustomer = DataObjectFactory::Factory('SLCustomer');
     if ($slmaster_id > 0) {
         $slcustomer->load($slmaster_id);
     }
     // Get the list of Product Headers for the selected item
     $product_ids = SelectorCollection::getTargets('sales_order', $this->search->getValue('parent_id'));
     $product = DataObjectFactory::Factory('SOProductLine');
     $product->identifierField = 'productline_header_id';
     $cc = new ConstraintChain();
     $customer_lines = array();
     if ($slcustomer->isLoaded()) {
         // Get any lines specific for this customer
         $this->view->set('slcustomer', $slcustomer->companydetail->name);
         $cc1 = new ConstraintChain();
         $cc1->add(new Constraint('slmaster_id', '=', $slcustomer->id));
         if (is_null($slcustomer->so_price_type_id)) {
             $cc1->add(new Constraint('so_price_type_id', 'is', 'NULL'));
             $cc->add(new Constraint('so_price_type_id', 'is', 'NULL'));
         } else {
             $cc1->add(new Constraint('so_price_type_id', '=', $slcustomer->so_price_type_id));
             $cc->add(new Constraint('so_price_type_id', '=', $slcustomer->so_price_type_id));
         }
         $cc1->add($product->currentConstraint());
         if (!empty($product_ids)) {
             $cc1->add(new Constraint('productline_header_id', 'in', '(' . implode(',', array_keys($product_ids)) . ')'));
         } else {
             $cc1->add(new Constraint('productline_header_id', '=', '-1'));
         }
         $customer_lines = $product->getAll($cc1, true, true);
         // Now exclude any lines for a header where the line for the customer exists
         if (count($customer_lines) > 0) {
             $cc->add(new Constraint('productline_header_id', 'not in', '(' . implode(',', $customer_lines) . ')'));
         }
     } else {
         $this->view->set('slcustomer', 'Not Set');
     }
     // Get the non-customer lines, excluding any lines for a header found above for a customer
     $cc->add(new Constraint('slmaster_id', 'is', 'NULL'));
     if (!empty($product_ids)) {
         $cc->add(new Constraint('productline_header_id', 'in', '(' . implode(',', array_keys($product_ids)) . ')'));
     } else {
         $cc->add(new Constraint('productline_header_id', '=', '-1'));
     }
     $cc->add($product->currentConstraint());
     $lines = $product->getAll($cc, true, true);
     $lines += $customer_lines;
     $products = new SOProductLineCollection($product);
     if (!isset($this->_data['orderby']) && !isset($this->_data['page'])) {
         $sh = new SearchHandler($products, false);
         $cc2 = new ConstraintChain();
         if (count($lines) > 0) {
             $cc2->add(new Constraint('id', 'in', '(' . implode(',', array_keys($lines)) . ')'));
         } else {
             // No lines found, so ensure no rows returned
             $cc2->add(new Constraint('id', '=', -1));
         }
         $sh->addConstraint($cc2);
     } else {
         $sh = new SearchHandler($products);
     }
     $sh->extract();
     $fields = array('id', 'description', 'price', 'currency', 'uom_name', 'so_price_type', 'stitem_id', 'slmaster_id', 'prod_group_id');
     $sh->setFields($fields);
     $sh->setGroupby($fields);
     $sh->setOrderby(array('description', 'so_price_type'));
     parent::index($products, $sh);
     $this->view->set('stitem', DataObjectFactory::Factory('STItem'));
     if (empty($this->_data['sorders'])) {
         $this->_data['sorders'] = array();
     }
     $this->view->set('selected', $this->_data['sorders']);
     foreach ($this->_modules as $key => $value) {
         $modules[] = $key . '=' . $value;
     }
     $link = implode('&', $modules) . '&controller=' . $this->name . '&action=showProducts';
     $this->view->set('link', $link);
     $selectedproduct = empty($_SESSION['selectedproducts']) ? array() : $_SESSION['selectedproducts'];
     $selectedproducts = new SOProductLineCollection(DataObjectFactory::Factory('SOProductLine'));
     if (!empty($selectedproduct)) {
         $sh = new SearchHandler($selectedproducts, false);
         $sh->addConstraint(new Constraint('id', 'in', '(' . implode(',', array_keys($selectedproduct)) . ')'));
         $selectedproducts->load($sh);
     }
     $this->view->set('selected', $selectedproduct);
     $this->view->set('productlines', $selectedproducts);
     $this->view->set('page_title', $this->getPageName('', 'Select Products for'));
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:100,代码来源:SordersController.php


注:本文中的SearchHandler::setGroupby方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。