Пример #1
0
/**
* @deprecated
*/
function ahColFromACol(&$acol)
{
    // Link to the subarray and assign any defaults
    $acol['html_element'] = 'input';
    $acol['html_right'] = '';
    $acol['html_inner'] = '';
    $acol['text-align'] = 'left';
    $acol['hparms'] = array('class' => 'x3' . $acol['mode'], 'type' => 'text', 'name' => '--NAME--', 'nameprefix' => '--NAME-PREFIX--', 'id' => '--ID--', 'tabindex' => '--TABINDEX--', 'tooltip' => ArraySafe($acol, 'tooltip', ''), 'value' => '--NAME----VALUE--', 'x_value_original' => $acol['mode'] == 'ins' ? '' : '--NAME----VALUE--', 'x_class_suffix' => '', 'x_error' => '0', 'x_class_base' => $acol['mode'], 'x_mode' => $acol['mode'], 'x_no_clear' => ArraySafe($acol, 'noclear', 'N'), 'x_ctl_prv' => ArraySafe($acol, 'ctl_prv', ''), 'x_ctl_nxt' => ArraySafe($acol, 'ctl_nxt', ''), 'x_value_focus' => '', 'x_type_id' => $acol['type_id']);
    if ($acol['type_id'] == 'date') {
        $acol['hparms']['data-date'] = '--NAME----VALUE--';
        $acol['hparms']['class'] = 'datepicker';
        $acol['hparms']['data-date-format'] = 'mm/dd/yyyy';
    }
    $TOOLTIPS = OptionGet('TOOLTIPS', 'N');
    switch ($TOOLTIPS) {
        case 'NONE':
            $acol['hparms']['title'] = '';
            $acol['hparms']['tooltip'] = '';
        case 'JQUERY_ALSO':
            $acol['hparms']['title'] = $acol['hparms']['tooltip'];
            break;
        case 'JQUERY_ONLY':
            $acol['hparms']['title'] = $acol['hparms']['tooltip'];
            unset($acol['hparms']['tooltip']);
    }
    // For read-onlies, add another class
    if (!$acol['writable']) {
        //$acol['hparms']['class']='x3ro';
        $acol['hparms']['readonly'] = 'readonly';
    }
    // A size correction
    $acol['size'] = min($acol['size'], 24);
    // KFD 10/22/07.  For PROMAT application originally
    if (ArraySafe($acol, 'pk_change') == 'Y') {
        $acol['html_right'] .= "&nbsp;&nbsp;" . "<a href=\"javascript:void(0)\"" . 'onclick="ob(\'--NAME--\').readOnly=false;ob(\'--NAME--\').focus()">' . 'change</a>';
    }
    // ------------------------------------
    // Big deal #1, decisions based on type
    // ------------------------------------
    switch ($acol['type_id']) {
        case 'date':
            //  We might put a date button off to the right,
            //  if it is writable
            /*
                  if($acol['writable']) {
                     $acol['html_right']
                        .="&nbsp;&nbsp;"
                        ."<img src='clib/dhtmlgoodies_calendar_images/calendar1.gif' value='Cal'
                           onclick=\"displayCalendar(ob('--NAME--'),'mm/dd/yyyy',this,true)\">";
                  }*/
            $acol['hparams']['data-date-format'] = 'yyyy-mm-dd';
            $acol['hparms']['size'] = $acol['size'];
            if (isset($acol['maxlength'])) {
                $acol['hparms']['maxlength'] = $acol['maxlength'];
            }
            break;
        case 'time':
            $acol['html_element'] = 'select';
            $hinner = '';
            $xmin = $acol['value_min'];
            $xmax = $acol['value_max'] ? $acol['value_max'] : 1425;
            for ($x = $xmin; $x <= $xmax; $x += 15) {
                $hinner .= "\n<option value=\"{$x}\">" . hTime($x) . "</option>";
            }
            if ($acol['mode'] == 'search') {
                $hinner = "\n<option value=\"\"></option>" . $hinner;
            }
            $acol['html_inner'] = $hinner;
            break;
        case 'cbool':
            // DO 3-7-2008  Added if statement so that when column level security is present
            //              changes to field can be "disabled"
            if (!$acol['writable']) {
                $acol['html_element'] = 'input';
            } else {
                $acol['html_element'] = 'select';
                $prefix = $acol['mode'] == 'search' ? '<option value=""></option>' : '';
                $acol['html_inner'] = $prefix . "\n<option --SELECTED-Y-- value='Y'>Y</option>" . "<option --SELECTED-N-- value='N'>N</option>";
            }
            break;
        case 'gender':
            // DO 3-7-2008  Added if statement so that when column level security is present
            //              changes to field can be "disabled"
            if (!$acol['writable']) {
                $acol['html_element'] = 'input';
            } else {
                $acol['html_element'] = 'select';
                $prefix = $acol['mode'] == 'search' ? '<option value=""></option>' : '';
                $acol['html_inner'] = $prefix . "\n<option value='M'>M</option>" . "<option value='F'>F</option>";
            }
            break;
        case 'text':
            $acol['html_element'] = 'textarea';
            $acol['hparms']['rows'] = $acol['uirows'] == 0 ? 4 : $acol['uirows'];
            $acol['hparms']['cols'] = $acol['uicols'] == 0 ? 40 : $acol['uicols'];
            $acol['html_inner'] = '--NAME----VALUE--';
            $acol['value'] = '';
            break;
        case 'numb':
        case 'int':
        case 'money':
            if ($acol['type_id'] != 'int') {
                $acol['hparms']['size'] = 12;
            } else {
                $acol['hparms']['size'] = $acol['size'];
            }
            $acol['text-align'] = 'right';
            break;
        case 'mime-h-f':
        case 'mime-h':
            // Do nothing, it all gets done later.
        // Do nothing, it all gets done later.
        default:
            $acol['hparms']['size'] = $acol['size'];
            if (isset($acol['maxlength'])) {
                $acol['hparms']['maxlength'] = $acol['maxlength'];
            }
    }
    // ------------------------------------
    // Big deal GLEPH, value_min & value_max
    // ------------------------------------
    if (a($acol, 'value_min', '') != '' && a($acol, 'value_max', '') != '') {
        if ($acol['type_id'] != 'time') {
            $acol['html_element'] = 'select';
            $acol['hparms']['size'] = 1;
            $hinner = '';
            $xmin = a($acol, 'value_min');
            $xmax = a($acol, 'value_max');
            // DJO 4-18-08 Add empty row during lookup mode
            if ($acol['mode'] == 'search') {
                $hinner .= "\n<option value=\"\"></option>";
            }
            for ($x = $xmin; $x <= $xmax; $x++) {
                $hinner .= "\n<option value=\"{$x}\">" . $x . "</option>";
            }
            $acol['html_inner'] = $hinner;
            $acol['hparms']['style'] = 'text-align:left';
        }
    }
    // ------------------------------------
    // Big deal B), foreign keys
    // ------------------------------------
    if ($acol['table_id_fko'] != '' && $acol['type_id'] != 'date') {
        // Says we want an info button next to it
        if ($acol['mode'] != 'search') {
            $acol['html_right'] .= "<span class=\"help-inline\"><a tabindex=999 href=\"javascript:Info2('" . $acol['table_id_fko'] . "'" . ",'--NAME--')\">Info</a></span>";
        }
        if ($acol['writable']) {
            // if numeric, set this back
            $acol['text-align'] = 'left';
            if ($acol['fkdisplay'] != 'dynamic') {
                // HTML SELECT Branch
                $acol['html_element'] = 'SELECT';
                $acol['html_inner'] = '--NAME----HINNER--';
                if (array_key_exists('size', $acol['hparms'])) {
                    unset($acol['hparms']['size']);
                }
                if (array_key_exists('maxlength', $acol['hparms'])) {
                    unset($acol['hparms']['maxlength']);
                }
                // KFD 10/8/07 compound foreign keys.  If its the first,
                // put in a snippet to pull the next
                $fkpks = explode(',', $acol['fk_pks']);
                if (count($fkpks) > 1) {
                    if (trim($acol['column_id']) == trim($fkpks[0])) {
                        $tfko = $acol['table_id_fko'];
                        $pk1 = $fkpks[0];
                        $pk2 = $fkpks[1];
                        $acol['snippets']['onblur'][] = "fetchSELECT('{$tfko}',this,'{$pk1}',this.value,'{$pk2}',obv('x2t_{$pk2}'))";
                    }
                }
            } else {
                // The core code just says do a dropdown
                $table_id_fko = $acol['table_id_fko'];
                $fkparms = 'gp_dropdown=' . $table_id_fko;
                if ($acol['writable']) {
                    //$col['input']='select';
                    if (vgfGet('adlversion', 2) == 1) {
                        $acol['snippets']['onkeyup'][] = "ajax_showOptions(this,'{$fkparms}',event)";
                    } else {
                        $acol['snippets']['onkeyup'][] = "androSelect_onKeyUp(this,'{$fkparms}',event)";
                        $acol['snippets']['onkeydown'][] = "androSelect_onKeyDown(event)";
                    }
                }
                $acol['hparms']['autocomplete'] = 'off';
            }
        }
    }
    // ------------------------------------
    // Big deal IV. change detection
    // ------------------------------------
    // Any item in update mode needs to get a snippet
    // KFD 8/8/07, JS_KEYSTROKE, see next section, all snippets
    //             for regular events are unconditional, the Js
    //             library routine decides what to do
    $acol['snippets']['onkeyup'][] = 'inputOnKeyUp(event,this)';
    // ------------------------------------
    // Big deal Epsilon, focus/unfocus
    // ------------------------------------
    // KFD 8/8/07, JS_KEYSTROKE.
    //             Call to javascript routines that will decide
    //             what to do, don't decide here
    $acol['snippets']['onfocus'][] = 'inputOnFocus(this)';
    $acol['snippets']['onblur'][] = 'inputOnBlur(this)';
    //if($acol['writable']) {
    //   $acol['snippets']['onfocus'][]='focusColor(this,true)';
    //   $acol['snippets']['onblur'][] ='focusColor(this,false)';
    //}
    // ------------------------------------
    // Big deal #6 execute lookup on ENTER
    // ------------------------------------
    if ($acol['mode'] == 'search') {
        $acol['snippets']['onkeypress'][] = "doButton(event,13,'but_lookup')";
    }
    // ------------------------------------
    // 2nd Big deal, execute FETCHes
    // ------------------------------------
    if (count(ArraySafe($acol, 'fetches', array())) > 0) {
        $fetches = $acol['fetches'];
        foreach ($fetches as $fetch) {
            $acol['snippets']['onchange'][] = "ajaxFetch(" . "'" . $fetch['table_id_par'] . "'" . ",'--NAME-PREFIX--'" . ",'" . $fetch['commapklist'] . "'" . ",'" . $fetch['commafklist'] . "'" . ",'" . $fetch['controls'] . "'" . ",'" . $fetch['columns'] . "'" . ",this)";
        }
    }
    // ------------------------------------
    // Does this field force recalc?
    // ------------------------------------
    if ($acol['calcs']) {
        // KFD 8/8/07 JS_KEYSTROKES, this will be done on server by
        //            calling back to the server when a value changes.
        //$acol['snippets']['onkeyup'][]="calcRow()";
        $acol['hparms']['autocomplete'] = 'off';
    }
    // ------------------------------------
    // Big deal OMEGA, rendering the element
    // ------------------------------------
    $hparms = '';
    foreach ($acol['hparms'] as $parm => $value) {
        $hparms .= $parm . '="' . (($acol['type_id'] == 'mime-h' || $acol['type_id'] == 'mime-h-f') && $parm == 'value' ? $value : hx($value)) . '"';
    }
    if ($acol['text-align'] == 'right') {
        $hparms .= ' style="text-align: right"';
    }
    $hcode = '';
    if (isset($acol['snippets'])) {
        foreach ($acol['snippets'] as $event => $list) {
            $hcode .= $event . '="' . implode(';', $list) . '"';
        }
    }
    // WE HAD A DISABLED HERE, BUT THEN IT WOULD NOT POST!
    $acol['html'] = "<" . $acol['html_element'] . ' ' . $hparms . ($acol['writable'] ? '' : ' READONLY ') . $hcode . '>' . $acol['html_inner'] . '</' . $acol['html_element'] . '>';
}
Пример #2
0
 function OneCell($text, $type_id = 'char', $dispsize = 0, $colscale = 0, $caption = false)
 {
     if ($dispsize == 0) {
         $dispsize = strlen($text);
     }
     $align = "L";
     switch ($type_id) {
         case 'char':
         case 'vchar':
             $output = str_pad(substr($text, 0, $dispsize), $dispsize) . ' ';
             break;
         case 'date':
             if (!$text) {
                 $output = '';
             } else {
                 if ($caption) {
                     $output = $text;
                 } else {
                     $output = date('m/d/Y', dEnsureTS($text)) . ' ';
                 }
             }
             break;
         case 'numb':
             if ($this->zeronumber && $text == 0) {
                 $output = '';
             } else {
                 if ($caption) {
                     $output = $text;
                 } else {
                     $output = number_format((double) $text, $colscale);
                 }
             }
             $output = ' ' . str_pad($output, $dispsize, ' ', STR_PAD_LEFT);
             $align = "R";
             break;
         case 'time':
             $output = ' ' . str_pad(trim(hTime($text)), 8, ' ', STR_PAD_LEFT);
             $align = "R";
             break;
         default:
             $output = $text;
     }
     // BEAUTY STEP 3, DROP X_PDF'S ROUTINE, DO OUR OWN.
     // The width calculation was worked out using Courier (fixed width)
     // to put out cells 10 chars long.  The value used gave perfect
     // alignment
     //$width=$this->GetStringWidth($output);
     if (strtoupper($this->fontname) == 'COURIER') {
         $width = $this->GetStringWidth($output);
     } else {
         $width = $dispsize * $this->fontsize * 0.23;
     }
     //if($align<>'L') {
     $this->Cell($width, 0, $output, 0, 0, $align);
     //}
     //else {
     //    $this->Cell($width,0,$output);
     //}
     //$this->CurrentLine.=$output.' ';
 }
