Select part of Query builder complete with rename and aggregate operators
This commit is contained in:
@@ -334,10 +334,52 @@ var rename = function(nrename_to) {
|
||||
var aggregate = function(noperator) {
|
||||
var operator;
|
||||
this.set_operator = function(noperator) {
|
||||
operator=noperator;
|
||||
operator = noperator;
|
||||
};
|
||||
this.get_operator = function() {
|
||||
return operator;
|
||||
};
|
||||
this.set_operator(noperator);
|
||||
};
|
||||
|
||||
function build_query() {
|
||||
var q_select = "SELECT ";
|
||||
var temp;
|
||||
for(i = 0;i < select_field.length; i++) {
|
||||
temp = check_aggregate(select_field[i]);
|
||||
if (temp != "") {
|
||||
q_select += temp;
|
||||
temp = check_rename(select_field[i]);
|
||||
q_select += temp + ",";
|
||||
}
|
||||
else {
|
||||
temp = check_rename(select_field[i]);
|
||||
q_select += select_field[i] + temp +",";
|
||||
}
|
||||
}
|
||||
q_select = q_select.substring(0,q_select.length - 1); //PDF_save()
|
||||
document.getElementById('hint').innerHTML = q_select;
|
||||
document.getElementById('hint').style.visibility = "visible";
|
||||
}
|
||||
|
||||
function check_aggregate(id_this) {
|
||||
var i = 0;
|
||||
for(i;i < history_array.length;i++) {
|
||||
var temp = '\'' + history_array[i].get_tab() + '\'.\'' +history_array[i].get_column_name() +'\'';
|
||||
if(temp == id_this && history_array[i].get_type() == "Aggregate") {
|
||||
return history_array[i].get_obj().get_operator() + '(' + id_this +')';
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function check_rename(id_this) {
|
||||
var i = 0;
|
||||
for (i;i < history_array.length;i++) {
|
||||
var temp = '\'' + history_array[i].get_tab() + '\'.\'' +history_array[i].get_column_name() +'\'';
|
||||
if(temp == id_this && history_array[i].get_type() == "Rename") {
|
||||
return " AS \'" + history_array[i].get_obj().getrename_to() +"\',";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
@@ -986,16 +986,27 @@ function Close_option()
|
||||
function Select_all(id_this,owner)
|
||||
{
|
||||
var parent= document.form1;
|
||||
var len = owner.length + 8;
|
||||
var i;
|
||||
for(i = 0; i < parent.elements.length; i++) {
|
||||
if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0,(7 + id_this.length)) == 'select_' + id_this) {
|
||||
if (parent.elements[i].type == "checkbox" && parent.elements[i].id.substring(0,(9 + id_this.length)) == 'select_' + id_this + '._') {
|
||||
if(document.getElementById('select_all_' + id_this).checked == true) {
|
||||
parent.elements[i].checked = true;
|
||||
store_column(parent.elements[i].id.substring(len),owner);
|
||||
parent.elements[i].disabled = true;
|
||||
var temp = '\'' + id_this.substring(owner.length +1) + '\'.*';
|
||||
}
|
||||
else {
|
||||
parent.elements[i].checked = false;
|
||||
store_column(parent.elements[i].id.substring(len),owner);
|
||||
parent.elements[i].disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(document.getElementById('select_all_' + id_this).checked == true) {
|
||||
select_field.push('\'' + id_this.substring(owner.length +1) + '\'.*');
|
||||
}
|
||||
else {
|
||||
for (i =0; i < select_field.length; i++) {
|
||||
if (select_field[i] == ('\'' + id_this.substring(owner.length +1) + '\'.*')) {
|
||||
select_field.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1018,14 +1029,14 @@ function Table_onover(id_this,val)
|
||||
* In case column is checked it add else it deletes
|
||||
*
|
||||
*/
|
||||
function store_column(id_this,owner) {
|
||||
function store_column(id_this,owner,col) {
|
||||
var i = 0;
|
||||
if (document.getElementById('select_' + owner + '.' + id_this).checked == true) {
|
||||
select_field.push(id_this);
|
||||
if (document.getElementById('select_' + owner + '.' + id_this + '._' + col).checked == true) {
|
||||
select_field.push('\'' + id_this + '\'.\'' + col +'\'');
|
||||
}
|
||||
else {
|
||||
for(i; i < select_field.length ;i++) {
|
||||
if ( select_field[i] == id_this ) {
|
||||
if (select_field[i] == ('\'' + id_this + '\'.\'' + col +'\'')) {
|
||||
select_field.splice(i,1);
|
||||
break;
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ echo $script_tabs . $script_contr . $script_display_field;
|
||||
class="M_butt" target="_self"
|
||||
><img title="<?php echo __('Toggle small/big'); ?>" alt="key" src="pmd/images/bottom.png"
|
||||
/></a><img class="M_bord" src="pmd/images/bord.png" alt=""
|
||||
/><a href="javascript:PDF_save();" onmousedown="return false;"
|
||||
/><a href="javascript:build_query()" onmousedown="return false;"
|
||||
class="M_butt" target="_self"
|
||||
><img src="pmd/images/pdf.png" alt="key" width="20" height="20"
|
||||
title="<?php echo __('Import/Export coordinates for PDF schema'); ?>" /></a>
|
||||
@@ -272,9 +272,9 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
if(isset($_REQUEST['query'])) {
|
||||
echo '<td class="select_all">';
|
||||
echo '<input value="'.htmlspecialchars($t_n_url).urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'"';
|
||||
echo 'type="checkbox" id="select_'.htmlspecialchars($t_n_url).'.'.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'" ';
|
||||
echo 'type="checkbox" id="select_'.htmlspecialchars($t_n_url).'._'.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'" ';
|
||||
echo 'style="margin: 0px;" title="select_'.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'" ';
|
||||
echo 'onclick="store_column(\''.urlencode($GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i]).'.'.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'\',\''.htmlspecialchars($GLOBALS['PMD_OUT']["OWNER"][$i]).'\')"></td>';
|
||||
echo 'onclick="store_column(\''.urlencode($GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i]).'\',\''.htmlspecialchars($GLOBALS['PMD_OUT']["OWNER"][$i]).'\',\''.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'\')"></td>';
|
||||
}?>
|
||||
<td width="10px" colspan="3"
|
||||
id="<?php echo $t_n_url.".".urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]) ?>">
|
||||
@@ -311,10 +311,10 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
|
||||
</td>
|
||||
<?php
|
||||
if(isset($_REQUEST['query'])) {
|
||||
$temp = $GLOBALS['PMD_OUT']["OWNER"][$i].'.'.$GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i];
|
||||
//$temp = $GLOBALS['PMD_OUT']["OWNER"][$i].'.'.$GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i];
|
||||
echo '<td class="small_tab_pref" onmouseover="this.className=\'small_tab_pref2\';"';
|
||||
echo 'onmouseout="this.className=\'small_tab_pref\';"';
|
||||
echo 'onclick="Click_option(\'pmd_optionse\',\''.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'\',\''.$temp.'\')" >';
|
||||
echo 'onclick="Click_option(\'pmd_optionse\',\''.urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]).'\',\''.$GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i].'\')" >';
|
||||
echo '<img src="pmd/images/exec_small.png" title="options" alt="" /></td> ';
|
||||
} ?>
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user