CGI-OptimalQuery

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

            my ($rec) = @_; 
            return "<button onclick=\"OQopwin('/ViewRecord?id=$$rec{U_ID};on_update=OQrefresh';\">".
                   "view</button>"; 
          }

    OQdocBottom => "bottom of the document (outside form)"
    OQdocTop => "top of the doc (outside form)"
    OQformBottom => "bottom of form"
    OQformTop => "top of form"
    usePopups => 1|0
        use popups when opening a record form using the built in buttons The
        default is 1. If this is set to 1, useAjax default is 1.

    WindowHeight => INT
    WindowWidth => INT
        Specify popup window width, height.

    OQscript => " some javascript code (see examples below) "
        OQscript gives you unlimited power to alter the output of optimal
        query by allowing you to enter javascript code that is executed
        client side For example to add a new command button:

          OQscript => "
        var e = document.getElementById('OQcmds');
        e.innerHTML = '".CGI::OptimalQuery::escape_js(q|<button type=button onclick="window.alert('hello there');">hello</button>|)."' + e.innerHTML;

lib/CGI/OptimalQuery.pm  view on Meta::CPAN

=item B<< OQdocBottom => "bottom of the document (outside form)" >>

=item B<< OQdocTop => "top of the doc (outside form)" >>

=item B<< OQformBottom => "bottom of form" >>

=item B<< OQformTop => "top of form" >>

=item B<< usePopups => 1|0 >>

use popups when opening a record form using the built in buttons The default is 1. If this is set to 1, useAjax default is 1.

=item B<< WindowHeight => INT >>

=item B<< WindowWidth => INT >>

Specify popup window width, height.


=item B<< OQscript => " some javascript code (see examples below) " >>

OQscript gives you unlimited power to alter the output of optimal query by allowing you to enter javascript code that is executed client side
For example to add a new command button:

  OQscript => "
var e = document.getElementById('OQcmds');
e.innerHTML = '".CGI::OptimalQuery::escape_js(q|<button type=button onclick="window.alert('hello there');">hello</button>|)."' + e.innerHTML; 

lib/CGI/OptimalQuery/InteractiveFilter.pm  view on Meta::CPAN

                      ||  $q->param($pnam.'ISVAL') );

    return
        $q->button( -name=>$pnam.'BTN',
                    -label=>$isUserVal?'value:':'column:',
                    -onClick=>"toggle_value('$pnam');",
                    -class=>'colvalbtn')
        . $q->hidden( -name=>$pnam.'ISVAL', -default=>$isUserVal )
        . $q->textfield( -name=>$pnam.'VALUE',
                         -class=> ( $isUserVal ? 'val' : 'hide' ) )
        . $q->popup_menu( -name=>$pnam.'COLMN',
                          -values=> $vals, -labels=> $lbls,
                          -onChange=>"submit_act('refresh');",
                          -class=> $isUserVal ? 'hide' : 'col');

}