Пример #3
0
 function ehBrowse_Data(&$rows)
 {
     // Generate the table header as sortable columns
     echo "\n";
     $cols = asliceValsFromKeys($this->table['flat'], 'description', $this->projections['_uisearch']);
     echo hTableSortable($this->table_id, $cols);
     // Retrieve the rows
     if (count($rows) > 0) {
         vgfSet('HTML_focus', 'browse_row0');
         $hrows = array();
         $j = 0;
         foreach ($rows as $row) {
             $j++;
             $i = 0;
             $newrow = array();
             foreach ($cols as $colname => $coldesc) {
                 if ($i != 0) {
                     switch ($this->table['flat'][$colname]['type_id']) {
                         case 'time':
                             $newrow[] = hTime($row[$colname]);
                             break;
                         case 'dtime':
                             $newrow[] = date('m/d/Y - h:i A', dEnsureTS($row[$colname]));
                             break;
                         case 'date':
                             if (is_null($row[$colname])) {
                                 $newrow[] = '';
                             } else {
                                 $newrow[] = hDate(strtotime($row[$colname]));
                             }
                             //$newrow[]=$row[$colname];
                             break;
                         default:
                             $newrow[] = $row[$colname];
                     }
                 } else {
                     $hName = $j == 1 ? ' id="browse_row0" ' : '';
                     $js = "SetAction('gp_page','" . $this->table_id . "'" . ",'gp_skey','" . $row['skey'] . "')";
                     $value = '<a tabindex=' . $j . $hName . ' ' . 'href="javascript:' . $js . '">' . $row[$colname] . '</a>';
                     $newrow[] = $value;
                     $i = 1;
                 }
             }
             $hrows[] = $newrow;
         }
         echo hTBodyFromRows('dlite', $hrows);
     } else {
         echo "\n<tr><td colspan=99 class='dlite'>" . "<b>There are no records to display</b>" . "</td></tr>\n";
     }
     // Wrap up by closing the table.
     echo "\n<tr><td colspan=99 class='dhead'>&nbsp;</td></tr>";
     echo "\n</table>";
 }