[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16789] Stable: Merge 16784:16788 from trunk
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16789] Stable: Merge 16784:16788 from trunk |
Date: |
Mon, 29 May 2017 07:34:36 -0400 (EDT) |
Revision: 16789
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16789
Author: sigurdne
Date: 2017-05-29 07:34:35 -0400 (Mon, 29 May 2017)
Log Message:
-----------
Stable: Merge 16784:16788 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-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch 2017-05-29 11:34:35 UTC (rev 16789)
Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
## -1,4 +1,4 ##
/branches/dev-syncromind:13653
-/branches/dev-syncromind-2:14933-16738
+/branches/dev-syncromind-2:14933-16787
/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,16734-16739,16741,16743-16746,16748-16750,16752-16755,16757,16759-16761,16763,16765,16767,16769-16774,16776,16778-16783
\ 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,16741,16743-16746,16748-16750,16752-16755,16757,16759-16761,16763,16765,16767,16769-16774,16776,16778-16783,16785-16788
\ No newline at end of property
Index: branches/Version-2_0-branch/booking
===================================================================
--- branches/Version-2_0-branch/booking 2017-05-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/booking 2017-05-29 11:34:35 UTC (rev 16789)
Property changes on: branches/Version-2_0-branch/booking
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
-/branches/dev-syncromind-2/booking:14933-16738
+/branches/dev-syncromind-2/booking:14933-16787
/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,16734-16739,16748-16750,16769-16774
\ 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,16748-16750,16769-16774,16785-16788
\ No newline at end of property
Index: branches/Version-2_0-branch/bookingfrontend
===================================================================
--- branches/Version-2_0-branch/bookingfrontend 2017-05-27 18:56:31 UTC (rev
16788)
+++ branches/Version-2_0-branch/bookingfrontend 2017-05-29 11:34:35 UTC (rev
16789)
Property changes on: branches/Version-2_0-branch/bookingfrontend
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,3 ##
-/branches/dev-syncromind-2/bookingfrontend:14933-16738
+/branches/dev-syncromind-2/bookingfrontend:14933-16787
/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,16734-16739,16752-16755
\ 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,16752-16755,16785-16788
\ 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-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/property/inc/class.boreport.inc.php
2017-05-29 11:34:35 UTC (rev 16789)
@@ -40,6 +40,13 @@
{
$this->so = CreateObject('property.soreport');
$this->bocommon = CreateObject('property.bocommon');
+ $this->operators = $this->so->operators;
+
+ $this->operators_equal = $this->so->operators_equal;
+ $this->operators_between = $this->so->operators_between;
+ $this->operators_like = $this->so->operators_like;
+ $this->operators_in = $this->so->operators_in;
+ $this->operators_null = $this->so->operators_null;
}
function read_single( $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-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/property/inc/class.soreport.inc.php
2017-05-29 11:34:35 UTC (rev 16789)
@@ -37,6 +37,34 @@
$this->left_join = & $this->db->left_join;
$this->like = & $this->db->like;
$this->total_records = 0;
+
+ $this->operators_equal = array(
+ 'equal' => '=',
+ 'not_equal' => '!=',
+ 'less' => '<',
+ 'less_equal' => '<=',
+ 'greater' => '>',
+ 'greater_equal' => '>='
+ );
+ $this->operators_between = array(
+ 'between' => 'BETWEEN',
+ 'not_between' => 'NOT BETWEEN'
+ );
+ $this->operators_like = array(
+ 'like' => 'LIKE',
+ 'not_like' => 'NOT LIKE',
+ 'ilike' => 'ILIKE',
+ 'not_ilike' => 'NOT ILIKE'
+ );
+ $this->operators_in = array(
+ 'in' => 'IN',
+ 'not_in' => 'NOT IN'
+ );
+ $this->operators_null = array(
+ 'is_null' => 'IS NULL',
+ 'is_not_null' => 'IS NOT NULL'
+ );
+ $this->operators = array_merge($this->operators_equal,
$this->operators_between, $this->operators_like, $this->operators_in,
$this->operators_null);
}
function read_single ( $id, $values = array() )
@@ -229,6 +257,120 @@
return $values;
}
+ private function _is_date( $str ) {
+ try {
+ $dt = new DateTime( trim($str) );
+ }
+ catch( Exception $e ) {
+ return false;
+ }
+ $month = $dt->format('m');
+ $day = $dt->format('d');
+ $year = $dt->format('Y');
+ if( checkdate($month, $day, $year) ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private function _build_conditions_equal($param, $type)
+ {
+ $result = '';
+
+ switch ($type)
+ {
+ case 'character varying':
+ case 'text':
+ $result = $param['field']."
".$this->operators[$param['operator']]." '".$param['value1']."'";
+ if ($param['conector'] &&
$param['value2'] != '')
+ {
+ $result .= "
".$param['conector']." ".$param['field']."
".$this->operators[$param['operator']]." '".$param['value2']."'";
+ }
+ break;
+ case 'integer':
+ case 'smallint':
+ case 'numeric':
+ if (is_numeric($param['value1']))
+ {
+ $result = $param['field']."
".$this->operators[$param['operator']]." ".$param['value1'];
+ if ($param['conector'] &&
is_numeric(['value2']))
+ {
+ $result .= "
".$param['conector']." ".$param['field']."
".$this->operators[$param['operator']]." ".$param['value2'];
+ }
+ }
+ break;
+ case 'date':
+ case 'timestamp without time zone':
+ if ($this->_is_date($param['value1']))
+ {
+ $result = $param['field']."
".$this->operators[$param['operator']]." '".$param['value1']."'";
+ if ($param['conector'] &&
$this->_is_date($param['value2']))
+ {
+ $result .= "
".$param['conector']." ".$param['field']."
".$this->operators[$param['operator']]." '".$param['value1']."'";
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ private function _build_conditions($criteria, $id)
+ {
+ $columns = $this->get_view_columns($id);
+ $_columns = array();
+ foreach ($columns as $column)
+ {
+ $_columns[$column['name']] = $column['type'];
+ }
+
+ $where = array();
+ foreach ($criteria as $param)
+ {
+ switch (true)
+ {
+ case
(array_key_exists($param['operator'], $this->operators_equal)):
+ $result =
$this->_build_conditions_equal($param, $_columns[$param['field']]);
+ break;
+ case
(array_key_exists($param['operator'], $this->operators_between)):
+ if ($param['value1'] != '' &&
$param['value2'] != '')
+ {
+ $result =
$param['field']."::text ".$this->operators[$param['operator']]."
'".$param['value1']."' AND '".$param['value2']."'";
+ }
+ break;
+ case
(array_key_exists($param['operator'], $this->operators_like)):
+ if ($param['value1'] != '')
+ {
+ $result =
$param['field']."::text ".$this->operators[$param['operator']]."
'%".$param['value1']."%'";
+ if ($param['conector']
&& $param['value2'] != '')
+ {
+ $result .= "
".$param['conector']." ".$param['field']."::text
".$this->operators[$param['operator']]." '%".$param['value2']."%'";
+ }
+ }
+ break;
+ case
(array_key_exists($param['operator'], $this->operators_null)):
+ $result = $param['field']."
".$this->operators[$param['operator']];
+ break;
+ case
(array_key_exists($param['operator'], $this->operators_in)):
+ if ($param['value1'] != '')
+ {
+ $values =
array_map('trim', explode(',', $param['value1']));
+ $_string =
"'".implode("','", $values)."'";
+ $result =
$param['field']."::text ".$this->operators[$param['operator']]."
(".$_string.")";
+ }
+ break;
+ }
+
+ if ($result)
+ {
+ $where[] = $result;
+ }
+ }
+
+ return $where;
+ }
+
function read_to_export ( $id, $data = array() )
{
$id = (int)$id;
@@ -237,19 +379,25 @@
{
$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']);
$group = implode(',', $jsonB['group']);
$order = 'ORDER BY '.$group.' ASC';
+ $cond = $this->_build_conditions($jsonB['criteria'],
$id);
- $sql = "SELECT ".$string_columns." FROM
".$dataset['view_name']." ".$order;
+ if ($cond)
+ {
+ $where = 'WHERE '.implode(' AND ', $cond);
+ }
+
+ $sql = "SELECT ".$string_columns." FROM
".$dataset['view_name']." ".$where." ".$order;
if (count($data))
{
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-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/property/inc/class.uireport.inc.php
2017-05-29 11:34:35 UTC (rev 16789)
@@ -47,6 +47,7 @@
'save_dataset' => true,
'delete_dataset' => true,
'get_column_preview' => true,
+ 'get_operators' => true,
'preview' => true,
'download' => true
);
@@ -59,6 +60,13 @@
$this->bo = CreateObject('property.boreport', true);
$this->bocommon = & $this->bo->bocommon;
$this->acl = & $GLOBALS['phpgw']->acl;
+ $this->operators = $this->bo->operators;
+
+ $this->operators_equal = $this->bo->operators_equal;
+ $this->operators_between = $this->bo->operators_between;
+ $this->operators_like = $this->bo->operators_like;
+ $this->operators_in = $this->bo->operators_in;
+ $this->operators_null = $this->bo->operators_null;
}
public function download()
@@ -334,6 +342,14 @@
'cancel_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uireport.index')),
'datasets' => array('options' => $list),
'report_definition' =>
$values['report_definition'],
+ 'operators' => json_encode($this->operators),
+
+ 'operators_equal' =>
json_encode($this->operators_equal),
+ 'operators_between' =>
json_encode($this->operators_between),
+ 'operators_like' =>
json_encode($this->operators_like),
+ 'operators_in' =>
json_encode($this->operators_in),
+ 'operators_null' =>
json_encode($this->operators_null),
+
'report_id' => $values['id'],
'report_name' => $values['report_name'],
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
@@ -360,7 +376,22 @@
$order_by = phpgw::get_var('order');
$aggregate = phpgw::get_var('aggregate');
$cbo_aggregate = phpgw::get_var('cbo_aggregate');
-
+
+ $restricted_values =
phpgw::get_var('cbo_restricted_value');
+ $operators = phpgw::get_var('cbo_operator');
+ $values_1 = phpgw::get_var('txt_value1');
+ $conector = phpgw::get_var('cbo_conector');
+ $values_2 = phpgw::get_var('txt_value2');
+
+ $criteria = array();
+ foreach ($restricted_values as $k => $field)
+ {
+ if ($field && $operators[$k])
+ {
+ $criteria[] = array('field'=>$field,
'operator'=>$operators[$k], 'value1'=>trim($values_1[$k]),
'conector'=>$conector[$k], 'value2'=>trim($values_2[$k]));
+ }
+ }
+
$group = array($group_by => $group_by);
$order = array($order_by => $order_by);
@@ -398,6 +429,7 @@
$values['report_definition']['order'] = $order;
$values['report_definition']['aggregate'] = $aggregate;
$values['report_definition']['cbo_aggregate'] =
$cbo_aggregate;
+ $values['report_definition']['criteria'] = $criteria;
//$values['report_definition']['txt_aggregate'] =
$txt_aggregate;
$values['dataset_id'] = $dataset_id;
@@ -708,7 +740,7 @@
}
$html_table .= '</table>';
- return array('columns_preview' => $html_table);
+ return array('columns_preview' => $html_table,
'columns' => $columns);
}
public function preview()
@@ -722,6 +754,22 @@
$data['aggregate'] = $values['aggregate'];
$data['cbo_aggregate'] = $values['cbo_aggregate'];
+ $restricted_values = $values['cbo_restricted_value'];
+ $operators = $values['cbo_operator'];
+ $values_1 = $values['txt_value1'];
+ $conector = $values['cbo_conector'];
+ $values_2 = $values['txt_value2'];
+
+ $criteria = array();
+ foreach ($restricted_values as $k => $field)
+ {
+ if ($field && $operators[$k])
+ {
+ $criteria[] = array('field'=>$field,
'operator'=>$operators[$k], 'value1'=>trim($values_1[$k]),
'conector'=>$conector[$k], 'value2'=>trim($values_2[$k]));
+ }
+ }
+ $data['criteria'] = $criteria;
+
$list = $this->bo->read_to_export($dataset_id, $data);
$html_table = '<table class="pure-table
pure-table-bordered">';
@@ -742,4 +790,27 @@
}
+ public function get_operators()
+ {
+ $operators = array(
+ 'equal' => '=',
+ 'different' => '!=',
+ 'less' => '<',
+ 'less_equal' => '<=',
+ 'higher' => '>',
+ 'higher_equal' => '>=',
+ 'between' => 'BETWEEN',
+ 'like' => 'LIKE',
+ 'not_like' => 'NOT LIKE',
+ 'ilike' => 'ILIKE',
+ 'not_ilike' => 'NOT ILIKE',
+ 'in' => 'IN',
+ 'not_in' => 'NOT IN',
+ 'not_between' => 'NOT BETWEEN',
+ 'is_null' => 'IS NULL',
+ 'is_not_null' => 'IS NOT NULL'
+ );
+
+ return $operators;
+ }
}
\ 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-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/property/js/portico/report.edit.js
2017-05-29 11:34:35 UTC (rev 16789)
@@ -28,9 +28,23 @@
$('#container_groups').empty();
$('#container_order').empty();
$('#container_aggregates').empty();
+ $('#container_criteria').empty();
$('#container_columns').html(result.columns_preview);
+ $('#responsiveTabsGroups').responsiveTabs('activate',
0);
+ columns = result.columns;
+
+ var row = '<span style="display:table-row;">\n\
+ <span
style="display:table-cell;">Restricted value</span>\n\
+ <span
style="display:table-cell;">Operator</span>\n\
+ <span
style="display:table-cell;">Value</span>\n\
+ <span
style="display:table-cell;">Conector</span>\n\
+ <span
style="display:table-cell;">Value</span>\n\
+ </span>';
+ $('#container_criteria').append(row);
+ n = 0;
+
if (jsonB !== '')
{
set_values();
@@ -58,6 +72,11 @@
values['order'] = {};
values['aggregate'] = {};
values['cbo_aggregate'] = {};
+ values['cbo_restricted_value'] = {};
+ values['cbo_operator'] = {};
+ values['txt_value1'] = {};
+ values['cbo_conector'] = {};
+ values['txt_value2'] = {};
$('input[name^="columns"]').each(function() {
@@ -113,7 +132,29 @@
alert('Choose COUNT/SUM option');
return;
}
+
+ var idx = 0;
+ var size = 0;
+ $('.criteria').each(function()
+ {
+ idx = $(this).val();
+ if ($('#cbo_restricted_value_' + idx).val())
+ {
+ values['cbo_restricted_value'][idx] =
$('#cbo_restricted_value_' + idx).val();
+ values['cbo_operator'][idx] =
$('#cbo_operator_' + idx).val();
+ values['txt_value1'][idx] = $('#txt_value1_' +
idx).val();
+ values['cbo_conector'][idx] =
$('#cbo_conector_' + idx).val();
+ values['txt_value2'][idx] = $('#txt_value2_' +
idx).val();
+ size ++;
+ }
+ });
+ if (size && !validate_criteria(values))
+ {
+ $('#responsiveTabsGroups').responsiveTabs('activate',
4);
+ return;
+ }
+
var data = {"values": values, "dataset_id":
$('#cbo_dataset_id').val()};
$('.processing-preview').show();
$.ajax({
@@ -128,8 +169,115 @@
});
});
+ $('#btn_add_restricted_value').click( function()
+ {
+ var combo_operator = $("<select></select>");
+ combo_operator.append("<option value=''></option>");
+ $.each(operators, function(key, value)
+ {
+ combo_operator.append("<option value='"+ key +"'>"+
value +"</option>");
+ });
+
+ var combo_conector = $("<select></select>");
+ combo_conector.append("<option value=''></option>");
+ combo_conector.append("<option value='and'>AND</option>");
+ combo_conector.append("<option value='or'>OR</option>");
+
+ var combo_restricted_value = $("<select></select>");
+ combo_restricted_value.append("<option value=''></option>");
+ $.each(columns, function(key, value)
+ {
+ combo_restricted_value.append("<option value='"+
value.name +"'>"+ value.name +"</option>");
+ });
+
+ var el_1 = "<span style='display:table-cell;'><select
id='cbo_restricted_value_"+ n +"' name='cbo_restricted_value[]'>" +
$(combo_restricted_value).html() + "</select></span>";
+ var el_2 = "<span style='display:table-cell;'><select
id='cbo_operator_"+ n +"' name='cbo_operator[]'>" + $(combo_operator).html() +
"</select></span>";
+ var el_3 = "<span style='display:table-cell;'><input
type='text' id='txt_value1_"+ n +"' name='txt_value1[]'></input></span>";
+ var el_4 = "<span style='display:table-cell;'><select
id='cbo_conector_"+ n +"' name='cbo_conector[]'>" + $(combo_conector).html() +
"</select></span>";
+ var el_5 = "<span style='display:table-cell;'><input
type='text' id='txt_value2_"+ n +"' name='txt_value2[]'></input></span>";
+ var el_6 = "<span style='display:table-cell;'><input
type='hidden' class='criteria' value='"+ n +"'><input type='button'
class='pure-button pure-button-primary' onclick='delete_restricted_value(this)'
name='btn_del' value='Delete'></input></span>";
+
+ var row = '<span style="display:table-row;">'+ el_1 + el_2 +
el_3 + el_4 + el_5 + el_6 +'</span>';
+ n ++;
+ $('#container_criteria').append(row);
+
+ });
});
+ var n = 0;
+
+function delete_restricted_value (e)
+{
+ $(e).parent().parent().remove();
+}
+
+function in_array_object (key_operator, array_object)
+{
+ var result = false;
+ $.each(array_object, function(key, value)
+ {
+ if (key == key_operator)
+ {
+ result = true;
+ return;
+ }
+ });
+
+ return result;
+}
+
+function validate_criteria (values)
+{
+ var result = true;
+ $.each(values.cbo_restricted_value, function(key, value)
+ {
+ if (values.cbo_operator[key] == "")
+ {
+ result = false;
+ alert('Select an operator for: ' + value);
+ $("#cbo_operator_" + key).focus();
+ return;
+ }
+ });
+
+ if (!result)
+ {
+ return result;
+ }
+
+ $.each(values.cbo_operator, function(key, value)
+ {
+ switch (true)
+ {
+ case (in_array_object(value, operators_between)):
+ if ($("#txt_value1_" + key).val() == '')
+ {
+ result = false;
+ alert('Enter a value for ' +
values.cbo_restricted_value[key]);
+ $("#txt_value1_" + key).focus();
+ }
+ if ($("#txt_value2_" + key).val() == '')
+ {
+ result = false;
+ alert('Enter a second value for: ' +
values.cbo_restricted_value[key]);
+ $("#txt_value2_" + key).focus();
+ }
+ break;
+ case (in_array_object(value, operators_null)):
+ break;
+ default:
+ if ($("#txt_value1_" + key).val() == '')
+ {
+ result = false;
+ alert('Enter a value for: ' +
values.cbo_restricted_value[key]);
+ $("#txt_value1_" + key).focus();
+ }
+ }
+ });
+
+ return result;
+}
+
function set_values()
{
$.each(jsonB.columns, function(key, value)
@@ -158,18 +306,18 @@
{
$("#cbo_" + key).val(value);
});
-}
-
-function build_check_columns(data)
-{
- $.each(data, function(key, object)
+
+ $.each(jsonB.criteria, function(key, value)
{
- var combo = build_list_aggregates(object.name, object.type);
- //var text = build_text_aggregates(object.name);
- var check = build_check_aggregates(object.name);
- var el_1 = '<span style="display:table-row;">'+ check + combo +
'</span>';
- $('#container_aggregates').append(el_1);
- });
+ $('#btn_add_restricted_value').click();
+
+ $("#cbo_restricted_value_" + key).val(value.field);
+ $("#cbo_operator_" + key).val(value.operator);
+ $("#txt_value1_" + key).val(value.value1);
+ $("#cbo_conector_" + key).val(value.conector);
+ $("#txt_value2_" + key).val(value.value2);
+ });
+
}
function build_check_groups(name, type)
@@ -182,7 +330,6 @@
$('#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);
@@ -191,7 +338,7 @@
$("#g_" + name).parent().remove();
$("#o_" + name).parent().remove();
$("#cbo_" + name).parent().parent().remove();
- }
+ }
}
function build_check_aggregates(name)
@@ -212,11 +359,6 @@
return "<span style='display:table-cell;'><select disabled='true'
id='cbo_" + name + "' name='cbo_aggregate["+ name +"]'>" + $(combo).html() +
"</select></span>";
}
-function build_text_aggregates(name)
-{
- return "<span style='display:table-cell;'>As <input disabled='true'
data-validation='required' type='text' id='txt_" + name + "'
name='txt_aggregate["+ name +"]'/></span>";
-}
-
function enabled_disabled_aggregates(name)
{
if ($("#a_" + name).is(":checked"))
Modified: branches/Version-2_0-branch/property/templates/base/report.xsl
===================================================================
--- branches/Version-2_0-branch/property/templates/base/report.xsl
2017-05-27 18:56:31 UTC (rev 16788)
+++ branches/Version-2_0-branch/property/templates/base/report.xsl
2017-05-29 11:34:35 UTC (rev 16789)
@@ -78,7 +78,34 @@
var jsonB = {};
<xsl:if test="report_definition != ''">
jsonB = <xsl:value-of select="report_definition"/>;
- </xsl:if>
+ </xsl:if>
+ var operators = {};
+ <xsl:if test="operators != ''">
+ operators = <xsl:value-of select="operators"/>;
+ </xsl:if>
+
+ var operators_equal = {};
+ <xsl:if test="operators_equal != ''">
+ operators_equal = <xsl:value-of
select="operators_equal"/>;
+ </xsl:if>
+ var operators_between = {};
+ <xsl:if test="operators_between != ''">
+ operators_between = <xsl:value-of
select="operators_between"/>;
+ </xsl:if>
+ var operators_like = {};
+ <xsl:if test="operators_like != ''">
+ operators_like = <xsl:value-of
select="operators_like"/>;
+ </xsl:if>
+ var operators_in = {};
+ <xsl:if test="operators_in != ''">
+ operators_in = <xsl:value-of select="operators_in"/>;
+ </xsl:if>
+ var operators_null = {};
+ <xsl:if test="operators_null != ''">
+ operators_null = <xsl:value-of
select="operators_null"/>;
+ </xsl:if>
+
+ var columns = {};
</script>
<style type="text/css">
@@ -126,6 +153,7 @@
<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-criteria"><xsl:value-of select="php:function('lang',
'Criteria')"/></a></li>
<li><a
href="#tab-preview"><xsl:value-of select="php:function('lang',
'Preview')"/></a></li>
</ul>
<div id="tab-columns">
@@ -159,7 +187,17 @@
</label>
<div
id="container_aggregates" class="pure-custom"></div>
</div>
- </div>
+ </div>
+ <div id="tab-criteria">
+ <div
class="pure-control-group">
+ <input
type="button" class="pure-button pure-button-primary"
name="btn_add_restricted_value" id="btn_add_restricted_value">
+
<xsl:attribute name="value">
+
<xsl:value-of select="php:function('lang', 'add')" />
+
</xsl:attribute>
+ </input>
+ <div
id="container_criteria" class="pure-custom"></div>
+ </div>
+ </div>
<div id="tab-preview">
<div
class="pure-control-group">
<label>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16789] Stable: Merge 16784:16788 from trunk,
sigurdne <=