예제 #1
0
 /**
  *  Override to handle spanning of row.  Used primarily by matrix reports to render a grid
  */
 public function renderFooterCell()
 {
     if (isset($this->footer)) {
         return parent::renderFooterCell();
     }
     return null;
 }
예제 #2
0
 /**
  * Renders the header cell content.
  * This method will render a link that can trigger the sorting if the column is sortable.
  */
 protected function renderHeaderCellContent()
 {
     if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
         echo $this->grid->dataProvider->getSort()->link($this->name, $this->header);
     } else {
         parent::renderHeaderCellContent();
     }
 }
예제 #3
0
 public function getDataCellContent($row)
 {
     if (method_exists(get_parent_class($this), 'getDataCellContent')) {
         return parent::getDataCellContent($row);
     }
     ob_start();
     $this->renderDataCellContent($row, $this->grid->dataProvider->data[$row]);
     return ob_get_clean();
 }
예제 #4
0
 public function init()
 {
     parent::init();
     $data = $this->grid->dataProvider->getData();
     if (count($data) == 0) {
         return;
     }
     $this->link = ObjectUrlRule::createUrlFromCurrent(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT_PARENT => '{id}'), array(ObjectUrlRule::PARAM_SYSTEM_MODULE, ObjectUrlRule::PARAM_PAGER_NUM, ObjectUrlRule::PARAM_OBJECT_INSTANCE, ObjectUrlRule::PARAM_ACTION_VIEW));
     $this->countData = $this->grid->dataProvider->model->getCountChildOfInstances($data);
 }
예제 #5
0
 /**
  * Renders the header cell content.
  * This method will render a link that can trigger the sorting if the column is sortable.
  */
 protected function renderHeaderCellContent()
 {
     if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
         echo $this->grid->dataProvider->getSort()->link($this->name, $this->header, array('class' => 'sort-link'));
     } elseif ($this->name !== null && $this->header === null) {
         if ($this->grid->dataProvider instanceof CActiveDataProvider) {
             echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
         } else {
             echo CHtml::encode($this->name);
         }
     } else {
         parent::renderHeaderCellContent();
     }
 }
예제 #6
0
 /**
  * Renders the header cell content.
  * This method will render a checkbox in the header when {@link CGridView::selectableRows} is greater than 1.
  */
 protected function renderHeaderCellContent()
 {
     if ($this->grid->selectableRows > 1) {
         echo CHtml::checkBox($this->id . '_all', false);
     } else {
         parent::renderHeaderCellContent();
     }
 }
예제 #7
0
 public function init()
 {
     parent::init();
 }
예제 #8
0
 /**
  * A seam for people extending CGridView to be able to hook onto the data cell rendering process.
  * 
  * By overriding only this method we will not need to copypaste and modify the whole entirety of `renderTableRow`.
  * Or override `renderDataCell()` method of all possible CGridColumn descendants.
  * 
  * @param CGridColumn $column The Column instance to 
  * @param integer $row
  * @since 1.1.17
  */
 protected function renderDataCell($column, $row)
 {
     $column->renderDataCell($row);
 }
 /**
  * @param CGridColumn $column
  * @param integer $row
  *
  * @return string
  */
 private function getRenderedDataCellValue($column, $row)
 {
     ob_start();
     $column->renderDataCell($row);
     return ob_get_clean();
 }
예제 #10
0
 /**
  * Renders the filter cell content.
  * This method will render the {@link filter} as is if it is a string.
  * If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered.
  * Otherwise if {@link filter} is not false, a text field is rendered.
  * @since 1.1.1
  */
 protected function renderFilterCellContent()
 {
     if ($this->filter !== null) {
         if (is_string($this->filter)) {
             echo $this->filter;
         } else {
             if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) {
                 if (is_array($this->filter)) {
                     echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id' => false, 'prompt' => ''));
                 } else {
                     if ($this->filter === null) {
                         echo CHtml::activeTextField($this->grid->filter, $this->name, array('id' => false));
                     }
                 }
             } else {
                 parent::renderFilterCellContent();
             }
         }
     }
 }
 /**
  * Render header cell (can not be sortable)
  */
 protected function renderHeaderCellContent()
 {
     if ($this->name !== null && $this->header === null) {
         if ($this->grid->dataProvider instanceof CActiveDataProvider) {
             echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
         } else {
             echo CHtml::encode($this->name);
         }
     } else {
         parent::renderHeaderCellContent();
     }
 }
