Ejemplo n.º 1
0
    function hDisplayOnscreen($filters = array(), &$parent_row)
    {
        $parent_pks = $filters;
        // capture for later reference
        //hprint_r($filters);
        // Pull the rows so we know how many we have
        if (count($filters) != 0) {
            //$filters=ConSet('table',$this->table_id,'search',$filters);
            processPost_TableSearchResultsClear($this->table_id);
        }
        $rows = rowsFromUserSearch($this->table, $this->projections['_uisearch'], $filters, true);
        $early_return = $this->hDisplayOnscreenOverride($rows, $filters, $parent_row);
        if ($early_return != '') {
            return $early_return;
        }
        // Pull the nav bar.  Do this after pulling rows so we
        // know how many rows there are, what page we're on, etc.
        $hNavBar = $this->hBrowse_NavBar();
        // Generate the table header
        $cols1 = asliceValsFromKeys($this->table['flat'], 'description', $this->projections['_uisearch']);
        $cols2 = array('Edit');
        if (DDUserPerm($this->table_id, 'del')) {
            $cols2[] = 'Delete';
        }
        $cols = array_merge($cols1, $cols2);
        if (count($rows) == 0) {
            $hContent = "<tr><td colspan=99 class=\"dlite\">" . "<b>There are no records to display</b>" . "</td></tr>\n";
        } else {
            // Convert last column to hyperlink to that page/row
            foreach ($rows as $index => $row) {
                $slipin1 = hLinkPostFromArray('', 'Edit', array('gp_dd_page' => $this->table_id, 'gp_skey' => $row['skey'], 'gp_mode' => 'upd'));
                //$slipin1=array('_edit'=>$slipin);
                $slipin2 = '';
                if (DDUserPerm($this->table_id, 'del')) {
                    $slipin2 = hLinkPostFromArray('', 'Delete', array('gp_delskey_' . $this->table_id => $row['skey'], 'gp_mode' => 'upd', 'gp_skey' => gp('gp_skey')));
                }
                //$slipin=array('_del'=>$slipin);
                // Get the formatted value
                foreach ($row as $colname => $colvalue) {
                    $value = hFormat($this->table['flat'][$colname]['type_id'], $colvalue);
                    $rows[$index][$colname] = $value;
                }
                if (isset($row['skey'])) {
                    unset($rows[$index]['skey']);
                }
                $rows[$index][] = $slipin1;
                $rows[$index][] = $slipin2;
                //$rows[$index]=array_merge($rows[$index],$slipin);
            }
            $hContent = hTBodyFromRows('', $rows);
        }
        // Add an empty row for inserting
        $empty_row = '';
        $table_id = $this->table['table_id'];
        /*
        foreach($cols1 as $column=>$description){
           $value = '';
           $name_id = 'gp_onscreen_'.$table_id.'_'.$column.'';
           $iname   = 'name="'.$name_id.'" '.'id="'.$name_id.'"';
           $value   = '<input type="text" '.$iname.'></input>';
           $empty_row  .= hTD('',$value,'');
        }
        */
        $empty_row = '';
        $parent_skey = $parent_row['skey'];
        $pkcols = explode(',', $this->table['pks']);
        // KFD 1/11/07, unconditionally copied in all values supplied
        // from parent.
        foreach ($pkcols as $pkcol) {
            if (!isset($parent_row[$pkcol])) {
                continue;
            }
            $prefilled[$pkcol] = $parent_row[$pkcol];
        }
        $prefilled = $parent_pks;
        //hprint_r($prefilled);
        $opts = array('drilldownmatches' => $prefilled, 'name_prefix' => 'gp_onscreen_' . $table_id . '_', 'hpsize' => 12);
        // KFD 5/29/07, refactoring code to use new widget generation
        //   routines, no more ahInputsComprehensive.
        //$inputs = ahInputsComprehensive($this->table,'ins',$prefilled,'_uisearch',$opts);
        //foreach($inputs as $column=>$details){
        //   $empty_row  .= hTD('',$details['html'],'');
        //}
        $acols = aColsModeProj($this->table, 'ins', '_uisearch');
        $ahcols = aHColsfromACols($acols, $prefilled);
        $name_prefix = 'gp_onscreen_' . $table_id . '_';
        $xh = hDetailFromAHCols($ahcols, $name_prefix, 500, 'tds');
        $xh = jsValues($ahcols, $name_prefix, $prefilled, $xh);
        $empty_row .= $xh;
        // END OF CHANGES 5/29/07 code refactoring
        //hprint_r(htmlentities($empty_row));
        // Add a save link
        hidden('gp_child_onscreen', '');
        $name_id = 'onscreen_save';
        $iname = 'name="' . $name_id . '" ' . 'id="' . $name_id . '"';
        $value = '<a tabindex="' . hpTabIndexNext(500) . '" href="' . "javascript:SetAction('gp_skey',{$parent_skey},'gp_child_onscreen','{$table_id}')" . '">Save</a>';
        $empty_row .= hTD('', $value, '');
        // Add a <tr></tr>
        $empty_row = '<tr>' . $empty_row . '</tr>';
        // Attatch the empty row
        $hContent .= $empty_row;
        $hNew = hLinkPostFromArray('', $this->table['description'], array('gp_dd_page' => $this->table_id));
        //$hDsc="<span class=\"x2menubar_text\">"
        //   .$this->table['description']
        //   .'</span>';
        ob_start();
        ?>
      <br>
      <br>
      <div class="x2menubar" style="text-align: left">
        <?php 
        echo $hNew;
        ?>
      </div>
      <div class="andro_space2"></div>
		<fieldset>
			<?php 
        echo hTRFromArray('dhead', $cols);
        ?>
			<?php 
        echo $hContent;
        ?>
			<tr>
				<td colspan=99 class='dhead'>&nbsp;
				</td>
			</tr>
		</fieldset>
      <?php 
        return ob_get_clean();
    }
