Ejemplo n.º 1
0
/**
* @deprecated
*/
function aColInfoFromDDColumns(&$table, &$retval)
{
    $perm_upd = DDUserPerm($table['table_id'], 'upd');
    // ----------------------------------------------
    // BIG DEAL A: Loop through each row
    // ----------------------------------------------
    foreach ($table['flat'] as $colname => $colinfo) {
        if (!isset($colinfo['uino'])) {
            # KFD 6/2/08, this line is required for some older programs
            # that SDS wrote that still use this family of routines.
            # Table constraints appear to be showing up as empty columns!
            if ($colname == '') {
                continue;
            }
            hprint_r("ERROR IN BUILD, PLEASE CONTACT SECURE DATA SOFTWARE");
            echo "Column {$colname}";
            hprint_r($colinfo);
            exit;
        }
        // Early return, if there is no UI, don't generate at all
        if ($colinfo['uino'] == 'Y') {
            continue;
        }
        // Clear out array
        $c = array();
        // Initialize a new array for the column, with some
        // basic info that is useful in all modes
        $c['base'] = array('type_id' => $colinfo['type_id'], 'formshort' => $colinfo['formshort'], 'column_id' => $colname, 'colprec' => $colinfo['colprec'], 'colscale' => $colinfo['colscale'], 'description' => $colinfo['description'], 'tooltip' => arraySafe($colinfo, 'tooltip'), 'pk_change' => ArraySafe($colinfo, 'pk_change', 'N'));
        $c['ins']['sequence'] = 0;
        $c['upd']['sequence'] = 0;
        // Load in any default snippets. As of this writing, 6/22/07, these
        // are not generated at build time, but can be added by
        // custom classes.
        $c['ins']['snippets'] = isset($colinfo['ins']['snippets']) ? $colinfo['ins']['snippets'] : array();
        $c['upd']['snippets'] = isset($colinfo['upd']['snippets']) ? $colinfo['upd']['snippets'] : array();
        // First property, writable.  Work this out for all
        // three modes.
        $c['search']['writable'] = true;
        $c['ins']['writable'] = true;
        $c['upd']['writable'] = $perm_upd;
        if ($colinfo['uiro'] == 'Y') {
            $c['ins']['writable'] = false;
            $c['upd']['writable'] = false;
        } else {
            $autos = array('seqdefault', 'fetchdef', 'default', 'blank', 'none', 'synch', '', 'queuepos', 'dominant');
            $auto = strtolower(trim($colinfo['automation_id']));
            //echo "the auto for $colname is -".$auto."-<br/>";
            if (!in_array($auto, $autos)) {
                $c['ins']['writable'] = false;
                $c['upd']['writable'] = false;
            }
            // override for primary key
            if ($colinfo['primary_key'] == 'Y') {
                $c['upd']['writable'] = false;
            }
        }
        // This is the default size and maxlength.  Notice that
        // we don't seet a maxlength in search mode.
        //
        $size = $colinfo['dispsize'] + 1;
        $maxl = $colinfo['dispsize'];
        if (ArraySafe($colinfo, 'colscale', 0) != 0) {
            $maxl += 1;
        }
        $c['search']['size'] = $size;
        $c['ins']['size'] = $size;
        $c['ins']['maxlength'] = $maxl;
        $c['upd']['size'] = $size;
        $c['upd']['maxlength'] = $maxl;
        // This is a feature that the column should be all
        // caps, currently done only for primary keys
        if ($table['capspk'] == 'Y' && $colinfo['primary_key'] == 'Y') {
            $snippet = 'javascript:this.value=this.value.toUpperCase()';
            $c['ins']['snippets']['onkeyup'][] = $snippet;
            $c['upd']['snippets']['onkeyup'][] = $snippet;
        }
        // set up foreign keys
        $c['search']['table_id_fko'] = '';
        $c['search']['fkdisplay'] = '';
        $c['ins']['table_id_fko'] = $colinfo['table_id_fko'];
        $c['upd']['table_id_fko'] = $colinfo['table_id_fko'];
        $c['ins']['fkdisplay'] = $colinfo['fkdisplay'];
        $c['upd']['fkdisplay'] = $colinfo['fkdisplay'];
        // If the foreign key is compound, give us the whole thing
        if (trim($colinfo['table_id_fko']) != '') {
            $tabfk = dd_TableRef(trim($colinfo['table_id_fko']));
            $c['upd']['fk_pks'] = $tabfk['pks'];
            $c['ins']['fk_pks'] = $tabfk['pks'];
        }
        // If this column forces calculations, set a flag
        $c['upd']['calcs'] = in_array($colname, $table['calcs']);
        $c['ins']['calcs'] = $c['upd']['calcs'];
        $c['search']['calcs'] = false;
        // Give the guy his chain information
        $c['upd']['chaincalc'] = ArraySafe($colinfo, 'chaincalc', array());
        $c['ins']['chaincalc'] = $c['upd']['chaincalc'];
        $c['search']['chaincalc'] = array();
        // Value min and max
        $c['search']['value_min'] = $colinfo['value_min'];
        $c['search']['value_max'] = $colinfo['value_max'];
        $c['upd']['value_min'] = $colinfo['value_min'];
        $c['upd']['value_max'] = $colinfo['value_max'];
        $c['ins']['value_min'] = $colinfo['value_min'];
        $c['ins']['value_max'] = $colinfo['value_max'];
        // uirows and uicols
        $c['upd']['uicols'] = $colinfo['uicols'];
        $c['upd']['uirows'] = $colinfo['uirows'];
        $c['ins']['uicols'] = $colinfo['uicols'];
        $c['ins']['uirows'] = $colinfo['uirows'];
        $c['search']['uicols'] = $colinfo['uicols'];
        $c['search']['uirows'] = $colinfo['uirows'];
        // defaults
        $c['upd']['default'] = null;
        $c['search']['default'] = null;
        $c['ins']['default'] = $colinfo['automation_id'] == 'DEFAULT' && $colinfo['auto_formula'] != '' ? $colinfo['auto_formula'] : null;
        // Add results into final array
        $retval['base'][$colname] = $c['base'];
        $retval['ins'][$colname] = $c['ins'];
        $retval['upd'][$colname] = $c['upd'];
        $retval['search'][$colname] = $c['search'];
    }
    //hprint_r($retval);
    return $retval;
}
Ejemplo n.º 2
0
/**
name:ri
parm:string rettype
parm:string retname
parm:any value

Shortcut to [[returnItem]].
*/
function ri($rettype, $retname, $retvalue)
{
    $r = arraySafe($GLOBALS['AG'], 'returnItems', array());
    $r[$rettype][$retname][] = $retvalue;
    $GLOBALS['AG']['returnItems'] = $r;
}