* [misc] delete useless pager code.

This commit is contained in:
songchenxuan
2024-07-16 15:46:53 +08:00
committed by 綦新志
parent b671fcc76d
commit 82c8b57e3d
2 changed files with 4 additions and 129 deletions
+2 -62
View File
@@ -68,66 +68,6 @@ class pivot extends control
$this->display();
}
/**
* Ajax get sys options.
*
* @param string $type
* @param string $object
* @param string $field
* @param string $saveAs
* @access public
* @return string
*/
public function ajaxGetSysOptions($type, $object = '', $field = '', $saveAs = '')
{
$sql = isset($_POST['sql']) ? $_POST['sql'] : '';
$filters = isset($_POST['filters']) ? $_POST['filters'] : array();
$sql = $this->loadModel('chart')->parseSqlVars($sql, $filters);
$options = $this->pivot->getSysOptions($type, $object, $field, $sql, $saveAs);
return print(html::select('default[]', array('' => '') + $options, '', "class='form-control form-select picker-select' multiple"));
}
/**
* Ajax get pivot table.
*
* @access public
* @return void
*/
public function ajaxGetPivot()
{
$post = fixer::input('post')->skipSpecial('settings,filters,sql,langs')->get();
$pivotID = $post->id;
$settings = $post->settings;
$filters = isset($_POST['searchFilters']) ? $_POST['searchFilters'] : (isset($_POST['filters']) ? $post->filters : array());
$page = isset($_POST['page']) ? $_POST['page'] : 0;
$filterType = 'result';
$pivot = $this->pivot->getById($pivotID);
list($sql, $filterFormat) = $this->pivot->getFilterFormat($post->sql, $filters);
$post->sql = $sql;
$settings['filterType'] = $filterType;
$sql = str_replace(';', '', "$post->sql");
$driver = $pivot->driver;
$fields = $post->fieldSettings;
$langs = isset($post->langs) ? (is_array($post->langs) ? $post->langs : json_decode($post->langs, true)) : array();
if(isset($settings['summary']) and $settings['summary'] == 'notuse')
{
list($data, $configs) = $this->pivot->genOriginSheet($fields, $settings, $sql, $filterFormat, $langs, $driver);
}
else
{
list($data, $configs) = $this->pivot->genSheet($fields, $settings, $sql, $filterFormat, $langs, $driver);
}
$this->pivot->buildPivotTable($data, $configs, $page);
}
/**
* Drill data modal.
* 下钻数据的弹窗。
@@ -150,8 +90,8 @@ class pivot extends control
$datas = $this->pivot->getDrillDatas($drill, $drillFields);
$result = $this->pivot->processColData($drill->object, $cols, $datas);
$cols = $result['cols'];
$datas = $result['data'];
$cols = $result['cols'];
$datas = $result['data'];
$this->view->cols = $cols;
$this->view->datas = $datas;
+2 -67
View File
@@ -1432,57 +1432,6 @@ class pivotModel extends model
}
}
/**
* 通过合并单元格的数据对透视表进行分页
* Page pivot by configs merge cell data.
*
* @param array $configs
* @param int $page
* @param bool $useColumnTotal
* @static
* @access public
* @return bool
*/
public function pagePivot($configs, $page, $useColumnTotal)
{
$configs = array_values($configs);
// 当前在第几页
$nowPage = 1;
// 一共多少行
$pageCount = 0;
// 当前页目前多少行
$nowCount = 0;
// 记录当前第几个分组(项),共有多少行
$itemRow = array(0 => 0);
// 目标分页的起始行和结束行
$start = $end = -1;
foreach($configs as $key => $config)
{
if($nowPage == $page and $start == -1) $start = $pageCount;
if($nowPage == $page + 1 and $end == -1) $end = $pageCount;
$pageCount += $config[0];
$nowCount += $config[0];
$itemRow[] = $pageCount;
// 如果当前页超过了50行,换一页
if($nowCount >= $this->config->pivot->recPerPage)
{
$nowCount = 0;
if(isset($configs[$key + 1])) $nowPage += 1;
}
}
if($start == -1) $start = 0;
if($end == -1) $end = $pageCount;
// 获得当前页面有多少"项"
$endKey = array_search($end, $itemRow);
$startKey = array_search($start, $itemRow);
$itemCount = $endKey - $startKey;
// 如果是最后一页且使用了显示列的汇总,项数-1,
if($page == $nowPage and $useColumnTotal) $itemCount --;
return array($start, $end - 1, $itemCount, $nowPage);
}
/**
* Gen sheet by origin sql.
*
@@ -2414,12 +2363,11 @@ class pivotModel extends model
*
* @param object $data
* @param array $configs
* @param int $page
* @access public
* @return void
*
*/
public function buildPivotTable($data, $configs, $page = 0)
public function buildPivotTable($data, $configs)
{
$width = 128;
@@ -2464,14 +2412,11 @@ class pivotModel extends model
$rowCount = 0;
$useColumnTotal = (!empty($data->columnTotal) and $data->columnTotal === 'sum');
if($page) list($start, $end, $itemCount, $pageTotal) = $this->pagePivot($configs, $page, $useColumnTotal);
for($i = 0; $i < count($data->array); $i ++)
{
$rowCount ++;
if($page and ($i < $start or $i > $end)) continue;
if($useColumnTotal and $rowCount == count($data->array)) continue;
$line = array_values($data->array[$i]);
@@ -2497,8 +2442,7 @@ class pivotModel extends model
$table .= "</tr>";
}
/* Add column total. 如果分页了,只在最后一页展示 */
if($useColumnTotal and !empty($data->array) and (!$page or $page == $pageTotal))
if($useColumnTotal and !empty($data->array))
{
$table .= "<tr class='text-center'>";
$table .= "<td colspan='" . count($data->groups) . "'>{$this->lang->pivot->step2->total}</td>";
@@ -2514,15 +2458,6 @@ class pivotModel extends model
$table .= "</tbody>";
$table .= "</table></div>";
if($page)
{
$recTotal = $end - $start + 1;
$leftPage = $page - 1;
$rightPage = $page + 1;
if($recTotal) $table .= $this->getTablePager($itemCount, $leftPage, $rightPage, $page, $pageTotal);
}
echo $table;
}