Exemplo n.º 1
0
 /**
  * Initializes the column.
  */
 public function init()
 {
     parent::init();
     if ($this->dataField === null) {
         $this->sortable = false;
     }
 }
 /**
  * Initializes the column.
  */
 public function init()
 {
     parent::init();
     if ($this->name === null && $this->value === null) {
         throw new CException(Yii::t('zii', 'Either "name" or "value" must be specified for CEditableColumn.'));
     }
 }
Exemplo n.º 3
0
 public function init()
 {
     parent::init();
     if ($this->name === null) {
         throw new CException(Yii::t('zii', '"name" must be specified for SelectColumn.'));
     }
 }
Exemplo n.º 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);
 }
 public function init()
 {
     parent::init();
     if ($this->pathPrefix === null) {
         $this->pathPrefix = Yii::app()->baseUrl . '/uploads/';
     }
     if ($this->name === null) {
         throw new CException(Yii::t('zii', 'Please specify a name for EImageColumn.'));
     }
 }
Exemplo n.º 6
0
 /**
  * @throws CException
  */
 public function init()
 {
     parent::init();
     if (empty($this->name)) {
         $this->sortable = false;
     }
     if (empty($this->onImageUrl)) {
         $this->onImageUrl = Yii::app()->request->baseUrl . '/core/images/admin/yes.png';
     }
     if (empty($this->offImageUrl)) {
         $this->offImageUrl = Yii::app()->request->baseUrl . '/core/images/admin/no.png';
     }
     if (empty($this->name) && empty($this->value)) {
         throw new CException('Either "name" or "value" must be specified for DToggleColumn.');
     }
     $this->registerClientScript();
 }
    public function init()
    {
        parent::init();
        $cs = Yii::app()->getClientScript();
        $gridId = $this->grid->getId();
        $script = <<<SCRIPT
\t\tjQuery(document).on("click", ".{$this->_flagClass}", function(e){
\t\t\te.preventDefault();
\t\t\tvar link = this;
\t\t\t\$.ajax({
\t\t\t\tdataType: "json",
\t\t\t\tcache: false,
\t\t\t\turl: link.href,
\t\t\t\tsuccess: function(data){
\t\t\t\t\t\$('#{$gridId}').yiiGridView.update('{$gridId}');
\t\t\t\t}
\t\t\t});
\t\t});
SCRIPT;
        $cs->registerScript(__CLASS__ . $gridId . '#flag_link', $script);
    }
Exemplo n.º 8
0
 public function init()
 {
     parent::init();
     $cs = Yii::app()->getClientScript();
     $gridId = $this->grid->getId();
     /*
     $script = <<<SCRIPT
     jQuery(document).on("click", ".{$this->_flagClass}", function(e) {e.preventDefault();
         var link = this;
         $.ajax({
             dataType: "json",
             cache: false,
             url: link.href,
             success: function(data){
                 $('#$gridId').yiiGridView.update('$gridId');
             }
         });
     });
     SCRIPT;
     $cs-> registerScript(__CLASS__.$gridId.'#flag_link', $script);
     */
 }
Exemplo n.º 9
0
    public function init()
    {
        parent::init();
        if ($this->icons) {
            $this->_assets = Yii::app()->assetManager->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
        }
        $cs = Yii::app()->getClientScript();
        $gridId = $this->grid->getId();
        $script = <<<SCRIPT
\t\tjQuery(".{$this->_flagClass}").live("click", function(e){
\t\t\te.preventDefault();
\t\t\tvar link = this;
\t\t\t\$.ajax({
\t\t\t\tdataType: "json",
\t\t\t\tcache: false,
\t\t\t\turl: link.href,
\t\t\t\tsuccess: function(data){
\t\t\t\t\t\$('#{$gridId}').yiiGridView.update('{$gridId}');
\t\t\t\t}
\t\t\t});
\t\t});
SCRIPT;
        $cs->registerScript(__CLASS__ . $gridId . '#flag_link', $script);
    }
Exemplo n.º 10
0
 public function init()
 {
     parent::init();
 }
Exemplo n.º 11
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);
            */
        }
    }
 /**
  * Init column
  * Publish necessary client script.
  */
 public function init()
 {
     parent::init();
     $this->publishReorderColumnAssets();
     $this->registerReorderColumnClientScript();
 }