# ------------------------- recreateFilterString -------------------------
sub recreateFilterString {
    my $o = shift;
    my $q = $$o{q};

lib/CGI/OptimalQuery/InteractiveFilter.pm  view on Meta::CPAN

    my $thing_to_focus_on;

    for( my $findx = 1; $findx <= $q->param('FINDX'); $findx++ ) {
	$pnp = 'F' . $findx . '_';
	$html .= '<TR><TD class="lp_col">'
	    . $q->button ( -name=>$pnp.'L_PARBTN', -label=>'(',
			   -onClick=>"toggle_paren('$pnp"."L_');",
			   -class=> $hideParen
			   ? 'hide' : ( $q->param($pnp.'L_PAREN') > 0
					? 'hide' : 'noparen' ) )
	    . $q->popup_menu
	        ( -name=>$pnp.'L_PAREN', -values=>[0 .. 3], -default=>'0',
		  -labels=>{'0'=>'','1'=>'(','2'=>'((','3'=>'((('},
		  -onChange=>"update_paren_vis('$pnp"."L_');",
		  -class=>$q->param($pnp.'L_PAREN')<1 ?'hide':'paren' )
	    . '</TD>';

	if( defined $q->param($pnp.'FUNCT') ) {
	    my $func_nam = $q->param($pnp.'FUNCT');
	    $func_nam =~ s/\(\)//;

            # if a predefined named filter
            if (ref($o->{schema}->{'named_filters'}{$func_nam}) eq 'ARRAY') {
    	      $html .= '<TD class="f_col" colspan=3>'
	  	  . $q->popup_menu( -name=>$pnp.'FUNCT',
		  		    -values=> \ @functionLOV,
				    -labels=> \ %functionLBL,
				    -default=> $q->param($pnp.'FUNCT'),
				    -onChange=>"submit_act('refresh');" ) ;
	      $html .= '</TD>';
            }
            
            # if named filter has an html generator
            elsif (exists $o->{schema}->{'named_filters'}{$func_nam}{html_generator}) {
    	      $html .= '<TD class="f_col" colspan=3>'
	  	  . $q->popup_menu( -name=>$pnp.'FUNCT',
		  		    -values=> \ @functionLOV,
				    -labels=> \ %functionLBL,
				    -default=> $q->param($pnp.'FUNCT'),
				    -onChange=>"submit_act('refresh');" ) ;
	      $html .=
		$o->{schema}->{'named_filters'}{$func_nam}{'html_generator'}->($q, $pnp.'ARG_');
	      $html .= '</TD>';
            } 

            # else if named filter does not have a html_generator 

lib/CGI/OptimalQuery/InteractiveFilter.pm  view on Meta::CPAN


              my $rv = $o->{schema}->{'named_filters'}{$func_nam}{'sql_generator'}->(%args);
	      $html .= "<div class=RO_NAMED_FILTER>".$o->escape_html($$rv[2])."</div></TD>";
            }
        }

	else {
	    $html .= '<TD class="l_col">'
		. &cmp_val($q, $pnp.'L_', \ @columnLOV, \ %columnLBL)
		. '</TD><TD class="c_col">'
		. $q->popup_menu ( 
                    -name=>$pnp.'CMPOP', -values=> cmpopLOV(), -class=>'cmpop')
		. '</TD><TD class="r_col">'
		. &cmp_val($q, $pnp.'R_', \ @columnLOV, \ %columnLBL )
		. '</TD>';
	}

	$html .= '<TD class="rp_col">'
	    . $q->popup_menu ( -name=>$pnp.'R_PAREN',
			       -values=>[0 .. 3], -default=>'0',
			       -labels=>
			         {'0'=>'', '1'=>')', '2'=>'))', '3'=>')))'},
			       -onChange=>"update_paren_vis('$pnp"."R_');",
			       -class=> ( $q->param($pnp.'R_PAREN')<1
					  ? 'hide' : 'paren' ) )
	    . $q->button ( -name=>$pnp.'R_PARBTN', -label=>')',
			   -onClick=>"toggle_paren('$pnp"."R_');",
			   -class=> $hideParen 
			   ? 'hide'
			   : ( $q->param($pnp.'R_PAREN')>0
			       ? 'hide' : 'noparen') )
	    . '</TD><TD class="d_col">'
	    . $q->checkbox ( -name=>$pnp.'DELME', -label=>'remove',
			     -value=>'1', -checked=>0, -override=>1,
			     -onClick=>'show_submit_del();',
			     -class=>'delbox' )
	    . "</TD></TR>\n<TR><TD colspan=5 align=center>"
	    . $q->popup_menu ( -name=>$pnp.'ANDOR', -values=> \ @andorLOV,
			       -class=>$findx == $q->param('FINDX')?'hide':'')
	    . "</TD></TR>\n" ;

    }

    
    $html .= '<TR><TD colspan=5><HR width="90%" /></TD><TD class="d_col">'
	. $q->checkbox ( -name=>'CHECKALL', -label=>'ALL', -value=>'1',
			 -checked=>0, -override=>1,
			 -onClick=>'checkall_delme();',

lib/CGI/OptimalQuery/InteractiveFilter.pm  view on Meta::CPAN

                                       -labels=> \ %columnLBL ) );
    if (@functionLOV) {
      push @sel_opts, $q->optgroup ( -name=>'Named Filters:',
                                     -values=> \ @functionLOV ,
                                     -labels=> \ %functionLBL );
    }

    $html .= "</TABLE>\n"
	. '<DIV id="paren_warn" class="paren_match">( Parenthesis must be matching pairs )</DIV>'
	. '<SPAN id="submit_add" class="submit_ok">'
	. $q->popup_menu ( -name=>'NEXT_EXPR', 
			   -default=>'--- Choose Next Filter ---',
			   -override=>1,
			   -values=>\@sel_opts,
			   -onChange=>"submit();" )
	. '</SPAN><SPAN id="submit_text" class="submit_ok"> or '
	. $q->submit( -name=>'SUBMIT', -class=>'submit_ok' )
	. "</SPAN> "
	. $q->end_form()
	. "\n</center>
<script type='text/javascript'>



( run in 1.412 second using v1.01-cache-2.11-cpan-364913b4093 )