예제 #12
0
    public function init()
    {
        parent::init();
        $arrayOfId = $this->grid->dataProvider->getKeys();
        if (count($arrayOfId) == 0) {
            return;
        }
        $availableObjects = array();
        $singleStatus = 0;
        foreach ($this->childData as $param) {
            if ($param->isRelation() == false) {
                continue;
            }
            $idObject = $param->getIdObjectParameter();
            // Смотрим, может ли пользователь работать с подчинённым объектом
            if (isset($availableObjects[$idObject]) && $availableObjects[$idObject] === null) {
                continue;
            }
            if (!Yii::app()->authManager->checkObject(DaDbAuthManager::OPERATION_LIST, Yii::app()->user->id, $idObject)) {
                $availableObjects[$idObject] = null;
                continue;
            } else {
                $singleStatus = $singleStatus == 0 ? 1 : 2;
                $availableObjects[$idObject][$param->getIdParameter()]['field'] = $param->getFieldName();
            }
        }
        if ($singleStatus == 2) {
            $this->single = false;
            $this->htmlOptions = array('class' => 'col-ref action-sub-data');
        } else {
            $this->htmlOptions = array('class' => 'col-ref-one action-sub-data');
        }
        foreach ($availableObjects as $idObject => $params) {
            if ($params === null) {
                unset($availableObjects[$idObject]);
                continue;
            }
            $object = null;
            if (count($params) == 1) {
                $object = DaObject::getById($idObject, false);
                foreach ($params as $idParameter => $caption) {
                    $availableObjects[$idObject][$idParameter]['caption'] = $object->name;
                }
            } else {
                $object = DaObject::getById($idObject, true);
                foreach ($params as $idParameter => $caption) {
                    $param = $object->getParameterObjectByIdParameter($idParameter);
                    $availableObjects[$idObject][$idParameter]['caption'] = $object->name . ' (' . $param->caption . ')';
                }
            }
            $model = $object->getModel();
            foreach ($params as $idParameter => $config) {
                $cr = new CDbCriteria();
                $cr->addColumnCondition(array('t.id_object' => $idObject));
                $cr->order = 't.order_no';
                $objectView = DaObjectView::model()->find($cr);
                $dataProvider = Yii::app()->controller->buildDataProvider($objectView, $model);
                $where = $dataProvider->criteria->condition;
                $params = $dataProvider->criteria->params;
                $whereConfig = array('and');
                if ($where != null) {
                    $whereConfig[] = $where;
                }
                $whereConfig[] = array('in', $config['field'], $arrayOfId);
                $data = Yii::app()->db->createCommand()->select($config['field'] . ' AS id, count(*) AS cnt')->from($model->tableName())->where($whereConfig, $params)->group($config['field'])->queryAll();
                /*
                        // многообъектая поддержка
                        $iq = new InstanceQuery($where);
                        $arrayOfIdObject = Object::getCommonObjectBySingle($idObjectTmp);
                        if (count($arrayOfIdObject) > 1) {
                          $iq->setUsedObjects(array($idObjectTmp));
                        }*/
                $assocData = array();
                foreach ($data as $row) {
                    $assocData[$row['id']] = $row['cnt'];
                }
                $availableObjects[$idObject][$idParameter]['data'] = $assocData;
            }
        }
        $this->prepareData = $availableObjects;
        // TODO: Поменять скрипт, когда будет применяться PopOver
        if (!$this->single) {
            Yii::app()->clientScript->registerScript('admin.subData.init', '$(".action-sub-data").daSubData();
$(document).on("afterGridUpdate", function(e) {  $(".action-sub-data").daSubData(); });
', CClientScript::POS_READY);
            /*
                    Yii::app()->clientScript->registerScript('admin.subData.init', '
                    $("[rel=\'popover-sub-data\']").popover({
                      placement: "left",
                      trigger:   "hover",
                      template:  "<div class=\'popover\'><div class=\'arrow\'></div><div class=\'popover-inner\'><div class=\'popover-content\'></div></div></div>"
                    });', CClientScript::POS_READY);
            */
        }
    }
예제 #13
0
 /**
  * Renders the header cell content.
  * This method will render a checkbox in the header when {@link selectableRows} is greater than 1
  * or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1.
  */
 protected function renderHeaderCellContent()
 {
     if (trim($this->headerTemplate) === '') {
         echo $this->grid->blankDisplay;
         return;
     }
     $item = '';
     if ($this->selectableRows === null && $this->grid->selectableRows > 1) {
         $item = CHtml::checkBox($this->id . '_all', false, array('class' => 'select-on-check-all'));
     } elseif ($this->selectableRows > 1) {
         $item = CHtml::checkBox($this->id . '_all', false);
     } else {
         ob_start();
         parent::renderHeaderCellContent();
         $item = ob_get_clean();
     }
     echo strtr($this->headerTemplate, array('{item}' => $item));
 }
예제 #14
0
 /**
  * Returns the header cell content.
  * This method will render a checkbox in the header when {@link selectableRows} is greater than 1
  * or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1.
  * @return string the header cell content.
  * @since 1.1.16
  */
 public function getHeaderCellContent()
 {
     if (trim($this->headerTemplate) === '') {
         return $this->grid->blankDisplay;
     }
     if ($this->selectableRows === null && $this->grid->selectableRows > 1) {
         $item = CHtml::checkBox($this->id . '_all', false, array('class' => 'select-on-check-all'));
     } elseif ($this->selectableRows > 1) {
         $item = CHtml::checkBox($this->id . '_all', false);
     } else {
         $item = parent::getHeaderCellContent();
     }
     return strtr($this->headerTemplate, array('{item}' => $item));
 }
예제 #15
0
 /**
  * Renders the data cell content.
  * This method evaluates {@link dataExpression} or {@link dataField} and renders the result.
  * @param integer the row number (zero-based)
  * @param mixed the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->dataExpression !== null) {
         echo $this->evaluateExpression($this->dataExpression, array('data' => $data, 'row' => $row));
     } else {
         if ($this->dataField !== null) {
             $value = CHtml::value($data, $this->dataField);
             if ($this->encodeData === true) {
                 $value = CHtml::encode($value);
             }
             echo $value;
         } else {
             parent::renderDataCellContent($row, $data);
         }
     }
 }
예제 #16
0
 /**
  * Renders the header cell content.
  * This method will render a checkbox in the header when {@link selectableRows} is greater than 1
  * or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1.
  */
 protected function renderHeaderCellContent()
 {
     if ($this->selectableRows === null && $this->grid->selectableRows > 1) {
         echo CHtml::checkBox($this->id . '_all', false, array('class' => 'select-on-check-all'));
     } else {
         if ($this->selectableRows > 1) {
             echo CHtml::checkBox($this->id . '_all', false);
         } else {
             parent::renderHeaderCellContent();
         }
     }
 }
예제 #17
0
 protected function renderHeaderCellContent()
 {
     CGridColumn::renderHeaderCellContent();
 }