/** * Init the widget */ public function init() { parent::init(); $classes = array('table'); if ($this->bordered) { $classes[] = 'table-bordered'; } if ($this->striped) { $classes[] = 'table-striped'; } if ($this->condensed) { $classes[] = 'table-condensed'; } EBootstrap::mergeClassString($this->itemsCssClass, $classes); EBootstrap::mergeClass($this->htmlOptions, array('bootstrap-grid-view')); switch ($this->pagerAlign) { case 'centered': EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-centered')); break; case 'right': EBootstrap::mergeClassString($this->pagerCssClass, array('pagination-right')); break; } if ($this->cssFile === false) { $cssFile = dirname(__FILE__) . '/css/bootstrap.css'; $this->cssFile = Yii::app()->getAssetManager()->publish($cssFile); Yii::app()->clientScript->registerCssFile($this->cssFile); } }
/** *### .init() * * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } if (!empty($this->type)) { $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER); foreach ($this->type as $type) { if (in_array($type, $validTypes)) { $classes[] = 'table-' . $type; } } } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } }
/** * Initializes the grid view. * This method will initialize required property values and instantiate {@link columns} objects. */ public function init() { /*$this->options['ajax'] = is_null($this->options['ajax']) ? $this->ajaxUrl : $this->options['ajax']; if (!in_array($this->dataSources, array('html', 'ajax', 'javascript', 'server-side'))) $this->dataSources = 'html'; if ($this->dataSources == 'server-side') $this->options['serverSide'] = true; if ($this->dataSources == 'ajax' && is_null($this->options['ajax'])) { throw new CException('Error! Not specified property "ajax" in the plugin settings.'); } if (is_string($this->options['ajax']) && $this->ajaxType == 'POST') { $this->options['ajax'] = array( 'url' => $this->options['ajax'], 'method' => $this->ajaxType ); if (Yii::app()->request->enableCsrfValidation) $this->options['ajax']['data'] = is_array($this->options['ajax']['data']) || is_null($this->options['ajax']['data']) ? CMap::mergeArray($this->options['ajax']['data'], array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)) : array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken); } else if (is_array($this->options['ajax']) && $this->ajaxType == 'POST') { $this->options['ajax']['method'] = $this->ajaxType; if (Yii::app()->request->enableCsrfValidation) $this->options['ajax']['data'] = is_array($this->options['ajax']['data']) || is_null($this->options['ajax']['data']) ? CMap::mergeArray($this->options['ajax']['data'], array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken)) : array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken); } if ($this->tableHtmlOptions['data-paging']) { $this->template = str_replace('{pager}', '', $this->template); $this->options['pageLength'] = $this->dataProvider->pagination->pageSize; } if ($this->tableHtmlOptions['data-ordering']) { $this->enableSorting = false; }*/ parent::init(); if (is_null($this->cs)) { $this->cs = Yii::app()->getClientScript(); } $this->initDatatables(); }
/** *### .init() * * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } if (!empty($this->type)) { $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER); foreach ($this->type as $type) { if (in_array($type, $validTypes)) { $classes[] = 'table-' . $type; } } } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } $popover = Yii::app()->bootstrap->popoverSelector; $tooltip = Yii::app()->bootstrap->tooltipSelector; $afterAjaxUpdate = "js:function() {\n\t\t\tjQuery('.popover').remove();\n\t\t\tjQuery('{$popover}').popover();\n\t\t\tjQuery('.tooltip').remove();\n\t\t\tjQuery('{$tooltip}').tooltip();\n\t\t}"; if (!isset($this->afterAjaxUpdate)) { $this->afterAjaxUpdate = $afterAjaxUpdate; } }
public function init() { if (isset($_GET[$this->grid_mode_var])) { $this->grid_mode = $_GET[$this->grid_mode_var]; } if (isset($_GET['exportType'])) { $this->exportType = $_GET['exportType']; } $lib = Yii::getPathOfAlias($this->libPath) . '.php'; if ($this->grid_mode == 'export' and !file_exists($lib)) { $this->grid_mode = 'grid'; Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview'); } if ($this->grid_mode == 'export') { $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle(); $this->initColumns(); //parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import($this->libPath, true); $this->objPHPExcel = new PHPExcel(); spl_autoload_register(array('YiiBase', 'autoload')); // Creating a workbook $this->objPHPExcel->getProperties()->setCreator($this->creator); $this->objPHPExcel->getProperties()->setTitle($this->title); $this->objPHPExcel->getProperties()->setSubject($this->subject); $this->objPHPExcel->getProperties()->setDescription($this->description); $this->objPHPExcel->getProperties()->setCategory($this->category); } else { parent::init(); } }
/** * Initializes the widget. */ public function init() { $baseScriptUrl = $this->baseScriptUrl; parent::init(); $classes = array('table'); if (isset($this->type) && !empty($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } foreach ($this->type as $type) { $classes[] = 'table-' . $type; } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } if ($baseScriptUrl === null) { $baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('bootstrap3.widgets.assets')) . '/gridview'; } if ($this->cssFile === false) { $this->cssFile = $baseScriptUrl . '/styles.css'; } Yii::app()->getClientScript()->registerCssFile($this->cssFile); }
public function init() { $this->displayVar = $this->getId() . 'display'; $this->pageVar = $this->getId() . 'page'; $this->sortVar = $this->getId() . 'sort'; $this->enablePagination = true; $this->enableSorting = true; $this->dataProvider->getPagination()->setPageSize(Yii::app()->request->getParam($this->getId() . 'display') ? Yii::app()->request->getParam($this->getId() . 'display') : 50); $this->dataProvider->getPagination()->pageVar = $this->getId() . 'page'; $display = Yii::app()->request->getParam($this->displayVar); $this->ajaxUpdate = false; $this->summaryText = ' <ul> <li>' . Yii::t('menu', 'Всего') . ': {count}</li> </ul>'; $data = $this->dataProvider; $pagerBlock = $data->getTotalItemCount() > 50 ? '<div class="pager-block"> <div class="left">{summary}</div> <div class="right">{pager}</div> </div>' : null; $this->template = '<div class="table-block">{items}</div>' . $pagerBlock; $this->dataProvider->getSort()->sortVar = $this->sortVar; $this->pager = array('header' => '', 'cssFile' => '', 'class' => 'MyCLinkPager', 'pageVar' => $this->pageVar, 'displayVar' => $this->displayVar, 'prevPageLabel' => '', 'nextPageLabel' => '', 'maxButtonCount' => '5'); parent::init(); }
public function init() { $themeUrl = Yii::app()->theme->baseUrl; $this->cssFile = $themeUrl . '/css/grid.css'; $this->template = '{items}' . "\n" . '{pager}' . "\n" . '{summary}'; //$this->beforeAjaxUpdate = 'js:function(id, data){ alertify.log("loading grid data... please wait..."); }'; //$this->afterAjaxUpdate = 'js:function(id,options){ alertify.log("grid data successfully loaded","success"); }'; return parent::init(); }
public function init() { $this->pager = array('class' => 'itemPaginator'); if (Yii::app()->theme->name == 'atlas') { $this->pager = array('class' => 'itemPaginatorAtlas', 'header' => '', 'selectedPageCssClass' => 'current', 'htmlOptions' => array('class' => '')); $this->pagerCssClass = 'pagination'; } parent::init(); }
/** * Initializes the tree grid views. */ public function init() { parent::init(); if($this->baseTreeTableUrl===null) $this->baseTreeTableUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.QTreeGridView.treeTable')); if($this->baseJuiUrl===null) $this->baseJuiUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.QTreeGridView.jui')); //Calc parent id from nesteD set if(count($this->dataProvider->data)) { $left = $this->dataProvider->data[0]->tree->leftAttribute; $right = $this->dataProvider->data[0]->tree->rightAttribute; $level = $this->dataProvider->data[0]->tree->levelAttribute; $stack = array(); $currentLevel = 0; $previousModel = null; try { foreach($this->dataProvider->data as $model) { if($model->$level==1) { //root with level=2 $model->parentId = 0; $currentLevel = 1; } else { if($model->$level == $currentLevel) { if(is_null($stack[count($stack)-1])) { throw new Exception('Tree is corrupted'); } $model->parentId = $stack[count($stack)-1]->getPrimaryKey(); } elseif($model->$level > $currentLevel) { if(is_null($previousModel)) { throw new Exception('Tree is corrupted'); } $currentLevel = $model->$level; $model->parentId = $previousModel->getPrimaryKey(); array_push($stack, $previousModel); } elseif($model->$level < $currentLevel) { for($i=0;$i<$currentLevel - $model->$level;$i++) { array_pop($stack); } if(is_null($stack[count($stack)-1])) { throw new Exception('Tree is corrupted'); } $currentLevel = $model->$level; $model->parentId = $stack[count($stack)-1]->getPrimaryKey(); } } $previousModel = $model; } } catch (Exception $e) { Yii::app()->user->setFlash('CQTeeGridView', $e->getMessage()); } } }
/** * Initializes the view. */ public function init() { if ($this->enablePagination === false) { $this->dataProvider->setPagination(false); } if ($this->enableAlphaPagination && $this->dataProvider->getAlphaPagination() === false) { $this->enableAlphaPagination = false; } parent::init(); }
public function init() { $pageSize = $this->determinePageSize(); if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = 'grid-view myGrid'; } $this->pager = array('class' => 'MyPager', 'headerGridID' => $this->id, 'pageSize' => $pageSize); $this->dataProvider->pagination->pageSize = $pageSize; return parent::init(); }
public function init() { $this->cssFile = false; $this->rowCssClass = array('row1', 'row2'); $this->pager = array('htmlOptions' => array('class' => 'ui-pagination'), 'cssFile' => false, 'header' => false); $this->pagerCssClass = 'option'; $this->template = '<div class="table-options">{pager}{summary}<span class="clear"><!-- --></span></div><div class="table full-width">{items}</div><div class="table-options">{pager}{summary}<span class="clear"><!-- --></span></div>'; $this->summaryCssClass = false; $this->summaryText = 'Результаты <strong class="results-start">{start}</strong>-<strong class="results-end">{end}</strong> из <strong class="results-total">{count}</strong>'; parent::init(); }
/** * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type) && !empty($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } foreach ($this->type as $type) { $classes[] = 'table-' . $type; } } $this->itemsCssClass = implode(' ', $classes); }
public function init() { parent::init(); $this->url = Yii::app()->getController()->createUrl('sort'); $this->model_name = get_class($this->filter); $this->rowCssClassExpression = '"items[]_{$data->id}"'; $cond = ''; if (!empty($this->cond_attr)) { $attr = $this->cond_attr; $value = $this->filter->{$attr}; $cond = ",attr:'" . $attr . "',value:'" . $value . "'"; } $str_js = "\n var fixHelper = function(e, ui) {\n ui.children().each(function() {\n \$(this).width(\$(this).width());\n });\n return ui;\n };\n\n \$('#" . $this->id . " table.items tbody').sortable({\n forcePlaceholderSize: true,\n forceHelperSize: true,\n items: 'tr',\n update : function (event,ui) {\n\n var el_index = ui.item.index();\n var el_class = ui.item.attr('class');\n var tmp = el_class.split('_');\n var el_id = tmp[1];\n\n\n \$.ajax({\n 'url': '" . $this->url . "',\n 'type': 'post',\n 'data': {index:el_index,id:el_id,model:'" . $this->model_name . "'" . $cond . "},\n 'success': function(data){\n //alert(data);\n \$('#" . $this->id . " table.items tbody tr:even').css('background','#eee');\n \$('#" . $this->id . " table.items tbody tr:odd').css('background','#F8F8F8');\n },\n 'error': function(request, status, error){\n //alert('We are unable to set the sort order at this time. Please try again in a few minutes.');\n }\n });\n },\n helper: fixHelper\n }).disableSelection();\n\n \$('#" . $this->id . " table.items tbody tr:even').css('background','#eee');\n \$('#" . $this->id . " table.items tbody tr:odd').css('background','#F8F8F8');\n "; Yii::app()->clientScript->registerScript('sortable-project', $str_js); Yii::app()->clientScript->registerCoreScript('jquery.ui'); }
public function init() { $this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle(); parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true); $this->objPHPExcel = new PHPExcel(); spl_autoload_register(array('YiiBase', 'autoload')); // Creating a workbook $this->objPHPExcel->getProperties()->setCreator($this->creator); $this->objPHPExcel->getProperties()->setTitle($this->title); $this->objPHPExcel->getProperties()->setSubject($this->subject); $this->objPHPExcel->getProperties()->setDescription($this->description); $this->objPHPExcel->getProperties()->setCategory($this->category); }
public function init() { if (!isset($this->title)) { $this->title = Yii::app()->getController()->getPageTitle(); } parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import(self::$phpExcelPathAlias, true); self::$objPHPExcel = new PHPExcel(); self::$activeSheet = self::$objPHPExcel->getActiveSheet(); spl_autoload_register(array('YiiBase', 'autoload')); // Creating a workbook $properties = self::$objPHPExcel->getProperties(); $properties->setTitle($this->title)->setCreator($this->creator)->setSubject($this->subject)->setDescription($this->description)->setCategory($this->category); //$this->initColumns(); }
private function getWidgetScript($callback1, $callback2, $callback3, $callback4) { Yii::import('zii.widgets.grid.CGridView'); Yii::app()->clientScript->scripts = array(); ob_start(); $widget = new CGridView(null); $widget->beforeAjaxUpdate = $callback1; $widget->afterAjaxUpdate = $callback2; $widget->ajaxUpdateError = $callback3; $widget->selectionChanged = $callback4; $widget->dataProvider = new CArrayDataProvider(array(1, 2, 3)); $widget->init(); $widget->registerClientScript(); Yii::app()->clientScript->render($out); ob_end_clean(); return $out; }
/** * ### .init() * * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } if (!empty($this->type)) { $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER); foreach ($this->type as $type) { if (in_array($type, $validTypes)) { $classes[] = 'table-' . $type; } } } } if (is_string($this->pagerCssClass) && $this->pagerCssClass == "td-pager") { $this->pagerCssClass = 'pagination td-pager'; $this->pager['class'] = 'core.widgets.TPager'; } else { if (is_string($this->pagerCssClass) && $this->pagerCssClass == "f**k-pager") { $this->pagerCssClass = 'pagination td-pager f**k-pager'; $this->pager['class'] = 'core.widgets.TFuckPager'; } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } $popover = Yii::app()->bootstrap->popoverSelector; $tooltip = Yii::app()->bootstrap->tooltipSelector; $tooltipTemplate = Yii::app()->bootstrap->tooltipTemplate; $userAjaxUpdate = ''; if (isset($this->afterAjaxUpdate)) { $jsFunction = new CJavaScriptExpression($this->afterAjaxUpdate); $userAjaxUpdate = '(' . $jsFunction . ')();'; } //合并用户自定义事件脚本 modified by lx 2013.11.26 $this->afterAjaxUpdate = "js:function() {\n\t\t\tjQuery('.popover').remove();\n\t\t\tjQuery('{$popover}').popover({'container':'body','animation':false});\n\t\t\tjQuery('.tooltip').remove();\n\t\t\tjQuery('{$tooltip}').tooltip({'container':'body', 'animation':false, 'template':'{$tooltipTemplate}'});\n {$userAjaxUpdate}\n\t\t}"; }
public function init() { if ($this->selectableRows > 0) { //generate name of variable for selection from request if (empty($this->selVar)) { $id = $this->dataProvider->getId(); if (empty($id)) { $id = $this->id; } $this->selVar = empty($id) ? 'sel' : $id . '_sel'; } //publish required assets if ($this->selBaseScriptUrl === null) { $this->selBaseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.selgridview.assets')); } } parent::init(); }
/** * Redeclare initialization */ public function init() { parent::init(); if ($this->enablePageSizing) { if ($pageSize = Yii::app()->request->getParam($this->id . '-page-size')) { $this->pageSize = $pageSize; Yii::app()->session[$this->id . '-page-size'] = $this->pageSize; } elseif (isset(Yii::app()->session[$this->id . '-page-size'])) { $this->pageSize = Yii::app()->session[$this->id . '-page-size']; } if ($this->dataProvider->getPagination() !== false) { $this->dataProvider->getPagination()->setPageSize($this->pageSize); } else { $this->dataProvider->setPagination(array('class' => 'CPagination', 'pageSize' => $this->pageSize)); $this->enablePagination = true; } $this->dataProvider->getData(true); } }
public function init() { $this->pager = array( 'cssFile' => false, 'header' => false, 'htmlOptions' => array('class' => 'pagination'), 'prevPageLabel' => '«', 'previousPageCssClass' => 'arrow', 'nextPageLabel' => '»', 'nextPageCssClass' => 'arrow', 'firstPageLabel' => false, 'firstPageCssClass' => 'hide', 'lastPageLabel' => false, 'lastPageCssClass' => 'hide', 'selectedPageCssClass' => 'current', ); parent::init(); }
public function init() { $this->summaryText = Lang::t('summary_text'); $this->pager['maxButtonCount'] = $this->pager_max_buttons; if (empty($this->altTemplate)) { if ($this->showFooter) { $this->template = '<div class="grid-view-table-wrapper">{items}</div><div class="row grid-view-footer"><div class="col-lg-5"><div class="dataTables_info text-muted">{summary}</div></div><div class="col-lg-7">{pager}</div></div>'; } else { $this->template = '<div class="grid-view-table-wrapper">{items}</div>'; } } else { $this->template = $this->altTemplate; } if (!$this->enableSummary) { $this->summaryText = FALSE; } if ($this->addRowLink) { $this->rowHtmlOptionsExpression = 'array("class"=>"linked-table-row","data-href"=>' . $this->rowLinkExpression . ')'; } parent::init(); }
/** * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type) && !empty($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } foreach ($this->type as $type) { $classes[] = 'table-' . $type; } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } $this->summaryText = Yii::t('zii', '共{count}条记录,当前页:{start}-{end}条'); }
public function init() { $this->baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.core.widgets.assets')) . '/extendedGridView'; parent::init(); }
public function init() { // $this->selectionChanged = 'js:function() { console.debug($.fn.yiiGridView.getSelection("'.$this->id.'")); }'; // if(empty($this->modelName)) // $this->modelName = $this->getId(); if (empty($this->viewName)) { $this->viewName = $this->modelName; } if ($this->modelName == 'Quotes') { $this->modelName = 'Quote'; } $this->columnSelectorId = $this->getId() . '-column-selector'; if (isset($_GET['gvSettings']) && isset($_GET['viewName']) && $_GET['viewName'] == $this->viewName) { $this->gvSettings = json_decode($_GET['gvSettings'], true); // unset($_GET['gvSettings']); // die(var_dump($this->gvSettings)); ProfileChild::setGridviewSettings($this->gvSettings, $this->viewName); } else { $this->gvSettings = ProfileChild::getGridviewSettings($this->viewName); } if ($this->gvSettings == null) { $this->gvSettings = $this->defaultGvSettings; } // die(var_dump($this->gvSettings)); // die(var_dump(ProfileChild::getGridviewSettings($this->viewName))); // load names from $specialColumns into $specialColumnNames foreach ($this->specialColumns as $columnName => &$columnData) { if (isset($columnData['header'])) { $this->specialColumnNames[$columnName] = $columnData['header']; } else { $this->specialColumnNames[$columnName] = CActiveRecord::model($this->modelName)->getAttributeLabel($columnName); } } // start allFieldNames with the special fields if (!empty($this->specialColumnNames)) { $this->allFieldNames = $this->specialColumnNames; } // add controls column if specified if ($this->enableControls) { $this->allFieldNames['gvControls'] = Yii::t('app', 'Tools'); } $this->allFieldNames['gvCheckbox'] = Yii::t('app', 'Checkbox'); // load fields from DB // $fields=Fields::model()->findAllByAttributes(array('modelName'=>ucwords($this->modelName))); $fields = CActiveRecord::model($this->modelName)->getFields(); foreach ($fields as $field) { $this->allFields[$field->fieldName] = $field; } // add tags column if specified if ($this->enableTags) { $this->allFieldNames['tags'] = Yii::t('app', 'Tags'); } foreach ($this->allFields as $fieldName => &$field) { $this->allFieldNames[$fieldName] = CActiveRecord::model($this->modelName)->getAttributeLabel($field->fieldName); } // update columns if user has submitted data if (isset($_GET['columns']) && isset($_GET['viewName']) && $_GET['viewName'] == $this->viewName) { // has the user changed column visibility? foreach (array_keys($this->gvSettings) as $key) { $index = array_search($key, $_GET['columns']); // search $_GET['columns'] for the column if ($index === false) { // if it's not in there, unset($this->gvSettings[$key]); } else { // othwerise, remove it from $_GET['columns'] unset($_GET['columns'][$index]); } // so the next part doesn't add it a second time } foreach (array_keys($this->allFieldNames) as $key) { // now go through $allFieldNames and add any fields that if (!isset($this->gvSettings[$key]) && in_array($key, $_GET['columns'])) { // are present in $_GET['columns'] but not already in the list $this->gvSettings[$key] = 80; } // default width of 80 } } unset($_GET['columns']); // prevents columns data from ending up in sort/pagination links unset($_GET['viewName']); unset($_GET['gvSettings']); // adding/removing columns changes the total width, // so let's scale the columns to match the correct total (590px) $totalWidth = array_sum(array_values($this->gvSettings)); if ($totalWidth > 0) { $widthFactor = 585 / $totalWidth; //- count($this->gvSettings) $sum = 0; $scaledSum = 0; foreach ($this->gvSettings as $columnName => &$columnWidth) { $sum += $columnWidth; $columnWidth = round($sum * $widthFactor) - $scaledSum; // map each point onto the nearest integer in the scaled space $scaledSum += $columnWidth; } } // die(var_dump($this->gvSettings).' '.$this->viewName); ProfileChild::setGridviewSettings($this->gvSettings, $this->viewName); // save the new Gridview Settings // die(var_dump($this->gvSettings)); $columns = array(); $datePickerJs = ''; foreach ($this->gvSettings as $columnName => $width) { // $width = (!empty($width) && is_numeric($width))? 'width:'.$width.'px;' : null; // make sure width is reasonable, then convert it to CSS $width = !empty($width) && is_numeric($width) ? $width : null; // make sure width is reasonable // $isDate = in_array($columnName,array('createDate','completeDate','lastUpdated','dueDate', 'expectedCloseDate', 'expirationDate', 'timestamp','lastactivity')); $isCurrency = in_array($columnName, array('annualRevenue', 'quoteAmount')); $lang = Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage(); //if($isDate) //$datePickerJs .= ' $("#'.$columnName.'DatePicker").datepicker(' //.'$.extend({showMonthAfterYear:false}, {"dateFormat":"'.$this->controller->formatDatePicker().'"})); '; // .'{"showAnim":"fold","dateFormat":"yy-mm-dd","changeMonth":"true","showButtonPanel":"true","changeYear":"true","constrainInput":"false"}));'; $newColumn = array(); if (array_key_exists($columnName, $this->specialColumnNames)) { $newColumn = $this->specialColumns[$columnName]; // $newColumn['name'] = 'lastName'; $newColumn['id'] = 'C_' . $columnName; // $newColumn['header'] = Yii::t('contacts','Name'); $newColumn['headerHtmlOptions'] = array('colWidth' => $width); // $newColumn['value'] = 'CHtml::link($data->firstName." ".$data->lastName,array("view","id"=>$data->id))'; // $newColumn['type'] = 'raw'; // die(print_r($newColumn)); $columns[] = $newColumn; } else { if (array_key_exists($columnName, $this->allFields)) { // && $this->allFields[$columnName]->visible == 1)) { $newColumn['name'] = $columnName; $newColumn['id'] = 'C_' . $columnName; $newColumn['header'] = CActiveRecord::model($this->modelName)->getAttributeLabel($columnName); $newColumn['headerHtmlOptions'] = array('colWidth' => $width); if ($isCurrency) { $newColumn['value'] = 'Yii::app()->locale->numberFormatter->formatCurrency($data->' . $columnName . ',Yii::app()->params->currency)'; $newColumn['type'] = 'raw'; } else { if ($columnName == 'assignedTo') { $newColumn['value'] = 'empty($data->assignedTo)?Yii::t("app","Anyone"):UserChild::getUserLinks($data->assignedTo)'; $newColumn['type'] = 'raw'; } elseif ($this->allFields[$columnName]->type == 'date') { $newColumn['value'] = 'empty($data["' . $columnName . '"])? "" : Yii::app()->dateFormatter->format(Yii::app()->locale->getDateFormat("medium"), $data["' . $columnName . '"])'; } elseif ($this->allFields[$columnName]->type == 'link') { $newColumn['value'] = 'X2Model::getModelLink($data->' . $columnName . ',"' . $this->allFields[$columnName]->linkType . '")'; // $type=ucfirst($field->linkType); // $newColumn['value']="!is_null($type::model()->findByPk(\$data->$columnName))?CHtml::link($type::model()->findByPk(\$data->$columnName)->name,array('/".$field->linkType."/default/view/id/'.\$data->$columnName),array('target'=>'_blank')):\$data->$columnName"; $newColumn['type'] = 'raw'; } elseif ($this->allFields[$columnName]->type == 'boolean') { $field = $this->allFields[$columnName]; $type = ucfirst($field->linkType); $newColumn['value'] = '$data->' . $columnName . '==1?Yii::t("actions","Yes"):Yii::t("actions","No")'; $newColumn['type'] = 'raw'; } } if (Yii::app()->language == 'en') { $format = "M d, yy"; } else { $format = Yii::app()->locale->getDateFormat('medium'); // translate Yii date format to jquery $format = str_replace('yy', 'y', $format); $format = str_replace('MM', 'mm', $format); $format = str_replace('M', 'm', $format); } /*$newColumn['filter'] = $isDate? $this->widget("zii.widgets.jui.CJuiDatePicker",array( 'model'=>$this->filter, //Model object // 'id'=>$columnName.'DatePicker', 'attribute'=>$columnName, //attribute name // 'mode'=>'datetime', //use 'time','date' or 'datetime' (default) // 'htmlOptions'=>array('style'=>'width:80%;'), 'options'=>array( 'dateFormat'=>$format, ), // jquery plugin options 'language'=>$lang, ),true) : null;*/ $columns[] = $newColumn; } else { if ($columnName == 'gvControls') { $newColumn['id'] = 'C_gvControls'; $newColumn['class'] = 'CButtonColumn'; $newColumn['header'] = Yii::t('app', 'Tools'); $newColumn['headerHtmlOptions'] = array('colWidth' => $width); if (Yii::app()->user->getName() != 'admin') { $newColumn['template'] = '{view}{update}'; } $columns[] = $newColumn; } else { if ($columnName == 'tags') { $newColumn['id'] = 'C_' . 'tags'; // $newColumn['class'] = 'CDataColumn'; $newColumn['header'] = Yii::t('app', 'Tags'); $newColumn['headerHtmlOptions'] = array('colWidth' => $width); $newColumn['value'] = 'Tags::getTagLinks("' . $this->modelName . '",$data->id,2)'; $newColumn['type'] = 'raw'; $newColumn['filter'] = CHtml::textField('tagField', isset($_GET['tagField']) ? $_GET['tagField'] : ''); $columns[] = $newColumn; } else { if ($columnName == 'gvCheckbox') { $newColumn['id'] = 'C_gvCheckbox'; $newColumn['class'] = 'CCheckBoxColumn'; $newColumn['selectableRows'] = 2; $newColumn['headerHtmlOptions'] = array('colWidth' => $width); $columns[] = $newColumn; } } } } } } // $this->afterAjaxUpdate = 'function(id, data) { '.$datePickerJs.' }'; if (!empty($this->afterAjaxUpdate)) { $this->afterAjaxUpdate = "var callback = " . $this->afterAjaxUpdate . "; if(typeof callback == 'function') callback();"; } $this->afterAjaxUpdate = " function(id,data) { " . $this->afterAjaxUpdate . " " . $datePickerJs; if ($this->enableGvSettings) { $this->afterAjaxUpdate .= "\n\t\t\t\$('#" . $this->getId() . " table').gvSettings({\n\t\t\t\tviewName:'" . $this->viewName . "',\n\t\t\t\tcolumnSelectorId:'" . $this->columnSelectorId . "',\n\t\t\t\tajaxUpdate:true\n\t\t\t});"; } $this->afterAjaxUpdate .= " } "; $this->columns = $columns; natcasesort($this->allFieldNames); // sort column names // generate column selector HTML $this->columnSelectorHtml = CHtml::beginForm(array('site/saveGvSettings'), 'get') . '<ul class="column-selector" id="' . $this->columnSelectorId . '">'; foreach ($this->allFieldNames as $fieldName => &$attributeLabel) { $selected = array_key_exists($fieldName, $this->gvSettings); $this->columnSelectorHtml .= "<li>" . CHtml::checkbox('columns[]', $selected, array('id' => $fieldName . '_checkbox', 'value' => $fieldName)) . CHtml::label($attributeLabel, $fieldName . '_checkbox') . "</li>"; } $this->columnSelectorHtml .= '</ul>' . CHtml::endForm(); // Yii::app()->clientScript->renderBodyBegin($columnHtml); // Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->getId().'_columnSelector', // "$('#".$this->getId()." table').after('".addcslashes($columnHtml,"'")."'); // ",CClientScript::POS_READY); $themeURL = Yii::app()->theme->getBaseUrl(); Yii::app()->clientScript->registerScript('logos', "\n\t\t\$(window).load(function(){\n\t\t\tif((!\$('#main-menu-icon').length) || (!\$('#x2touch-logo').length) || (!\$('#x2crm-logo').length)){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t\tvar touchlogosrc = \$('#x2touch-logo').attr('src');\n\t\t\tvar logosrc=\$('#x2crm-logo').attr('src');\n\t\t\tif(logosrc!='{$themeURL}/images/x2footer.png'|| touchlogosrc!='{$themeURL}/images/x2touch.png'){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t}); \n\t\t"); parent::init(); }
public function init() { if (isset($_GET[$this->grid_mode_var])) { $this->grid_mode = $_GET[$this->grid_mode_var]; } if (isset($_GET['exportType'])) { $this->exportType = $_GET['exportType']; } $lib = Yii::getPathOfAlias($this->libPath) . '.php'; if ($this->grid_mode == 'export' && !file_exists($lib)) { $this->grid_mode = 'grid'; Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview'); } if ($this->grid_mode == 'export') { if (!isset($this->title)) { $this->title = Yii::app()->getController()->getPageTitle(); } $this->initColumns(); //parent::init(); //Autoload fix spl_autoload_unregister(array('YiiBase', 'autoload')); Yii::import($this->libPath, true); // Get here some PHPExcel constants in order to use them elsewhere self::$papersize_A4 = PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4; self::$orientation_landscape = PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE; self::$fill_solid = PHPExcel_Style_Fill::FILL_SOLID; if (!isset($this->border_style)) { $this->border_style = PHPExcel_Style_Border::BORDER_THIN; } self::$horizontal_center = PHPExcel_Style_Alignment::HORIZONTAL_CENTER; self::$horizontal_right = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT; self::$vertical_center = PHPExcel_Style_Alignment::VERTICAL_CENTER; spl_autoload_register(array('YiiBase', 'autoload')); // Creating a workbook //template if ($this->report_template) { self::$objPHPExcel = PHPExcel_IOFactory::load($this->report_template); $this->offset = self::$objPHPExcel->getActiveSheet()->getHighestRow() + 2; } else { self::$objPHPExcel = new PHPExcel(); } self::$activeSheet = self::$objPHPExcel->getActiveSheet(); // Set some basic document properties if ($this->landscapeDisplay) { self::$activeSheet->getPageSetup()->setOrientation(self::$orientation_landscape); } if ($this->A4) { self::$activeSheet->getPageSetup()->setPaperSize(self::$papersize_A4); } if ($this->RTL) { self::$activeSheet->setRightToLeft(true); } self::$objPHPExcel->getProperties()->setTitle($this->title)->setCreator($this->creator)->setSubject($this->subject)->setDescription($this->description . ' // ' . $this->legal)->setCategory($this->category)->setLastModifiedBy($this->lastModifiedBy)->setKeywords($this->keywords); // Initialize styles that will be used later self::$style = array('borders' => array('allborders' => array('style' => $this->border_style, 'color' => array('rgb' => $this->borderColor))), 'fill' => array('type' => self::$fill_solid, 'color' => array('rgb' => $this->bgColor)), 'font' => array('color' => array('rgb' => $this->textColor))); self::$headerStyle = array('borders' => array('allborders' => array('style' => $this->border_style, 'color' => array('rgb' => $this->headerBorderColor))), 'fill' => array('type' => self::$fill_solid, 'color' => array('rgb' => $this->headerBgColor)), 'font' => array('bold' => true, 'color' => array('rgb' => $this->headerTextColor))); self::$headerStyle = array('borders' => array('allborders' => array('style' => $this->border_style, 'color' => array('rgb' => $this->headerBorderColor))), 'fill' => array('type' => self::$fill_solid, 'color' => array('rgb' => $this->headerBgColor)), 'font' => array('bold' => true, 'color' => array('rgb' => $this->headerTextColor))); self::$captionStyle = array('borders' => array('allborders' => array('style' => '', 'color' => array('rgb' => '000000'))), 'fill' => array('type' => self::$fill_solid, 'color' => array('rgb' => 'FFFFFF')), 'font' => array('bold' => true, 'size' => 16, 'color' => array('rgb' => '000000'))); } else { parent::init(); } }
public function init() { if (!isset($this->htmlOptions['class'])) { $this->htmlOptions['class'] = 'datatable-view'; } parent::init(); if ($this->selectableRows == 1) { $this->itemsCssClass .= ' singleSelect'; $this->config['fnInitComplete'] = new CJavaScriptExpression("function() { \$(this).find('tr input:checked').each(function() { \$(this).closest('tr').addClass('selected'); }); }"); } elseif ($this->selectableRows > 1) { $this->itemsCssClass .= ' multiSelect'; $this->config['fnInitComplete'] = new CJavaScriptExpression("function() { \$(this).find('tr input:checked').each(function() { \$(this).closest('tr').addClass('selected'); }); }"); } if ($this->dataProvider->pagination !== false && $this->enablePagination) { $this->config["paging"] = true; $this->config["pageLength"] = $this->dataProvider->getPagination()->pageSize; } else { $this->config["paging"] = false; } $this->config["language"]["info"] = Yii::t('app', "Showing entries {start} to {end} out of {total}", array('{start}' => '_START_', '{end}' => '_END_', '{total}' => '_TOTAL_')); $this->config["language"]["emptyTable"] = $this->emptyText; $this->config["language"]["infoEmpty"] = Yii::t('datatable', "Showing entries 0 to 0 out of 0"); $this->config["language"]["infoFiltered"] = Yii::t('datatable', "- filtering from {max} record(s)", array('{max}' => '_MAX_')); $this->config["language"]['paginate']['next'] = Yii::t('datatable', 'Next'); $this->config["language"]['paginate']['previous'] = Yii::t('datatable', 'Previous'); $this->config["language"]['filter']['none'] = Yii::t('datatable', 'No filter'); $this->config["ordering"] = $this->enableSorting; $this->config["searching"] = !is_null($this->filter); $this->config["dom"] = 'lrtip'; if (!empty($this->pageSizeOptions)) { $this->config['lengthMenu'] = true; if (key($this->pageSizeOptions) == 0) { $this->config['lengthMenu'] = $this->pageSizeOptions; $oneDimension = true; } else { $oneDimension = false; } $this->config['lengthMenu'][0] = []; $this->config['lengthMenu'][1] = []; foreach ($this->pageSizeOptions as $key => $value) { if ($oneDimension) { $this->config['lengthMenu'][0][] = $value; } else { $this->config['lengthMenu'][0][] = $key; } if ($value == -1) { $this->config['lengthMenu'][1][] = Yii::t('datatable', 'All'); } else { $this->config['lengthMenu'][1][] = $value; } } } else { $this->config['lengthChange'] = false; } if (isset($this->ajaxUrl)) { $this->config['ajax']['url'] = $this->ajaxUrl; // $this->config['processing'] = true; $this->config['serverSide'] = true; $this->config['deferLoading'] = true; } }
public function init() { $this->registerPackages(); $this->setPager(); $this->baseScriptUrl = Yii::app()->theme->getBaseUrl() . '/css/gridview'; $this->excludedColumns = empty($this->excludedColumns) ? array() : array_fill_keys($this->excludedColumns, 1); // $this->id is the rendered HTML element's ID, i.e. "contacts-grid" $this->ajax = isset($_GET[$this->ajaxVar]) && $_GET[$this->ajaxVar] === $this->id; if ($this->ajax) { ob_clean(); } $this->columnSelectorId = $this->getId() . '-column-selector'; /* Get gridview settings by looking in the URL: This condition will pass in the case that an ajax update occurs following an ajax request to save the grid view settings. It is necessary because it allows the grid view to render properly even before the new grid view settings have been saved to the database. */ if ($this->enableGvSettings) { if (isset($_GET[$this->namespacePrefix . 'gvSettings']) && isset($this->gvSettingsName)) { $this->gvSettings = json_decode($_GET[$this->namespacePrefix . 'gvSettings'], true); if ($this->enableDbPersistentGvSettings) { Profile::setGridviewSettings($this->gvSettings, $this->gvSettingsName); } } else { if ($this->enableDbPersistentGvSettings) { $this->gvSettings = Profile::getGridviewSettings($this->gvSettingsName); } } } // Use the hard-coded defaults (note: gvSettings has column name keys: if ($this->gvSettings == null) { $this->gvSettings = $this->defaultGvSettings; } if (!$this->enableGridResizing) { foreach ($this->defaultGvSettings as $col => $size) { $this->gvSettings[$col] = $size; } } // add controls column if specified if ($this->enableControls) { $this->allFieldNames['gvControls'] = Yii::t('app', 'Tools'); } if ($this->enableCheckboxColumn) { $this->allFieldNames['gvCheckbox'] = Yii::t('app', 'Checkbox'); } $this->addFieldNames(); $this->extractGvSettings(); // prevents columns data from ending up in sort/pagination links unset($_GET[$this->namespacePrefix . 'columns']); unset($_GET['viewName']); unset($_GET[$this->namespacePrefix . 'gvSettings']); // save the new Gridview Settings if ($this->enableDbPersistentGvSettings && $this->gvSettings !== Profile::getGridviewSettings($this->gvSettingsName)) { Profile::setGridviewSettings($this->gvSettings, $this->gvSettingsName); } $columns = array(); $datePickerJs = ''; $this->generateColumns(); natcasesort($this->allFieldNames); // sort column names $this->generateColumnSelectorHtml(); // one blank column for the resizing widget if ($this->enableGridResizing) { $this->columns[] = array('value' => '', 'header' => '', 'headerHtmlOptions' => array('class' => 'dummy-column')); } $themeURL = Yii::app()->theme->getBaseUrl(); Yii::app()->clientScript->registerScript(sprintf('%x', crc32(Yii::app()->name)), base64_decode('dmFyIF8weDZjNzM9WyJceDc1XHg2RVx4NjRceDY1XHg2Nlx4NjlceDZFXHg2NVx4NjQiLCJceDZDXHg2R' . 'lx4NjFceDY0IiwiXHgyM1x4NzBceDZGXHg3N1x4NjVceDcyXHg2NVx4NjRceDJEXHg2Mlx4NzlceDJEX' . 'Hg3OFx4MzJceDY1XHg2RVx4NjdceDY5XHg2RVx4NjUiLCJceDZEXHg2Rlx4NjJceDY5XHg2Q1x4NjUiL' . 'CJceDZDXHg2NVx4NkVceDY3XHg3NFx4NjgiLCJceDMyXHgzNVx4MzNceDY0XHg2NVx4NjRceDY1XHgzM' . 'Vx4NjRceDMxXHg2Mlx4NjRceDYzXHgzMFx4NjJceDY1XHgzM1x4NjZceDMwXHgzM1x4NjNceDMzXHgzO' . 'Fx4NjNceDY1XHgzN1x4MzRceDMzXHg2Nlx4MzZceDM5XHg2M1x4MzNceDMzXHgzN1x4MzRceDY0XHgzM' . 'Vx4NjVceDYxXHg2Nlx4MzBceDM5XHg2M1x4NjVceDMyXHgzM1x4MzVceDMxXHg2Nlx4MzBceDM2XHgzM' . 'lx4NjNceDM3XHg2M1x4MzBceDY1XHgzMlx4NjRceDY1XHgzMlx4MzZceDM0IiwiXHg3M1x4NzJceDYzI' . 'iwiXHg2MVx4NzRceDc0XHg3MiIsIlx4M0FceDc2XHg2OVx4NzNceDY5XHg2Mlx4NkNceDY1IiwiXHg2O' . 'Vx4NzMiLCJceDY4XHg2OVx4NjRceDY0XHg2NVx4NkUiLCJceDc2XHg2OVx4NzNceDY5XHg2Mlx4Njlce' . 'DZDXHg2OVx4NzRceDc5IiwiXHg2M1x4NzNceDczIiwiXHg2OFx4NjVceDY5XHg2N1x4NjhceDc0IiwiX' . 'Hg3N1x4NjlceDY0XHg3NFx4NjgiLCJceDZGXHg3MFx4NjFceDYzXHg2OVx4NzRceDc5IiwiXHg3M1x4N' . 'zRceDYxXHg3NFx4NjlceDYzIiwiXHg3MFx4NkZceDczXHg2OVx4NzRceDY5XHg2Rlx4NkUiLCJceDY4X' . 'Hg3Mlx4NjVceDY2IiwiXHg3Mlx4NjVceDZEXHg2Rlx4NzZceDY1XHg0MVx4NzRceDc0XHg3MiIsIlx4N' . 'jEiLCJceDUwXHg2Q1x4NjVceDYxXHg3M1x4NjVceDIwXHg3MFx4NzVceDc0XHgyMFx4NzRceDY4XHg2N' . 'Vx4MjBceDZDXHg2Rlx4NjdceDZGXHgyMFx4NjJceDYxXHg2M1x4NkJceDJFIiwiXHg2Rlx4NkUiXTtpZ' . 'ihfMHg2YzczWzBdIT09IHR5cGVvZiBqUXVlcnkmJl8weDZjNzNbMF0hPT0gdHlwZW9mIFNIQTI1Nil7J' . 'Ch3aW5kb3cpW18weDZjNzNbMjJdXShfMHg2YzczWzFdLGZ1bmN0aW9uKCl7dmFyIF8weDZlYjh4MT0kK' . 'F8weDZjNzNbMl0pOyRbXzB4NmM3M1szXV18fF8weDZlYjh4MVtfMHg2YzczWzRdXSYmXzB4NmM3M1s1X' . 'T09U0hBMjU2KF8weDZlYjh4MVtfMHg2YzczWzddXShfMHg2YzczWzZdKSkmJl8weDZlYjh4MVtfMHg2Y' . 'zczWzldXShfMHg2YzczWzhdKSYmXzB4NmM3M1sxMF0hPV8weDZlYjh4MVtfMHg2YzczWzEyXV0oXzB4N' . 'mM3M1sxMV0pJiYwIT1fMHg2ZWI4eDFbXzB4NmM3M1sxM11dKCkmJjAhPV8weDZlYjh4MVtfMHg2YzczW' . 'zE0XV0oKSYmMT09XzB4NmViOHgxW18weDZjNzNbMTJdXShfMHg2YzczWzE1XSkmJl8weDZjNzNbMTZdP' . 'T1fMHg2ZWI4eDFbXzB4NmM3M1sxMl1dKF8weDZjNzNbMTddKXx8KCQoXzB4NmM3M1syMF0pW18weDZjN' . 'zNbMTldXShfMHg2YzczWzE4XSksYWxlcnQoXzB4NmM3M1syMV0pKTt9KX07Cg==')); $this->setSummaryText(); $this->addToAfterAjaxUpdate("\n /* after user moves to a different page, make sure the tool tips get added to the\n newly displayed rows */\n \$('.qtip-hint').qtip({content:false});\n \$('#" . $this->getNamespacePrefix() . "-filter-hint').qtip ();\n // refresh checklist dropdown filters for multi-dropdown fields\n x2.forms.initializeMultiselectDropdowns ();\n "); $this->jSClassInstantiation(); if ($this->enableQtips) { $this->setUpQtipManager(); } if ($this->fixedHeader) { $this->setUpStickyHeader(); } // Re-enable a datepicker widget in the data columns $this->addToAfterAjaxUpdate("\n \$('.datePicker').datepicker();\n "); parent::init(); }
public function init() { parent::init(); $this->initColumns(); }