Ejemplo n.º 2
0
function processPost_Textboxes($row)
{
    $gp_action = gp('gp_action');
    $gp_mode = gp('gpx_mode');
    $gp_skey = gp('gpx_skey');
    $table_id = gp('gpx_page');
    $table = DD_TableREf($table_id);
    // Cache flags.  This was introduced for Worldcare 5/22/06.
    // For worldcare the setting is made in applib, it is not set
    // anywhere in the data dictionary.  The idea is that a table
    // that is 'cache_table_pk' gets each row cached by the pk.  Perhaps
    // also we would have 'cache_table' for things like states, where
    // the entire table is cached.
    //
    $user_pref = $table_id == vgaGet('user_preferences') ? true : false;
    // Deletion is pretty simple
    if ($gp_action == 'del') {
        $view_id = DDTable_IDResolve($table_id);
        $sq = "DELETE FROM {$view_id} where skey={$gp_skey}";
        SQL($sq);
        processPost_TableSearchResultsClear($table_id);
        return;
        // <<<<<<<<<< RETURN
    }
    // Saving an insert requires an explicit command
    if ($gp_action == 'save' && $gp_mode == 'ins') {
        // KFD 6/15/07, remove blanks from an insert.
        foreach ($row as $key => $value) {
            if (trim($value == '')) {
                unset($row[$key]);
            }
        }
        $skey = SQLX_Insert($table, $row);
        if (Errors()) {
            // ERRORROW CHANGE 5/30/07, moved to SQLX_* routines
            //vgfSet('ErrorRow',$row);
        } else {
            if ($user_pref) {
                UserPrefsLoad();
            }
            processPost_TableSearchResultsClear($table_id);
            // If there was a page set to return to, do that now
            if (SessionGet('gp_aftersave', '') != '') {
                gpSet('gp_page', SessionGet('gp_aftersave'));
                $rowx = SQL_OneRow("Select * from {$table_id} where skey={$skey}");
                SessionSet("ROW_" . strtoupper($table_id), $rowx);
            }
        }
        return;
        // <<<<<<<<<< RETURN
    }
    // If the old mode was search, then set the new search criteria
    if ($gp_mode == 'search') {
        ConSet('table', $table_id, 'search', $row);
        processPost_TableSearchResultsClear($table_id);
        return;
        // <<<<<<<<<< RETURN
    }
    // Finally, if the old mode was view (update), then look for
    // changed values and figure out if we need to do an update
    if ($gp_mode == 'upd') {
        //echo "i am trying to update, here are old controls: ";
        $controls = ContextGet('OldRow', array());
        //html_vardump($controls);
        $changed = array();
        $errrow = $controls;
        foreach ($controls as $colname => $colvalue) {
            $value = null;
            if (!isset($row[$colname])) {
                // tough call. If did not come back, assume an
                // unchecked check box.
                if ($colvalue == 'Y') {
                    $changed[$colname] = 'N';
                }
            } else {
                // KFD 6/27/07, allow explicit force save of all values
                if (gpExists('gp_forcesave') || trim($colvalue) !== trim($row[$colname])) {
                    $changed[$colname] = $row[$colname];
                    $errrow[$colname] = $row[$colname];
                }
            }
        }
        if (count($changed) > 0) {
            $changed['skey'] = $gp_skey;
            $table = DD_TableRef($table_id);
            #hprint_r($changed);
            SQLX_Update($table, $changed, $errrow);
            if (Errors()) {
                // ERRORROW CHANGE 5/30/07, moved to SQLX_* routines
                //vgfSet('ErrorRow',$row);
            } else {
                if ($user_pref) {
                    UserPrefsLoad();
                }
                /*
                if($cache_pk<>'') {
                    DynFromA($cache_pk,$row);
                    if ($reload_user) {
                      $up=SQL_OneRow(
                         "Select * from $table_id WHERE user_id='".$row['user_id']."'"
                      );
                      vgaSet('this_user_prefs',$up);
                    }
                }
                */
            }
        }
        //html_vardump($row);
        //html_vardump($controls);
        //html_vardump($changed);
        return;
        // <<<<<<<<<< RETURN
    }
}
Ejemplo n.º 3
0
function index_hidden_page()
{
    global $AG;
    $sessok = !LoggedIn() ? false : true;
    // KFD 3/6/08, moved here from the main stream of index_hidden
    //             because these are relevant only to page processing
    if (gpExists('x_module')) {
        SessionSet('AGMENU_MODULE', gp('x_module'));
    } elseif (vgaGet('nomodule') != '' && SessionGet('AGMENU_MODULE') == '') {
        SessionSet('AGMENU_MODULE', vgaGet('nomodule'));
    }
    // If the search flag is set, we need to know what class for this
    // application handles searchs
    if (gpExists('gp_search')) {
        gpSet('gp_page', vgaGet('SEARCH_CLASS'));
    }
    // Load up a list of pages that public users are allowed to see,
    // with home and password always there.
    global $MPPages;
    // allows it to be in applib
    $MP = array();
    //$MPPages= array();
    // This is the old method, load $MPPages from its own file
    if (file_exists_incpath('appPublicMenu.php')) {
        include_once 'appPublicMenu.php';
    }
    if (!is_array($MPPages)) {
        $MPPages = array();
    }
    $MPPages['x_home'] = 'Home Page';
    $MPPages['x_login'] = '******';
    $MPPages['x_noauth'] = 'Authorization Required';
    $MPPages['x_password'] = "******";
    $MPPages['x_mpassword'] = "******";
    $MPPages['x_paypalipn'] = 'Paypal IPN';
    // If the install page exists, it will be used, no getting
    // around it.
    $install = $GLOBALS['AG']['dirs']['application'] . 'install.php';
    $instal2 = $GLOBALS['AG']['dirs']['application'] . 'install.done.php';
    if (file_exists($install)) {
        if (gp('gp_install') == 'finish') {
            rename($install, $instal2);
        } else {
            $MPPages['install'] = 'install';
            gpSet('gp_page', 'install');
        }
    }
    // First pass is to look for the "flaglogin" flag.  This says save all
    // current page settings and go to login screen.  They will be restored
    // on a successful login.  Very useful for links that say "Login to
    // see nifty stuff..."
    if (gp('gp_flaglogin') == '1') {
        gpSet('gp_flaglogin', '');
        gpToSession();
        gpSet('gp_page', 'x_login');
    }
    // Second pass redirection, pick default page if there
    // is none, and verify public pages.
    //
    $gp_page = gp('gp_page');
    if ($gp_page == '') {
        if (vgfGet('LoginAttemptOK') === true && vgfGet('x4') === true) {
            $gp_page = 'x4init';
            gpSet('gp_page', 'x4init');
            SessionSet('TEMPLATE', 'x4');
        } else {
            if (function_exists('appNoPage')) {
                $gp_page = appNoPage();
            } else {
                if (!LoggedIn()) {
                    $gp_page = FILE_EXISTS_INCPATH('x_home.php') ? 'x_home' : 'x_login';
                } else {
                    // KFD 3/2/07, pull vga stuff to figure defaults
                    if (vgaGet('nopage') != '') {
                        $gp_page = vgaGet('nopage');
                    } else {
                        $gp_page = 'x_welcome';
                    }
                }
            }
        }
    }
    // If they are trying to access a restricted page and are not
    // logged in, cache their request and redirect to login page
    if (!$sessok && !isset($MPPages[$gp_page])) {
        if (vgfGet('loglogins', false)) {
            fwLogEntry('1014', 'Page access w/o login', $gp_page);
        }
        gpToSession();
        $gp_page = 'x_login';
    }
    // If pos is activated and the current requested page does not
    // match what they are cleared for, redirect to login
    if (vgaGet('POS_SECURITY', false) == true && SessionGet('ADMIN') == false) {
        if (SessionGet('POS_PAGE', '', 'FW') != $gp_page) {
            gpToSession();
            $gp_page = 'x_login';
        }
    }
    gpSet('gp_page', $gp_page);
    // Make any database saves.  Do this universally, even if save
    // was not selected.  If errors, reset to previous request.
    //if(gp('gp_save')=='1') processPost();
    processPost();
    if (Errors()) {
        gpSetFromArray('gp_', aFromGp('gpx_'));
    }
    // Put Userid where HTML forms can find it
    //vgfSet("UID",SessionGet("UID"));
    //if (vgfSet("UID")=="") { vgfSet("UID","Not Logged In"); }
    // THIS IS NEWER X_TABLE2 version of drilldown commands,
    // considerably simpler than the older ones. It makes use of
    // three gp_dd variables.
    //
    // Notice how we process drillbacks FIRST, allowing a link
    // to contain both drillback and drilldown, for the super-nifty
    // effect of a "drill-across"
    hidden('gp_dd_page');
    hidden('gp_dd_skey');
    hidden('gp_dd_back');
    if (intval(gp('gp_dd_back')) > 0 && $sessok) {
        // this is drillback
        $dd = ContextGet('drilldown', array());
        $back = intval(gp('gp_dd_back'));
        if (count($dd) >= $back) {
            $spot = count($dd) - $back;
            $aback = $dd[$spot];
            gpSet('gp_skey', $aback['skey']);
            gpSet('gp_page', $aback['page']);
            $gp_page = $aback['page'];
            gpSet('gpx_skey', $aback['skey']);
            gpSet('gpx_page', $aback['page']);
            gpSetFromArray('parent_', $aback['parent']);
            if (!gpExists('gp_mode')) {
                gpSet('gp_mode', 'upd');
            }
            $dd = $spot == 0 ? array() : array_slice($dd, 0, $spot);
            ContextSet('drilldown', $dd);
            ContextSet('drilldown_top', $aback['page']);
            //ContextSet('drilldown_level',count($dd));
        }
    }
    if (gp('gp_dd_page') != '' && $sessok) {
        // this is drilldown...
        $matches = DrillDownMatches();
        $matches = array_merge($matches, aFromGP('parent_'));
        $dd = ContextGet('drilldown', array());
        $newdd = array('matches' => $matches, 'parent' => aFromGP('parent_'), 'skey' => gp('gpx_skey'), 'page' => gp('gpx_page'));
        $dd[] = $newdd;
        ContextSet('drilldown', $dd);
        ContextSet('drilldown_top', gp('gp_dd_page'));
        //ContextSet('drilldown_level',count($dd));
        // having saved the stack, redirect to new page.
        $tnew = gp('gp_dd_page');
        $gp_page = $tnew;
        gpSet('gp_page', $tnew);
        if (gp('gp_dd_skey') != '') {
            gpSet('gp_skey', gp('gp_dd_skey'));
            gpSet('gp_mode', 'upd');
        }
        // Clear search of new page, set filters to blank
        processPost_TableSearchResultsClear($tnew);
        ConSet('table', $tnew, 'search', array());
    }
    // If no drilldown commands were received, and we are not on
    // the page that is the top, user must have picked a new page
    // altogether, wipe out the drilldown stack
    if (gp('gp_page') != ContextGet('drilldown_top', '')) {
        ContextSet('drilldown', array());
        ContextSet('drilldown_top', '');
    }
    // Must always have these on the user's form.  These can
    // be retired with x_Table, they are for old drilldown
    //
    hidden("dd_page", "");
    hidden("dd_ddc", "");
    hidden("dd_ddv", "");
    hidden("dd_ddback", "");
    hidden("dd_action", "searchexecute");
    hidden("dd_skey", "");
    // Load user preferences just before display
    UserPrefsLoad();
    $dir = $GLOBALS['AG']['dirs']['root'] . 'application/';
    if (file_exists($dir . $gp_page . ".page.yaml")) {
        include 'androPage.php';
        $obj_page = new androPage();
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main($gp_page);
        if ($obj_page->flag_buffer) {
            vgfSet("HTML", ob_get_clean());
            //ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    } else {
        $obj_page = DispatchObject($gp_page);
        if ($obj_page->flag_buffer) {
            ob_start();
        }
        $obj_page->main();
        if ($obj_page->flag_buffer && vgfGet('HTML') == '') {
            vgfSet("HTML", ob_get_contents());
            ob_end_clean();
        }
        vgfSet("PageSubtitle", $obj_page->PageSubtitle);
    }
    // Save context onto the page.  Note that it is not really
    // protected by these methods, just compressed and obscured.
    //
    $t2 = serialize($GLOBALS['AG']['clean']['gpContext']);
    $t2 = gzcompress($t2);
    $t2 = base64_encode($t2);
    Hidden('gpContext', $t2);
    // KFD 3/7/07, give the app the final opportunity to process
    //             things before the display, while logged in.
    if (function_exists('appdisplaypre')) {
        appDisplayPre();
    }
    // ...and write output and we are done.  Assume if there was
    // no buffering that the output is already done.
    if ($obj_page->flag_buffer != false) {
        // Work out what template we are using
        index_hidden_template('x2');
        // KFD 5/30/07, send back only main content if asked
        if (gp('ajxBUFFER') == 1) {
            echo "andromeda_main_content|";
            ehStandardContent();
            echo "|-|_focus|" . vgfGet('HTML_focus');
            $ajax = ElementReturn('ajax', array());
            echo '|-|' . implode('|-|', $ajax);
            echo '|-|_title|' . vgfGet('PageTitle');
        } elseif (defined('_VALID_MOS')) {
            // This is the default branch, using a Joomla template
            // DUPLICATE ALERT: This code copied into
            //          index_hidden_x4Dispatch() above
            global $J;
            $mainframe = $J['mainframe'];
            $my = $J['my'];
            $mosConfig_absolute_path = $J['mC_absolute_path'];
            $mosConfig_live_site = $J['mC_live_site'];
            $template_color = $J['template_color'];
            $template_color = 'red';
            $file = $GLOBALS['AG']['dirs']['root'] . '/templates/' . $mainframe->GetTemplate() . "/index.php";
            include $file;
        } elseif ($obj_page->html_template !== '') {
            // This is newer style, let the class specify the template.
            include $obj_page->html_template . '.php';
        } else {
            // This is old style, defaults to "html_main.php", can be
            // set also by vgaSet() or by gp(gp_out)
            $html_main = vgaGet('html_main') == '' ? 'html_main' : vgaGet('html_main');
            switch (CleanGet("gp_out", "", false)) {
                case "print":
                    include "html_print.php";
                    break;
                case "info":
                    include "html_info.php";
                    break;
                case "":
                    include $html_main . ".php";
                    break;
                default:
            }
        }
    }
}