Exemplo n.º 1
0
 /**
  * Go get FETCH values from other tables
  *
  */
 function fetch()
 {
     // Get the list of columns from the dd
     $column_id = gp('column');
     $table_id = $this->dd['table_id'];
     $table_id_fko = $this->dd['flat'][$column_id]['table_id_fko'];
     $match = $table_id . '_' . $table_id_fko . '_';
     $collist = $this->dd['FETCHDIST'][$match];
     // Build the SQL to fetch the row
     $colsc = array();
     $colsp = array();
     foreach ($collist as $idx => $info) {
         $colsp[] = $info['column_id_par'] . ' as ' . $info['column_id'];
     }
     $type_id = $this->dd['flat'][$column_id]['type_id'];
     $value = SQL_Format($type_id, gp('value'));
     $sql = "SELECT " . implode(',', $colsp) . "  FROM " . ddTable_idResolve($table_id_fko) . " WHERE " . $this->dd['fk_parents'][$table_id_fko]['cols_par'] . "= {$value}";
     $answer = SQL_OneRow($sql);
     x4Data('fetch', $answer);
 }
Exemplo n.º 2
0
 /**
  *  Generates an x3 HTML page requesting input from the
  *  user.  No parameters, accesses the object's yamlP2 property.
  *
  *  @access private
  */
 private function x3HTML()
 {
     $x6 = vgfGet('x6', false);
     $yamlP2 = $this->yamlP2;
     if (isset($yamlP2['options']['title'])) {
         # This is for classic x2 displays
         $this->PageSubtitle = $yamlP2['options']['title'];
     }
     # There are few tweaks based on x4/x_table2 version
     $x4 = gp('x4Page') == '' ? false : true;
     # Create top-level div, x4 library is looking for this
     # and x2 library will ignore it.
     $top = html('div');
     $top->hp['id'] = 'x4Top';
     $top->autoFormat(true);
     if ($x6) {
         $top->hp['id'] = 'x4Top';
         $top->addClass('fadein');
         $top->hp['x6plugin'] = 'androPage';
         jqDocReady("var plugin = x6.byId('x4Top');");
         jqDocReady("x6plugins.androPage(plugin,'x4Top','*');");
     }
     # Hidden variables so posts will come back here
     if ($x4) {
         x4Data('return', 'menu');
         $h = $top->h('input');
         $h->hp['id'] = 'x4Page';
         $h->hp['type'] = 'hidden';
         $h->hp['value'] = $this->page;
     } else {
         hidden('gp_page', $this->page);
     }
     # List of ids for buttons below
     if ($yamlP2['template'] == '') {
         $ids = array('pdf' => 'printNow', 'onscreen' => 'showOnScreen', 'showSql' => 'showSql', 'csv' => 'csvExport');
     } else {
         $ids = array('smarty' => 'RunReport');
     }
     $x4D = html('div', $top);
     if ($x4) {
         $x4D->addClass('x4Pane');
     }
     $x4D->addClass('x4AndroPage');
     # Triggers all browser-side x4 stuff
     $x4D->hp['id'] = 'x4AndroPage';
     $x4D->ap['defaultOutput'] = a($ids, a($yamlP2['options'], 'default'));
     # Put out the title and the help link
     $tabx = html('table', $x4D);
     $tabx->addClass('tab100');
     $tabxtr = html('tr', $tabx);
     $td = html('td', $tabxtr);
     $td->hp['style'] = "text-align: left; vertical-align: top";
     $h1 = html('h1', $td, $this->PageSubtitle);
     $h1->hp['id'] = 'x4H1Top';
     $td = html('td', $tabxtr);
     $td->hp['style'] = "text-align: right; vertical-align: top;\n        padding-top: 8px; font-size: 120%";
     #if($x4) {
     #$a = html('a-void',$td,"F1:Help");
     #$a->hp['onclick'] = "$('#x4AndroPage')[0].help()";
     #$a->addClass('button');
     #}
     # Make top level container
     $tabtop = html('table', $x4D);
     $tr = html('tr', $tabtop);
     $td1 = html('td', $tr);
     $td1->hp['style'] = 'vertical-align: top';
     $td2 = html('td', $tr);
     $td2->hp['style'] = 'vertical-align: top';
     # Do right-hand side first actually, the on-screen display area
     $div = html('div', $td2);
     $div->hp['id'] = 'divOnScreen';
     # Put out the inputs
     if (!$x6) {
         $table = html('table', $td1);
     } else {
         $form = $td1->form();
         $table = $form->h('table');
         $table->addClass('x6Detail');
         $table->hp['style'] = 'float: left';
     }
     $filters = ArraySafe($this->yamlP2, 'uifilter', array());
     foreach ($filters as $id => $options) {
         if (isset($options['table'])) {
             $dd = ddTable($options['table']);
             $opt2 = $dd['flat'][$options['column']];
             $options = array_merge($opt2, $options);
         } else {
             $options['inputId'] = 'ap_' . $id;
         }
         if (isset($options['value']) && gp('ap_' . $id) == '') {
             $options['value'] = $options['value'];
         } else {
             $options['value'] = gp('ap_' . $id);
         }
         $type_id = a($options, 'cotype_id', 'vchar');
         $tr = html('tr', $table);
         $td = html('td', $tr);
         if ($x6) {
             $td->addClass('x6Caption');
         } else {
             $td->hp['style'] = "text-align: right";
         }
         $td->setHTML($options['description']);
         $td = html('td', $tr);
         if ($x6) {
             $td->addClass('x6Input');
         } else {
             $td->hp['style'] = "text-align: left";
         }
         $input = input($options);
         $input->hp['autocomplete'] = 'off';
         if ($x6) {
             $input->hp['xNoPassup'] = 'Y';
         }
         $td->setHTML($input->bufferedRender());
     }
     $h = $top->h('input');
     $h->hp['type'] = 'hidden';
     $h->hp['id'] = 'gp_post';
     $h->hp['name'] = 'gp_post';
     if (isset($yamlP2['template'])) {
         $h->hp['value'] = 'smarty';
     } else {
         $h->hp['value'] = 'pdf';
     }
     $td1->br();
     // DO 7/31/2008 Only need a button to run the report for Smarty AndroPage
     if ($this->yamlP2['template'] == '') {
         # First button: print
         $inp = html('a-void', $td1, '<u>P</u>rint Now');
         $inp->ap['xLabel'] = 'CtrlP';
         $inp->hp['id'] = $ids['pdf'];
         $inp->addClass('button');
         if ($x6) {
             $inp->hp['onclick'] = "x6events.fireEvent('key_CtrlP')";
         } elseif (gpExists('x4Page')) {
             $inp->hp['onclick'] = "\$a.byId('x4AndroPage').printNow()";
         } else {
             $inp->hp['onclick'] = 'formSubmit();';
         }
         $td1->br(2);
         # Second button: show onscreen
         $inp = html('a-void', $td1, 'Show <u>O</u>nscreen');
         $inp->hp['id'] = $ids['onscreen'];
         $inp->ap['xLabel'] = 'CtrlO';
         $inp->addClass('button');
         if ($x6) {
             $inp->hp['onclick'] = "x6events.fireEvent('key_CtrlO')";
         } elseif (gpExists('x4Page')) {
             $inp->hp['onclick'] = "\$a.byId('x4AndroPage').showOnScreen()";
         } else {
             $inp->hp['onclick'] = "SetAndPost('gp_post','onscreen')";
         }
         # KFD 9/20/08, new option: export to csv
         $td1->br(2);
         $inp = html('a-void', $td1, '<u>E</u>xport as CSV');
         $inp->hp['id'] = $ids['csv'];
         $inp->ap['xLabel'] = 'CtrlE';
         $inp->addClass('button');
         if ($x6) {
             $inp->hp['onclick'] = "x6events.fireEvent('key_CtrlE')";
         } else {
             if (gpExists('x4Page')) {
                 $inp->hp['onclick'] = "\$a.byId('x4AndroPage').csvExport()";
             } else {
                 $inp->hp['onclick'] = "SetAndPost('gp_post','csvexport')";
             }
         }
     } else {
         # First button: Run Report
         $inp = html('a-void', $td1, '<u>R</u>un Report');
         $inp->ap['xLabel'] = 'CtrlR';
         $inp->hp['id'] = $ids['smarty'];
         $inp->addClass('button');
         if (gpExists('x4Page')) {
             $inp->hp['onclick'] = "\$a.byId('x4AndroPage').showOnScreen()";
         } else {
             $inp->hp['onclick'] = 'formSubmit();';
         }
     }
     $td1->br(2);
     if (SessionGet('ADMIN') == true && $x4) {
         $x4D->nbsp(2);
         $inp = html('a-void', $td1, 'Show S<u>Q</u>L');
         $inp->ap['xLabel'] = 'CtrlQ';
         $inp->hp['id'] = $ids['showSql'];
         $inp->hp['name'] = 'showsql';
         // For x2
         $inp->addClass('button');
         if ($x6) {
             $inp->hp['onclick'] = "x6events.fireEvent('key_CtrlQ')";
         } else {
             $inp->hp['onclick'] = "\$a.byId('x4AndroPage').showSql()";
         }
     }
     # Put in the spot where we display the SQL
     $td1->br(2);
     $showSql = html('div', $td1);
     $showSql->hp['id'] = 'divShowSql';
     echo $top->render();
 }
Exemplo n.º 3
0
function x4sqlSel($table, $whr)
{
    $options = array();
    if (gp('ob') != '') {
        $options = array('ob', gp('ob'));
    }
    x4Data('rows', SQLX_Select($table, '', $options));
}