[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16740] Stable: Merge 16733:16739 from trunk
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16740] Stable: Merge 16733:16739 from trunk |
Date: |
Sat, 13 May 2017 10:20:43 -0400 (EDT) |
Revision: 16740
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16740
Author: sigurdne
Date: 2017-05-13 10:20:43 -0400 (Sat, 13 May 2017)
Log Message:
-----------
Stable: Merge 16733:16739 from trunk
Modified Paths:
--------------
branches/Version-2_0-branch/property/inc/class.boreport.inc.php
branches/Version-2_0-branch/property/inc/class.soreport.inc.php
branches/Version-2_0-branch/property/inc/class.uireport.inc.php
branches/Version-2_0-branch/property/js/portico/report.edit.js
branches/Version-2_0-branch/property/templates/base/report.xsl
Property Changed:
----------------
branches/Version-2_0-branch/
branches/Version-2_0-branch/booking/
branches/Version-2_0-branch/bookingfrontend/
Index: branches/Version-2_0-branch
===================================================================
--- branches/Version-2_0-branch 2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch 2017-05-13 14:20:43 UTC (rev 16740)
Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
## -1,4 +1,4 ##
/branches/dev-syncromind:13653
-/branches/dev-syncromind-2:14933-16587
+/branches/dev-syncromind-2:14933-16738
/branches/stavangerkommune:12743-12875,12986
-/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818,15820-15849,15851-15887,15889-15900,15902-16046,16048-16051,16053,16055,16057-16063,16065-16071,16073-16077,16079-16081,16083-16099,16101-16130,16132-16140,16142,16144-16212,16214-16219,16221,16223-16224,16226,16228-16229,16231,16233,16235,16237,16239-16240,16242,16244-16246,16248,16250-16251,16253-16255,16257-16259,16261,16263,16265,16267,16269-16276,16278,16280-16283,16285,16287-16288,16290,16292-16295,16297-16305,16307-16314,16316-16318,16320-16322,16324,16326-16330,16332,16334,16336,16338-16339,16341-16342,16344,16346,16348,16350,16352-16353,16355-16358,16360,16362,16364-16369,16371,16373,16375-16378,16380,16382-16383,16385,16387,16389,16391,16393-16395,16397,16399-16402,16404,16406,16408,16410-16415,16417,16419-16420,16422-16425,16427,16429-16440,16442,16444,16446,16448-16449,16451,16453,16455-16463,16465-16472,16474-16475,16477-16484,16486,16488,16490-16497,16499,16501-16503,16505-16512,16514-16517,16519,16521,16523,16525,16527-16532,16534,16536-16541,16543,16545-16554,16556,16558-16565,16567-16575,16577-16584,16586-16588,16590,16592-16593,16595-16596,16598,16600-16601,16603-16608,16610-16614,16616-16618,16620-16621,16623-16624,16626,16628,16630,16632-16638,16640,16642,16644,16646-16651,16653-16663,16665,16667,16669,16671,16673,16675,16677,16679-16680,16682,16684,16686,16688-16692,16694-16695,16697-16699,16701,16703,16705-16706,16708,16710,16712,16714,16716-16718,16720-16728,16730-16732
\ No newline at end of property
+/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818,15820-15849,15851-15887,15889-15900,15902-16046,16048-16051,16053,16055,16057-16063,16065-16071,16073-16077,16079-16081,16083-16099,16101-16130,16132-16140,16142,16144-16212,16214-16219,16221,16223-16224,16226,16228-16229,16231,16233,16235,16237,16239-16240,16242,16244-16246,16248,16250-16251,16253-16255,16257-16259,16261,16263,16265,16267,16269-16276,16278,16280-16283,16285,16287-16288,16290,16292-16295,16297-16305,16307-16314,16316-16318,16320-16322,16324,16326-16330,16332,16334,16336,16338-16339,16341-16342,16344,16346,16348,16350,16352-16353,16355-16358,16360,16362,16364-16369,16371,16373,16375-16378,16380,16382-16383,16385,16387,16389,16391,16393-16395,16397,16399-16402,16404,16406,16408,16410-16415,16417,16419-16420,16422-16425,16427,16429-16440,16442,16444,16446,16448-16449,16451,16453,16455-16463,16465-16472,16474-16475,16477-16484,16486,16488,16490-16497,16499,16501-16503,16505-16512,16514-16517,16519,16521,16523,16525,16527-16532,16534,16536-16541,16543,16545-16554,16556,16558-16565,16567-16575,16577-16584,16586-16588,16590,16592-16593,16595-16596,16598,16600-16601,16603-16608,16610-16614,16616-16618,16620-16621,16623-16624,16626,16628,16630,16632-16638,16640,16642,16644,16646-16651,16653-16663,16665,16667,16669,16671,16673,16675,16677,16679-16680,16682,16684,16686,16688-16692,16694-16695,16697-16699,16701,16703,16705-16706,16708,16710,16712,16714,16716-16718,16720-16728,16730-16732,16734-16739
\ No newline at end of property
Index: branches/Version-2_0-branch/booking
===================================================================
--- branches/Version-2_0-branch/booking 2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/booking 2017-05-13 14:20:43 UTC (rev 16740)
Property changes on: branches/Version-2_0-branch/booking
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
-/branches/dev-syncromind-2/booking:14933-16587
+/branches/dev-syncromind-2/booking:14933-16738
/branches/stavangerkommune/booking:9468-12740,12743-12875,12986
-/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541,15543-15566,15568-15569,15585-15617,15621-15630,15637-15639,15641-15643,15645,15647-15665,15667-15668,15695-15712,15714-15764,15820-15849,15889-15900,15902-16046,16055,16101-16130,16144-16212,16297-16305,16307-16314,16393-16395,16490-16497,16514-16517,16534,16567-16575,16577-16584,16586-16588,16590,16592-16593,16595-16596,16598,16616-16618,16730
\ No newline at end of property
+/trunk/booking:14721-14732,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14871,14886-14896,14900-14902,14917-14919,14924-14978,14980-15258,15266-15285,15287-15288,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15360-15541,15543-15566,15568-15569,15585-15617,15621-15630,15637-15639,15641-15643,15645,15647-15665,15667-15668,15695-15712,15714-15764,15820-15849,15889-15900,15902-16046,16055,16101-16130,16144-16212,16297-16305,16307-16314,16393-16395,16490-16497,16514-16517,16534,16567-16575,16577-16584,16586-16588,16590,16592-16593,16595-16596,16598,16616-16618,16730,16734-16739
\ No newline at end of property
Index: branches/Version-2_0-branch/bookingfrontend
===================================================================
--- branches/Version-2_0-branch/bookingfrontend 2017-05-13 14:17:39 UTC (rev
16739)
+++ branches/Version-2_0-branch/bookingfrontend 2017-05-13 14:20:43 UTC (rev
16740)
Property changes on: branches/Version-2_0-branch/bookingfrontend
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
-/branches/dev-syncromind-2/bookingfrontend:14933-16587
+/branches/dev-syncromind-2/bookingfrontend:14933-16738
/branches/stavangerkommune/bookingfrontend:9468-12740,12986
-/trunk/bookingfrontend:14721-14732,14770-14783,14794-14808,14824-14825,14838,14886-14894,14906-14909,14917-14919,14924-14978,14980-15258,15297,15312-15335,15585-15617,15621-15630,15714-15764,15813-15814,15820-15849,15889-15900,15902-16046,16101-16130,16144-16212,16297-16305,16307-16314,16316-16318,16385,16387,16393-16395,16399-16402,16586-16588,16603-16608
\ No newline at end of property
+/trunk/bookingfrontend:14721-14732,14770-14783,14794-14808,14824-14825,14838,14886-14894,14906-14909,14917-14919,14924-14978,14980-15258,15297,15312-15335,15585-15617,15621-15630,15714-15764,15813-15814,15820-15849,15889-15900,15902-16046,16101-16130,16144-16212,16297-16305,16307-16314,16316-16318,16385,16387,16393-16395,16399-16402,16586-16588,16603-16608,16734-16739
\ No newline at end of property
Modified: branches/Version-2_0-branch/property/inc/class.boreport.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.boreport.inc.php
2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/property/inc/class.boreport.inc.php
2017-05-13 14:20:43 UTC (rev 16740)
@@ -57,9 +57,9 @@
return $values;
}
- public function read_to_export($id)
+ public function read_to_export($id, $data = array())
{
- $values = $this->so->read_to_export($id);
+ $values = $this->so->read_to_export($id, $data);
return $values;
}
@@ -78,13 +78,20 @@
return $values;
}
- function get_columns($id)
+ function get_view_columns($id)
{
- $values = $this->so->get_columns($id);
+ $values = $this->so->get_view_columns($id);
return $values;
}
+ function get_view_content($id)
+ {
+ $values = $this->so->get_view_content($id);
+
+ return $values;
+ }
+
function read_single_dataset( $dataset_id = '' )
{
$dataset = $this->so->read_single_dataset($dataset_id);
Modified: branches/Version-2_0-branch/property/inc/class.soreport.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.soreport.inc.php
2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/property/inc/class.soreport.inc.php
2017-05-13 14:20:43 UTC (rev 16740)
@@ -168,7 +168,7 @@
return $values;
}
- public function get_columns($id)
+ public function get_view_columns($id)
{
$dataset = $this->read_single_dataset($id);
@@ -193,48 +193,165 @@
return $values;
}
- function read_to_export ( $id )
+ function get_view_content ( $id )
{
$id = (int)$id;
+
+ $dataset = $this->read_single_dataset($id);
- $definition = $this->read_single($id);
- $dataset =
$this->read_single_dataset($definition['dataset_id']);
+ $sql = "SELECT column_name, data_type
+ FROM information_schema.columns
+ WHERE table_name = '".$dataset['view_name']."'
+ ORDER BY ordinal_position";
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ $columns = array();
- $jsonB = json_decode($definition['report_definition'],
true);
+ while ($this->db->next_record())
+ {
+ $columns[] = $this->db->f('column_name');
+ }
- $columns = implode(',', $jsonB['group']);
- $agregates = array();
- foreach ($jsonB['aggregate'] as $c => $v)
+ $sql = "SELECT * FROM ".$dataset['view_name'];
+ $this->db->limit_query($sql, 0, __LINE__, __FILE__, 20);
+
+ $values = array();
+ while ($this->db->next_record())
{
- $agregates[] =
$jsonB['cbo_aggregate'][$v]."(".$v.") AS ".$jsonB['txt_aggregate'][$v];
+ $value = array();
+ foreach ($columns as $column)
+ {
+ $value[$column] = $this->db->f($column);
+ }
+ $values[] = $value;
}
- $func_agregates = implode(',', $agregates);
- $order = '';
- if (count($jsonB['order']))
+
+ return $values;
+ }
+
+ function read_to_export ( $id, $data = array() )
+ {
+ $id = (int)$id;
+
+ if (count($data))
{
- $order = ' ORDER BY '.implode(',',
$jsonB['order']);
+ $dataset = $this->read_single_dataset($id);
+ $jsonB = $data;
+ }
+ else {
+ $definition = $this->read_single($id);
+ $dataset =
$this->read_single_dataset($definition['dataset_id']);
+ $jsonB =
json_decode($definition['report_definition'], true);
}
+
+ $string_columns = implode(',', $jsonB['columns']);
- $sql = "SELECT ".$columns.",".$func_agregates." FROM
".$dataset['view_name']." GROUP BY ".$columns.$order;
+ $group = implode(',', $jsonB['group']);
+ $order = 'ORDER BY '.$group.' ASC';
- $this->db->query($sql, __LINE__, __FILE__);
+ $sql = "SELECT ".$string_columns." FROM
".$dataset['view_name']." ".$order;
- $resultado = array_merge(array_values($jsonB['group']),
array_values($jsonB['txt_aggregate']));
+ if (count($data))
+ {
+ $this->db->limit_query($sql, 0, __LINE__,
__FILE__, 20);
+ } else {
+ $this->db->query($sql, __LINE__, __FILE__);
+ }
+
+ $columns = array_values($jsonB['columns']);
+ array_unshift($columns, "");
+ $functions = $jsonB['cbo_aggregate'];
+
+ $values = array();
+ $array_sum = array();
+ $array_count = array();
- $values = array();
while ($this->db->next_record())
{
$value = array();
- foreach ($resultado as $column)
+ foreach ($columns as $column)
{
$value[$column] = $this->db->f($column);
}
- $values[] = $value;
+
+ foreach ($functions as $k => $v)
+ {
+ if ($v == 'sum')
+ {
+
$array_sum[$this->db->f($group)][$k][] = $this->db->f($k);
+ }
+ if ($v == 'count')
+ {
+
$array_count[$this->db->f($group)][$k][] = $this->db->f($k);
+ }
+ }
+
+ $values[$this->db->f($group)][] = $value;
}
+
+ $result = $this->_generate_total_sum($values,
$array_sum, $array_count);
- return $values;
+ return $result;
}
+ private function _generate_total_sum($values, $array_sum,
$array_count)
+ {
+ $result = array();
+ $array_operations = array();
+
+ foreach ($values as $k => $group)
+ {
+ $columns = array_keys($group[0]);
+
+ $operations = array();
+ $empty = array();
+ foreach ($columns as $columm)
+ {
+ $empty[$columm] = $operations[$columm]
= '';
+
+ if (is_array($array_sum[$k][$columm]))
+ {
+ $operations[$columm] =
array_sum($array_sum[$k][$columm]);
+ }
+ if (is_array($array_count[$k][$columm]))
+ {
+ $operations[$columm] =
count($array_count[$k][$columm]);
+ }
+ if ($columm == '')
+ {
+ $operations[$columm] =
lang('Total');
+ }
+ }
+
+ $array_operations[] = $operations;
+ $group[] = $operations;
+ $group[] = $empty;
+
+ $result = array_merge($result, $group);
+ }
+
+ $grand_total = array();
+ $columns = array_keys($array_operations[0]);
+ foreach ($array_operations as $value)
+ {
+ foreach ($columns as $columm)
+ {
+ if ($columm == '')
+ {
+ $grand_total[$columm] =
lang('Grand Total');
+ }
+ else
+ {
+ $grand_total[$columm] =
($grand_total[$columm] + $value[$columm]) ? ($grand_total[$columm] +
$value[$columm]) : '';
+ }
+ }
+ }
+
+ $result[] = $grand_total;
+
+ return $result;
+ }
+
function read_single_dataset ( $id, $values = array() )
{
$id = (int)$id;
@@ -391,16 +508,16 @@
$this->db->transaction_begin();
- $this->db->query("DELETE FROM fm_view_dataset WHERE id
='{$id}'", __LINE__, __FILE__);
- $this->db->query("DELETE FROM fm_view_dataset_report
WHERE dataset_id ='{$id}'", __LINE__, __FILE__);
+ //$this->db->query("DELETE FROM fm_view_dataset WHERE
id ='{$id}'", __LINE__, __FILE__);
+ $this->db->query("DELETE FROM fm_view_dataset_report
WHERE id ='{$id}'", __LINE__, __FILE__);
if ($this->db->transaction_commit())
{
- $receipt['message'][] = array('msg' =>
lang('dataset has been deleted'));
+ $receipt['message'][] = array('msg' =>
lang('report has been deleted'));
}
else
{
- $receipt['error'][] = array('msg' =>
lang('dataset has not been deleted'));
+ $receipt['error'][] = array('msg' =>
lang('report has not been deleted'));
}
return $receipt;
Modified: branches/Version-2_0-branch/property/inc/class.uireport.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.uireport.inc.php
2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/property/inc/class.uireport.inc.php
2017-05-13 14:20:43 UTC (rev 16740)
@@ -46,7 +46,8 @@
'edit_dataset' => true,
'save_dataset' => true,
'delete_dataset' => true,
- 'get_columns' => true,
+ 'get_column_preview' => true,
+ 'preview' => true,
'download' => true
);
@@ -337,6 +338,7 @@
'report_name' => $values['report_name'],
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+ 'image_loader' =>
$GLOBALS['phpgw']->common->image('property', 'ajax-loader', '.gif', false),
'validator' =>
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
'file'))
);
@@ -353,11 +355,20 @@
$report_name = phpgw::get_var('report_name');
$dataset_id = phpgw::get_var('dataset_id');
- $group = phpgw::get_var('group');
- $order = phpgw::get_var('order');
+ $_columns = phpgw::get_var('columns');
+ $group_by = phpgw::get_var('group');
+ $order_by = phpgw::get_var('order');
$aggregate = phpgw::get_var('aggregate');
$cbo_aggregate = phpgw::get_var('cbo_aggregate');
- $txt_aggregate = phpgw::get_var('txt_aggregate');
+
+ $group = array($group_by => $group_by);
+ $order = array($order_by => $order_by);
+
+ $columns = array();
+ foreach ($_columns as $column)
+ {
+ $columns[] = $column;
+ }
$values['id'] = $report_id;
@@ -373,7 +384,7 @@
if (!count($group))
{
- $this->receipt['error'][] = array('msg' =>
lang('Please select a columns !'));
+ $this->receipt['error'][] = array('msg' =>
lang('Please select a group !'));
}
if (!count($aggregate))
@@ -382,11 +393,12 @@
}
$values['report_name'] = $report_name;
+ $values['report_definition']['columns'] = $columns;
$values['report_definition']['group'] = $group;
$values['report_definition']['order'] = $order;
$values['report_definition']['aggregate'] = $aggregate;
$values['report_definition']['cbo_aggregate'] =
$cbo_aggregate;
- $values['report_definition']['txt_aggregate'] =
$txt_aggregate;
+ //$values['report_definition']['txt_aggregate'] =
$txt_aggregate;
$values['dataset_id'] = $dataset_id;
return $values;
@@ -398,7 +410,7 @@
{
return $this->edit();
}
-
+
/*
* Overrides with incoming data from POST
*/
@@ -673,13 +685,61 @@
return $this->jquery_results($result_data);
}
- public function get_columns()
+ public function get_column_preview()
{
$dataset_id = phpgw::get_var('dataset_id');
- $columns = $this->bo->get_columns($dataset_id);
+ $columns = $this->bo->get_view_columns($dataset_id);
- return $columns;
+ $html_table = '<table class="pure-table
pure-table-bordered">';
+ $html_table .= '<thead><tr>';
+ foreach ($columns as $col)
+ {
+ $_check = '<input type="checkbox"
id="c_'.$col['name'].'" name="columns['.$col['name'].']"
value="'.$col['name'].'" onchange="build_check_groups(\''. $col['name'] .'\',
\''. $col['type'] .'\')"/>';
+ $html_table .= "<th align='center'>".$_check."
".$col['name']."</th>";
+ }
+ $html_table .= '</tr></thead>';
+
+ $data = $this->bo->get_view_content($dataset_id);
+
+ foreach ($data as $row)
+ {
+ $html_table .= "<tr><td>" .
implode('</td><td>', $row) . '</td></tr>';
+ }
+ $html_table .= '</table>';
+
+ return array('columns_preview' => $html_table);
}
+ public function preview()
+ {
+ $values = phpgw::get_var('values');
+ $dataset_id = phpgw::get_var('dataset_id');
+
+ $data['columns'] = $values['columns'];
+ $data['group'] = $values['group'];
+ $data['order'] = $values['order'];
+ $data['aggregate'] = $values['aggregate'];
+ $data['cbo_aggregate'] = $values['cbo_aggregate'];
+
+ $list = $this->bo->read_to_export($dataset_id, $data);
+
+ $html_table = '<table class="pure-table
pure-table-bordered">';
+ $html_table .= '<thead><tr>';
+ foreach ($list[0] as $c => $v)
+ {
+ $html_table .= "<th align='center'>".$c."</th>";
+ }
+ $html_table .= '</tr></thead>';
+
+ foreach ($list as $row)
+ {
+ $html_table .= "<tr><td>" .
implode('</td><td>', $row) . '</td></tr>';
+ }
+ $html_table .= '</table>';
+
+ return $html_table;
+
+ }
+
}
\ No newline at end of file
Modified: branches/Version-2_0-branch/property/js/portico/report.edit.js
===================================================================
--- branches/Version-2_0-branch/property/js/portico/report.edit.js
2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/property/js/portico/report.edit.js
2017-05-13 14:20:43 UTC (rev 16740)
@@ -1,10 +1,11 @@
$(document).ready(function ()
{
- //$('.processing').hide();
+ $('.processing').hide();
+ $('.processing-preview').hide();
$('#btn_get_columns').click( function()
{
- var oArgs = {menuaction: 'property.uireport.get_columns'};
+ var oArgs = {menuaction:
'property.uireport.get_column_preview'};
var requestUrl = phpGWLink('index.php', oArgs, true);
var data = {"dataset_id": $('#cbo_dataset_id').val()};
@@ -20,7 +21,7 @@
dataType: 'json',
data: data
}).always(function () {
- //$('.processing').hide();
+ $('.processing').hide();
}).done(function (result) {
//console.log(result);
$('#container_columns').empty();
@@ -28,7 +29,8 @@
$('#container_order').empty();
$('#container_aggregates').empty();
- build_check_columns(result);
+ $('#container_columns').html(result.columns_preview);
+
if (jsonB !== '')
{
set_values();
@@ -37,14 +39,108 @@
});
$('#btn_get_columns').click();
+
+ $('#btn_preview').click( function()
+ {
+ var oArgs = {menuaction: 'property.uireport.preview'};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ if ($('#cbo_dataset_id').val() == '')
+ {
+ alert('choose dataset');
+ return;
+ }
+
+ var values = {};
+
+ values['columns'] = {};
+ values['group'] = {};
+ values['order'] = {};
+ values['aggregate'] = {};
+ values['cbo_aggregate'] = {};
+
+ $('input[name^="columns"]').each(function() {
+
+ if ($(this).is(":checked"))
+ {
+ values['columns'][$(this).val()] =
$(this).val();
+ }
+ });
+
+ var invalid_groups = true;
+ $('input[name="group"]').each(function() {
+
+ if ($(this).is(":checked"))
+ {
+ values['group'][$(this).val()] = $(this).val();
+ invalid_groups = false;
+ }
+ });
+
+ if (invalid_groups)
+ {
+ alert('Choose group');
+ $('#responsiveTabsGroups').responsiveTabs('activate',
1);
+ return;
+ }
+
+ $('input[name="order"]').each(function() {
+
+ if ($(this).is(":checked"))
+ {
+ values['order'][$(this).val()] = $(this).val();
+ }
+ });
+
+ var name = '';
+ var invalid_aggregate = true;
+
+ $('input[name^="aggregate"]').each(function() {
+
+ if ($(this).is(":checked"))
+ {
+ name = $(this).val();
+ values['aggregate'][name] = name;
+ invalid_aggregate = false;
+
+ values['cbo_aggregate'][name] = $('#cbo_' +
name).val();
+ }
+ });
+
+ if (invalid_aggregate)
+ {
+ $('#responsiveTabsGroups').responsiveTabs('activate',
3);
+ alert('Choose COUNT/SUM option');
+ return;
+ }
+
+ var data = {"values": values, "dataset_id":
$('#cbo_dataset_id').val()};
+ $('.processing-preview').show();
+ $.ajax({
+ type: 'GET',
+ url: requestUrl,
+ dataType: 'json',
+ data: data
+ }).always(function () {
+ $('.processing-preview').hide();
+ }).done(function (result) {
+ $('#container_preview').html(result);
+ });
+ });
+
});
function set_values()
{
+ $.each(jsonB.columns, function(key, value)
+ {
+ $("#c_" + value).prop('checked', true);
+ $("#c_" + value).change();
+ });
+
$.each(jsonB.group, function(key, value)
{
- $("#c_" + key).prop('checked', true);
- $("#c_" + key).change();
+ $("#g_" + key).prop('checked', true);
});
$.each(jsonB.order, function(key, value)
@@ -62,11 +158,6 @@
{
$("#cbo_" + key).val(value);
});
-
- $.each(jsonB.txt_aggregate, function(key, value)
- {
- $("#txt_" + key).val(value);
- });
}
function build_check_columns(data)
@@ -73,28 +164,33 @@
{
$.each(data, function(key, object)
{
- $('#container_columns').append('<span
style="margin-right:12px;"><input type="checkbox" id="c_'+ object.name +'"
value="'+ object.name +'" onchange="build_check_groups(\''+ object.name
+'\')"/> ' + object.name + '</span>');
-
var combo = build_list_aggregates(object.name, object.type);
- var text = build_text_aggregates(object.name);
+ //var text = build_text_aggregates(object.name);
var check = build_check_aggregates(object.name);
- var el_1 = '<span style="display:table-row;">'+ check + combo +
text + '</span>';
+ var el_1 = '<span style="display:table-row;">'+ check + combo +
'</span>';
$('#container_aggregates').append(el_1);
});
}
-function build_check_groups(name)
+function build_check_groups(name, type)
{
if ($("#c_" + name).is(":checked"))
{
- var el_1 = '<span style="display:block;"><input onclick="return
false;" onkeydown="return false;" type="checkbox" name="group['+ name +']"
id="g_'+ name +'" value="'+ name +'" checked/>' + name + '</span>';
- var el_2 = '<span style="display:block;"><input type="checkbox"
name="order['+ name +']" id="o_'+ name +'" value="'+ name +'"/>' + name +
'</span>';
+ var el_1 = '<span style="display:block;"><input type="radio"
name="group" id="g_'+ name +'" value="'+ name +'"/>' + name + '</span>';
+ var el_2 = '<span style="display:block;"><input type="radio"
name="order" id="o_'+ name +'" value="'+ name +'"/>' + name + '</span>';
$('#container_groups').append(el_1);
$('#container_order').append(el_2);
+
+ var combo = build_list_aggregates(name, type);
+ //var text = build_text_aggregates(name);
+ var check = build_check_aggregates(name);
+ var el_1 = '<span style="display:table-row;">'+ check + combo +
'</span>';
+ $('#container_aggregates').append(el_1);
}
else {
$("#g_" + name).parent().remove();
$("#o_" + name).parent().remove();
+ $("#cbo_" + name).parent().parent().remove();
}
}
@@ -108,7 +204,7 @@
{
var combo = $("<select></select>");
combo.append("<option value='count'>Count</option>");
- if (type == 'integer')
+ if (type == 'integer' || type == 'numeric')
{
combo.append("<option value='sum'>Sum</option>");
}
@@ -126,9 +222,7 @@
if ($("#a_" + name).is(":checked"))
{
$("#cbo_" + name).prop('disabled', false);
- $("#txt_" + name).prop('disabled', false);
} else {
- $("#cbo_" + name).prop('disabled', true);
- $("#txt_" + name).prop('disabled', true);
+ $("#cbo_" + name).prop('disabled', true);
}
}
Modified: branches/Version-2_0-branch/property/templates/base/report.xsl
===================================================================
--- branches/Version-2_0-branch/property/templates/base/report.xsl
2017-05-13 14:17:39 UTC (rev 16739)
+++ branches/Version-2_0-branch/property/templates/base/report.xsl
2017-05-13 14:20:43 UTC (rev 16740)
@@ -75,8 +75,20 @@
</xsl:when>
</xsl:choose>
<script type="text/javascript">
- var jsonB = <xsl:value-of select="report_definition"/>;
+ var jsonB = {};
+ <xsl:if test="report_definition != ''">
+ jsonB = <xsl:value-of select="report_definition"/>;
+ </xsl:if>
</script>
+
+ <style type="text/css">
+ .content_columns {
+ position: relative;
+ overflow: auto;
+ max-height: 50vh;
+ width: 100%;
+ }
+ </style>
<div id="document_edit_tabview">
<xsl:variable name="form_action">
@@ -86,7 +98,7 @@
<div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="tabs"/>
<div id="report">
- <input type="hidden" name="report_id"
value="{report_id}"/>
+ <input type="hidden" id="report_id"
name="report_id" value="{report_id}"/>
<div class="pure-control-group">
<label>
<xsl:value-of
select="php:function('lang', 'report name')" />
@@ -104,32 +116,65 @@
<xsl:attribute
name="value">
<xsl:value-of
select="php:function('lang', 'get columns')" />
</xsl:attribute>
- </input>
- </div>
- <div class="pure-control-group">
- <label>
- <xsl:value-of
select="php:function('lang', 'Choose columns')" />
- </label>
- <div id="container_columns"
class="pure-custom"></div>
+ </input>
+ <img src="{image_loader}"
class="processing" align="absmiddle"></img>
</div>
- <div class="pure-control-group">
- <label>
- <xsl:value-of
select="php:function('lang', 'Group by')" />
- </label>
- <div id="container_groups"
class="pure-custom"></div>
- </div>
- <div class="pure-control-group">
- <label>
- <xsl:value-of
select="php:function('lang', 'Sort by')" />
- </label>
- <div id="container_order"
class="pure-custom"></div>
- </div>
- <div class="pure-control-group">
- <label>
- <xsl:value-of
select="php:function('lang', 'Count / Sum')" />
- </label>
- <div id="container_aggregates"
class="pure-custom"></div>
- </div>
+
+ <div id="responsiveTabsGroups">
+ <ul>
+ <li><a
href="#tab-columns"><xsl:value-of select="php:function('lang',
'Columns')"/></a></li>
+ <li><a
href="#tab-group"><xsl:value-of select="php:function('lang', 'Group
by')"/></a></li>
+ <li><a
href="#tab-sort"><xsl:value-of select="php:function('lang', 'Sort
by')"/></a></li>
+ <li><a
href="#tab-count-sum"><xsl:value-of select="php:function('lang', 'Count /
Sum')"/></a></li>
+ <li><a
href="#tab-preview"><xsl:value-of select="php:function('lang',
'Preview')"/></a></li>
+ </ul>
+ <div id="tab-columns">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Choose')" />
+ </label>
+ <div
id="container_columns" class="content_columns"></div>
+ </div>
+ </div>
+ <div id="tab-group">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Choose')" />
+ </label>
+ <div
id="container_groups" class="pure-custom"></div>
+ </div>
+ </div>
+ <div id="tab-sort">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Choose')" />
+ </label>
+ <div
id="container_order" class="pure-custom"></div>
+ </div>
+ </div>
+ <div id="tab-count-sum">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Choose')" />
+ </label>
+ <div
id="container_aggregates" class="pure-custom"></div>
+ </div>
+ </div>
+ <div id="tab-preview">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'Show')" />
+ </label>
+ <input
type="button" class="pure-button pure-button-primary" name="btn_preview"
id="btn_preview">
+
<xsl:attribute name="value">
+
<xsl:value-of select="php:function('lang', 'preview')" />
+
</xsl:attribute>
+ </input>
+ <img
src="{image_loader}" class="processing-preview" align="absmiddle"></img>
+ </div>
+ <div
id="container_preview" class="content_columns"></div>
+ </div>
+ </div>
</div>
</div>
<div class="proplist-col">
@@ -152,6 +197,12 @@
</div>
</form>
</div>
+ <script>
+
+ $('#responsiveTabsGroups').responsiveTabs({
+ startCollapsed: 'accordion'
+ });
+ </script>
</xsl:template>
<xsl:template match="edit_dataset">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16740] Stable: Merge 16733:16739 from trunk,
sigurdne <=