Exemplo n.º 1
0
 /**
  * Render
  *
  * @param object $object
  * @return string
  */
 public static function render($object)
 {
     $input = $object->options['input'];
     $filter = $object->filter;
     $full_text_search = $filter['full_text_search'] ?? null;
     unset($filter['full_text_search']);
     // generating form
     $table = ['header' => ['name' => i18n(null, 'Column'), 'value' => i18n(null, 'Value'), 'sep' => ' ', 'value2' => ' '], 'options' => []];
     // fields
     foreach ($filter as $k => $v) {
         if (!empty($v['range'])) {
             $table['options'][$k] = ['name' => ['value' => i18n(null, $v['name']) . ':', 'width' => '25%', 'class' => 'list_filter_name'], 'value' => ['value' => self::render_column($v, $k, false, $input), 'width' => '30%'], 'sep' => ['value' => '—', 'width' => '1%', 'class' => 'list_filter_value'], 'value2' => ['value' => self::render_column($v, $k, true, $input), 'width' => '30%']];
         } else {
             $table['options'][$k] = ['name' => ['value' => i18n(null, $v['name']) . ':', 'width' => '25%', 'class' => 'list_filter_name'], 'value' => ['value' => self::render_column($v, $k, false, $input), 'width' => '30%']];
         }
     }
     // full text search last
     if (!empty($full_text_search)) {
         $names = [];
         foreach ($full_text_search as $v) {
             $names[] = i18n(null, $filter[$v]['name']);
         }
         $table['options']['full_text_search'] = ['name' => ['value' => i18n(null, 'Text Search') . ':', 'class' => 'list_filter_name'], 'value' => ['value' => html::input(['name' => 'filter[full_text_search]', 'class' => 'list_filter_full_text_search', 'size' => 15, 'value' => $input['filter']['full_text_search'] ?? null])], 'value2' => ['value' => implode(', ', $names), 'class' => 'list_filter_value']];
     }
     $body = html::table($table);
     $footer = html::button2(['name' => 'submit_filter', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.modal.hide('list_{$object->list_link}_filter'); \$('#list_{$object->list_link}_form').attr('target', '_self'); \$('#list_{$object->list_link}_form').attr('no_ajax', ''); return true;"]);
     return html::modal(['id' => "list_{$object->list_link}_filter", 'class' => 'large', 'title' => i18n(null, 'Filter'), 'body' => $body, 'footer' => $footer]);
 }
Exemplo n.º 2
0
 /**
  * Render
  *
  * @param object $object
  * @return string
  */
 public static function render($object)
 {
     $input = $object->options['input'];
     // generating form
     $table = ['header' => ['column' => i18n(null, 'Column'), 'value' => i18n(null, 'Value')], 'options' => [], 'skip_header' => 1];
     $model = new object_content_exports();
     $table['options'][0]['column'] = ['value' => i18n(null, 'Format') . ':', 'width' => '1%', 'nowrap' => true, 'class' => 'list_filter_name'];
     $table['options'][0]['value']['value'] = html::select(['id' => 'export_format', 'name' => 'export[format]', 'options' => $model->options(['i18n' => true]), 'value' => $input['export']['format'] ?? null]);
     $body = html::table($table);
     $footer = html::button2(['name' => 'submit_export', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "if (\$('#export_format').val() == 'html2') { \$('#list_{$object->list_link}_form').attr('target', '_blank'); } else { \$('#list_{$object->list_link}_form').attr('target', '_self'); } \$('#list_{$object->list_link}_form').attr('no_ajax', 1); numbers.modal.hide('list_{$object->list_link}_export'); return true;"]);
     return html::modal(['id' => "list_{$object->list_link}_export", 'class' => '', 'title' => i18n(null, 'Export/Print'), 'body' => $body, 'footer' => $footer]);
 }
Exemplo n.º 3
0
    private function buildTable($data)
    {
        $id = uniqid('table');
        $tvpag = <<<EOT
function table_setpage(tableid,page) {
    alert('Set page ' + page);
}
EOT;
        App::document()->addInlineScript($tvpag, 'text/javascript', 'tableview-pagination');
        $hc = empty($this->options['header-columns']) ? 0 : $this->options['header-columns'];
        $hr = empty($this->options['header-rows']) ? 0 : $this->options['header-rows'];
        $rows = [];
        $ri = 0;
        $ipp = $this->options['items-per-page'];
        foreach ($data as $row) {
            $ri++;
            $ci = 0;
            $cols = [];
            foreach ($row as $col) {
                $ci++;
                if ($ci <= $hc || $ri <= $hr) {
                    $cols[] = html::th($col);
                } else {
                    $cols[] = html::td($col);
                }
            }
            $rows[] = html::tr(join($cols));
            if ($ipp && $ri > $ipp) {
                break;
            }
        }
        $table = html::table(join($rows), ['class' => $this->options['table-class'], 'style' => 'width:100%;']);
        if ($ipp) {
            $page = 0;
            $numpages = floor((count($data) - 1) / $ipp) + 1;
            $pagelinks = html::a(' &laquo; First ', ['href' => 'javascript:return false;']);
            $pagelinks .= html::a(' &lsaquo; Prev ', ['href' => 'javascript:return false;']);
            for ($n = 1; $n <= $numpages; $n++) {
                $pagelinks .= html::a(' {page} ', ['href' => 'javascript:return false;'], ['page' => $n]);
            }
            $pagelinks .= html::a(' Next &rsaquo; ', ['href' => 'javascript:return false;']);
            $pagelinks .= html::a(' Last &raquo; ', ['href' => 'javascript:return false;']);
            $table .= html::div('Page {page} of {pages} ({items} items) {links}', ['class' => $this->options['footer-class']], ['page' => $page + 1, 'pages' => $numpages, 'items' => count($data), 'links' => $pagelinks]);
        }
        return html::div($table, ['style' => 'width:99%']);
    }
Exemplo n.º 4
0
 /**
  * Render
  *
  * @param object $object
  * @return string
  */
 public static function render($object)
 {
     $input = $object->options['input'];
     if (empty($input['sort'])) {
         $i = 0;
         foreach ($object->orderby as $k => $v) {
             $input['sort'][$i]['column'] = $k;
             $input['sort'][$i]['order'] = $v;
             $i++;
         }
     }
     // generating form
     $table = ['header' => ['row_number' => '&nbsp;', 'column' => i18n(null, 'Column'), 'order' => i18n(null, 'Order')], 'options' => []];
     $order_model = new object_data_model_order();
     $columns = [];
     // we need to skip certain columns
     foreach ($object->columns as $k => $v) {
         if (!in_array($k, ['row_number', 'offset_number', 'action'])) {
             $v['name'] = i18n(null, $v['name']);
             $columns[$k] = $v;
         }
     }
     // full text search goes last
     if (!empty($object->filter['full_text_search'])) {
         $columns['full_text_search'] = ['name' => i18n(null, 'Text Search')];
     }
     // render 5 rows
     for ($i = 0; $i < 5; $i++) {
         if (empty($input['sort'][$i]['column'])) {
             $input['sort'][$i]['order'] = SORT_ASC;
         }
         $column = html::select(['id' => 'sort_' . $i . '_column', 'name' => 'sort[' . $i . '][column]', 'options' => $columns, 'value' => $input['sort'][$i]['column'] ?? null]);
         $order = html::select(['id' => 'sort_' . $i . '_order', 'name' => 'sort[' . $i . '][order]', 'no_choose' => true, 'options' => $order_model->options(['i18n' => true]), 'value' => $input['sort'][$i]['order'] ?? null]);
         $table['options'][$i] = ['row_number' => ['value' => format::id($i + 1) . '.', 'width' => '1%', 'align' => 'right'], 'column' => ['value' => $column, 'width' => '25%', 'class' => 'list_sort_name'], 'order' => ['value' => $order, 'width' => '30%']];
     }
     $body = html::table($table);
     $footer = html::button2(['name' => 'submit_sort', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.modal.hide('list_{$object->list_link}_sort'); \$('#list_{$object->list_link}_form').attr('target', '_self'); \$('#list_{$object->list_link}_form').attr('no_ajax', ''); return true;"]);
     return html::modal(['id' => "list_{$object->list_link}_sort", 'class' => 'large', 'title' => i18n(null, 'Sort'), 'body' => $body, 'footer' => $footer]);
 }
Exemplo n.º 5
0
    /**
     * Render debug toolbar
     *
     * @return string
     */
    public static function render()
    {
        $loaded_classes = application::get(['application', 'loaded_classes']);
        self::$data['session'] = [];
        if (!empty($_SESSION)) {
            self::$data['session'] = [$_SESSION];
        }
        $application = application::get();
        $result = '<div class="container" dir="ltr">';
        $result .= '<table cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<td>';
        $result .= '<table width="100%">';
        $result .= '<tr>';
        $result .= '<td nowrap>&nbsp;' . html::a(['value' => 'Hide All', 'href' => 'javascript:void(0);', 'onclick' => "\$('.debuging_toolbar_class').hide();"]) . '&nbsp;</td>';
        foreach (self::$data as $k => $v) {
            if ($k == 'errors') {
                $count = count(error_base::$errors);
            } else {
                if ($k == 'classes') {
                    $count = count($loaded_classes);
                } else {
                    if ($k == 'application') {
                        $count = count($application);
                    } else {
                        if ($k == 'phpinfo') {
                            $count = 1;
                        } else {
                            $count = count($v);
                        }
                    }
                }
            }
            $result .= '<td nowrap>&nbsp;' . html::a(['value' => ucwords($k) . ' (' . $count . ')', 'id' => "debuging_toolbar_{$k}_a", 'href' => 'javascript:void(0);', 'onclick' => "\$('#debuging_toolbar_{$k}').toggle();"]) . '&nbsp;</td>';
        }
        $result .= '<td width="50%" align="right">' . html::a(['href' => '/numbers/frontend/system/controller/dev', 'value' => 'Dev. Portal']) . '</td>';
        $result .= '</tr>';
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // errors
        $result .= '<tr id="debuging_toolbar_errors" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Errors (' . count(error_base::$errors) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (error_base::$errors as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . error_base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . $v['code'] . '</pre></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . implode("\n", $v['backtrace']) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // suppressed
        $result .= '<tr id="debuging_toolbar_suppressed" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Suppressed (' . count(self::$data['suppressed']) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (self::$data['suppressed'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . error_base::$error_codes[$v['errno']] . ' (' . $v['errno'] . ') - ' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td><pre>' . $v['code'] . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // javascript
        $result .= '<tr id="debuging_toolbar_js" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Javascript Errors (' . count(self::$data['js']) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        foreach (self::$data['js'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . implode('<br/>', $v['error']) . '</b></td>';
            $result .= '</tr>';
            $result .= '<tr>';
            $result .= '<td>File: ' . $v['file'] . ', Line: ' . $v['line'] . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '<div id="debuging_toolbar_js_data">';
        $result .= '&nbsp;';
        $result .= '</div>';
        $result .= '</td>';
        $result .= '</tr>';
        // benchmark first
        $result .= '<tr id="debuging_toolbar_benchmark" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Benchmark (' . count(self::$data['benchmark']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Name</th>';
        $result .= '<th>Time</th>';
        $result .= '<th>Start</th>';
        $result .= '<th>Total</th>';
        $result .= '<th>Memory</th>';
        $result .= '</tr>';
        foreach (self::$data['benchmark'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td>' . $v['name'] . '</td>';
            $result .= '<td align="right">' . $v['time'] . '</td>';
            $result .= '<td align="right">' . $v['start'] . '</td>';
            $result .= '<td align="right">' . $v['total'] . '</td>';
            $result .= '<td align="right">' . format::memory($v['memory'], 'm') . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // sql
        $result .= '<tr id="debuging_toolbar_sql" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Sql (' . count(self::$data['sql']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Sql</th>';
        $result .= '<th>Error</th>';
        $result .= '<th>Errno</th>';
        $result .= '<th>Num Rows</th>';
        $result .= '<th>Affected Rows</th>';
        //$result.= '<th>Rows</th>';
        $result .= '<th>Key</th>';
        $result .= '<th>Structure</th>';
        $result .= '<th>Time</th>';
        $result .= '</tr>';
        foreach (self::$data['sql'] as $k => $v) {
            $temp = is_array($v['key']) ? implode('<br/>', $v['key']) : $v['key'];
            // header first
            $result .= '<tr>';
            $result .= '<td valign="top"><pre style="width: 500px;">' . nl2br($v['sql']) . '</pre></td>';
            $result .= '<td valign="top">' . implode('<br/>', $v['error']) . ' - ' . implode('<br/>', $v['error_original'] ?? []) . '</td>';
            $result .= '<td valign="top">' . $v['errno'] . '</td>';
            $result .= '<td valign="top">' . $v['num_rows'] . '</td>';
            $result .= '<td valign="top">' . $v['affected_rows'] . '</td>';
            //$result.= '<td valign="top">' . html::table(['options' => $v['rows']]) . '</td>';
            $result .= '<td valign="top">' . $temp . '</td>';
            $result .= '<td valign="top">' . html::table(['options' => $v['structure']]) . '</td>';
            $result .= '<td valign="top">' . $v['time'] . '</td>';
            $result .= '</tr>';
            // results second
            if (!empty($v['rows'])) {
                $temp = array_keys(current($v['rows']));
                $header = array_combine($temp, $temp);
                if (!empty($header)) {
                    $result .= '<tr>';
                    $result .= '<td valign="top" colspan="8" style="max-width: 1000px; overflow: scroll;">' . html::table(['header' => $header, 'options' => $v['rows']]) . '</td>';
                    $result .= '</tr>';
                }
            }
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // cache
        $result .= '<tr id="debuging_toolbar_cache" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Cache (' . count(self::$data['cache']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Type</th>';
        $result .= '<th>Link</th>';
        $result .= '<th>Cache #</th>';
        $result .= '<th>Has Data</th>';
        $result .= '</tr>';
        foreach (self::$data['cache'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top">' . $v['type'] . '</td>';
            $result .= '<td valign="top">' . $v['link'] . '</td>';
            $result .= '<td valign="top">' . $v['cache_id'] . '</td>';
            $result .= '<td valign="top">' . ($v['have_data'] ? 'Yes' : 'No') . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // dump
        $result .= '<tr id="debuging_toolbar_dump" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Dump (' . count(self::$data['dump']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Name</th>';
        $result .= '<th>Dump</th>';
        $result .= '</tr>';
        foreach (self::$data['dump'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top">' . $v['name'] . '</td>';
            $result .= '<td valign="top"><pre>' . print_r($v['value'], true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // input
        $result .= '<tr id="debuging_toolbar_input" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Input (' . count(self::$data['input']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Input</th>';
        $result .= '</tr>';
        foreach (self::$data['input'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // session
        $result .= '<tr id="debuging_toolbar_session" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Session (' . count(self::$data['session']) . ')' . '</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Session</th>';
        $result .= '</tr>';
        foreach (self::$data['session'] as $k => $v) {
            $result .= '<tr>';
            $result .= '<td valign="top"><pre>' . print_r($v, true) . '</pre></td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // autoloaded classes
        $result .= '<tr id="debuging_toolbar_classes" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Loaded Classes (' . count($loaded_classes) . ')</h3>';
        $result .= '<table border="1" cellpadding="2" cellspacing="2" width="100%">';
        $result .= '<tr>';
        $result .= '<th>Class Name</th>';
        $result .= '<th>File</th>';
        $result .= '<th>Media</th>';
        $result .= '</tr>';
        foreach ($loaded_classes as $k => $v) {
            $result .= '<tr>';
            $result .= '<td><b>' . $v['class'] . '</b></td>';
            $result .= '<td>' . $v['file'] . '</td>';
            $result .= '<td>' . html::table(['options' => $v['media']]) . '</td>';
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '</td>';
        $result .= '</tr>';
        // application
        $result .= '<tr id="debuging_toolbar_application" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Application (' . count($application) . ')</h3>';
        $result .= print_r2($application, true);
        $result .= '</td>';
        $result .= '</tr>';
        // phpinfo
        $result .= '<tr id="debuging_toolbar_phpinfo" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>PHPInfo</h3>';
        helper_ob::start();
        phpinfo();
        $str = helper_ob::clean();
        $str = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $str);
        $str .= <<<TTT
\t\t\t\t\t\t\t<style type="text/css">
\t\t\t\t\t\t\t\t#phpinfo table {
\t\t\t\t\t\t\t\t\tborder: 1px solid #000;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t\t#phpinfo table tr {
\t\t\t\t\t\t\t\t\tborder-bottom: 1px solid #000;
\t\t\t\t\t\t\t\t}
\t\t\t\t\t\t\t</style>
TTT;
        $result .= '<div id="phpinfo">' . $str . '</div>';
        $result .= '</td>';
        $result .= '</tr>';
        // acls
        $result .= '<tr id="debuging_toolbar_acls" class="debuging_toolbar_class" style="display: none;">';
        $result .= '<td>';
        $result .= '<h3>Acls (' . count(debug::$data['acls']) . ')</h3>';
        $result .= print_r2(debug::$data['acls'], true);
        $result .= '</td>';
        $result .= '</tr>';
        $result .= '</table>';
        $result .= '</div>';
        return $result;
    }
Exemplo n.º 6
0
 /**
  * @see html::grid()
  */
 public static function grid($options = [])
 {
     $rows = isset($options['options']) ? $options['options'] : [];
     unset($options['options']);
     $data = ['header' => [], 'options' => [], 'skip_header' => true];
     foreach ($rows as $k => $v) {
         $index = 0;
         foreach ($v as $k2 => $v2) {
             foreach ($v2 as $k3 => $v3) {
                 $cell = ['header' => [0], 'options' => [[$v3['label'] ?? ''], [$v3['value'] ?? ''], [$v3['description'] ?? '']], 'skip_header' => true];
                 if (!empty($v3['separator'])) {
                     $data['options'][$k][$index] = ['value' => $v3['value'], 'colspan' => 24];
                 } else {
                     $data['options'][$k][$index] = html::table($cell);
                 }
                 $data['header'][$index] = $index;
                 $index++;
             }
         }
     }
     return html::table($data);
 }
 function compose($_focusElement = 'to')
 {
     // read the data from session
     // all values are empty for a new compose window
     $sessionData = $this->bocompose->getSessionData();
     if (is_array($_REQUEST['preset'])) {
         if ($_REQUEST['preset']['file'] && is_readable($_REQUEST['preset']['file'])) {
             $this->bocompose->addAttachment(array_merge($sessionData, $_REQUEST['preset']));
             $sessionData = $this->bocompose->getSessionData();
         }
         foreach (array('to', 'cc', 'bcc', 'subject', 'body') as $name) {
             if ($_REQUEST['preset'][$name]) {
                 $sessionData[$name] = $_REQUEST['preset'][$name];
             }
         }
     }
     // is the to address set already?
     if (!empty($_REQUEST['send_to'])) {
         $sessionData['to'] = base64_decode($_REQUEST['send_to']);
     }
     //is the MimeType set/requested
     if (!empty($_REQUEST['mimeType'])) {
         $sessionData['mimeType'] = $_REQUEST['mimeType'];
     }
     // is a certain signature requested?
     // only the following values are supported (and make sense)
     // no => means -2
     // system => means -1
     // default => fetches the default, which is standard behavior
     if (!empty($_REQUEST['signature']) && (strtolower($_REQUEST['signature']) == 'no' || strtolower($_REQUEST['signature']) == 'system')) {
         $presetSig = strtolower($_REQUEST['signature']) == 'no' ? -2 : -1;
     }
     $this->display_app_header();
     $this->t->set_file(array("composeForm" => "composeForm.tpl"));
     $this->t->set_block('composeForm', 'header', 'header');
     $this->t->set_block('composeForm', 'body_input');
     $this->t->set_block('composeForm', 'attachment', 'attachment');
     $this->t->set_block('composeForm', 'attachment_row', 'attachment_row');
     $this->t->set_block('composeForm', 'attachment_row_bold');
     $this->t->set_block('composeForm', 'destination_row');
     $this->t->set_block('composeForm', 'simple_text');
     $this->translate();
     /*		$this->t->set_var("link_addressbook",$GLOBALS['phpgw']->link('/index.php',array(
     				'menuaction' => 'addressbook.addressbook_ui.emailpopup'
     			),true));
     */
     $this->t->set_var("link_addressbook", $GLOBALS['phpgw']->link('/felamimail/addressbook.php', false, true));
     $this->t->set_var("focusElement", $_focusElement);
     $linkData = array('menuaction' => 'felamimail.uicompose.selectFolder');
     $this->t->set_var('folder_select_url', $GLOBALS['phpgw']->link('/index.php', $linkData, true));
     $linkData = array('menuaction' => 'felamimail.uicompose.fileSelector', 'composeid' => $this->composeID);
     $this->t->set_var('file_selector_url', $GLOBALS['phpgw']->link('/index.php', $linkData, true));
     $linkData = array('menuaction' => 'felamimail.uicompose.action', 'composeid' => $this->composeID);
     $this->t->set_var("link_action", $GLOBALS['phpgw']->link('/index.php', $linkData, true));
     $this->t->set_var('folder_name', $this->bofelamimail->sessionData['mailbox']);
     $this->t->set_var('compose_id', $this->composeID);
     // check for some error messages from last posting attempt
     if ($errorInfo = $this->bocompose->getErrorInfo()) {
         $this->t->set_var('errorInfo', "<font color=\"red\"><b>{$errorInfo}</b></font>");
     } else {
         $this->t->set_var('errorInfo', '&nbsp;');
     }
     // header
     $allIdentities = $this->mailPreferences->getIdentity();
     #_debug_array($allIdentities);
     $defaultIdentity = 0;
     foreach ($allIdentities as $key => $singleIdentity) {
         #$identities[$singleIdentity->id] = $singleIdentity->realName.' <'.$singleIdentity->emailAddress.'>';
         $identities[$key] = $singleIdentity->realName . ' <' . $singleIdentity->emailAddress . '>';
         if (!empty($singleIdentity->default)) {
             #$defaultIdentity = $singleIdentity->id;
             $defaultIdentity = $key;
             $sessionData['signatureID'] = $singleIdentity->signature;
         }
     }
     $selectFrom = html::select('identity', $defaultIdentity, $identities, true, "style='width:100%;' onchange='changeIdentity(this);'");
     $this->t->set_var('select_from', $selectFrom);
     // navbar(, kind of)
     $this->t->set_var('img_clear_left', $GLOBALS['phpgw']->common->image('felamimail', 'clear_left'));
     $this->t->set_var('img_fileopen', $GLOBALS['phpgw']->common->image('phpgwapi', 'fileopen'));
     $this->t->set_var('img_mail_send', $GLOBALS['phpgw']->common->image('felamimail', 'mail_send'));
     $this->t->set_var('img_attach_file', $GLOBALS['phpgw']->common->image('felamimail', 'attach'));
     $this->t->set_var('ajax-loader', $GLOBALS['phpgw']->common->image('felamimail', 'ajax-loader'));
     $this->t->set_var('img_fileexport', $GLOBALS['phpgw']->common->image('felamimail', 'fileexport'));
     // prepare print url/button
     $this->t->set_var('img_print_it', $GLOBALS['phpgw']->common->image('felamimail', 'fileprint'));
     $this->t->set_var('lang_print_it', lang('print it'));
     $this->t->set_var('print_it', $printURL);
     // from, to, cc, replyto
     $destinationRows = 0;
     foreach (array('to', 'cc', 'bcc', 'replyto', 'folder') as $destination) {
         foreach ((array) $sessionData[$destination] as $key => $value) {
             $selectDestination = html::select('destination[]', $destination, $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
             $this->t->set_var('select_destination', $selectDestination);
             $this->t->set_var('address', @htmlentities($value, ENT_QUOTES, $this->displayCharset));
             $this->t->parse('destinationRows', 'destination_row', True);
             $destinationRows++;
         }
     }
     while ($destinationRows < 3) {
         // and always add one empty row
         $selectDestination = html::select('destination[]', 'to', $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
         $this->t->set_var('select_destination', $selectDestination);
         $this->t->set_var('address', '');
         $this->t->parse('destinationRows', 'destination_row', True);
         $destinationRows++;
     }
     // and always add one empty row
     $selectDestination = html::select('destination[]', 'to', $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
     $this->t->set_var('select_destination', $selectDestination);
     $this->t->set_var('address', '');
     $this->t->parse('destinationRows', 'destination_row', True);
     $this->t->set_var("subject", @htmlentities($sessionData['subject'], ENT_QUOTES, $this->displayCharset));
     $this->t->set_var('addressbookImage', $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website', 'users'));
     //		$this->t->set_var('infologImage',html::image('felamimail','to_infolog',lang('Save as infolog'),'width="17px" height="17px" valign="middle"' ));
     //		$this->t->set_var('lang_save_as_infolog',lang('Save as infolog'));
     $this->t->set_var('lang_no_recipient', lang('No recipient address given!'));
     $this->t->set_var('lang_no_subject', lang('No subject given!'));
     $this->t->pparse("out", "header");
     // body
     if ($sessionData['mimeType'] == 'html') {
         $style = "border:0px; width:100%; height:400px;";
         $this->t->set_var('tinymce', html::fckEditorQuick('body', 'simple', $sessionData['body']));
         $this->t->set_var('mimeType', 'html');
         $ishtml = 1;
     } else {
         $style = "border:0px; width:100%; height:400px;";
         $this->t->set_var('tinymce', html::fckEditorQuick('body', 'ascii', $sessionData['body']));
         $this->t->set_var('mimeType', 'text');
         $ishtml = 0;
     }
     require_once PHPGW_INCLUDE_ROOT . '/felamimail/inc/class.felamimail_bosignatures.inc.php';
     $boSignatures = new felamimail_bosignatures();
     $signatures = $boSignatures->getListOfSignatures();
     if (empty($sessionData['signatureID'])) {
         if ($signatureData = $boSignatures->getDefaultSignature()) {
             if (is_array($signatureData)) {
                 $sessionData['signatureID'] = $signatureData['signatureid'];
             } else {
                 $sessionData['signatureID'] = $signatureData;
             }
         }
     }
     $selectSignatures = array('-2' => lang('no signature'));
     foreach ($signatures as $signature) {
         $selectSignatures[$signature['fm_signatureid']] = $signature['fm_description'];
     }
     $selectBox = html::select('signatureID', $presetSig ? $presetSig : $sessionData['signatureID'], $selectSignatures, true, "style='width: 70%;' onchange='fm_compose_changeInputType(this)'");
     $this->t->set_var("select_signature", $selectBox);
     $this->t->set_var("lang_editormode", lang("Editor type"));
     $this->t->set_var("toggle_editormode", lang("Editor type") . ":&nbsp;<span><input name=\"_is_html\" value=\"" . $ishtml . "\" type=\"hidden\" /><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" " . ($ishtml ? "checked=\"checked\"" : "") . " id=\"_html\" value=\"html\" type=\"radio\"><label for=\"_html\">HTML</label><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" " . ($ishtml ? "" : "checked=\"checked\"") . " id=\"_plain\" value=\"plain\" type=\"radio\"><label for=\"_plain\">Plain text</label></span>");
     $this->t->pparse("out", "body_input");
     // attachments
     if (is_array($sessionData['attachments']) && count($sessionData['attachments']) > 0) {
         $imgClearLeft = $GLOBALS['phpgw']->common->image('felamimail', 'clear_left');
         foreach ((array) $sessionData['attachments'] as $id => $attachment) {
             $tempArray = array('1' => $attachment['name'], '2' => $attachment['type'], '.2' => "style='text-align:center;'", '3' => $attachment['size'], '4' => "<img src='{$imgClearLeft}' onclick=\"fm_compose_deleteAttachmentRow(this,'{$_composeID}','{$id}')\">");
             $tableRows[] = $tempArray;
         }
         if (count($tableRows) > 0) {
             $table = html::table($tableRows, "style='width:100%'");
         }
         $this->t->set_var('attachment_rows', $table);
     } else {
         $this->t->set_var('attachment_rows', '');
     }
     $this->t->pparse("out", "attachment");
 }
Exemplo n.º 8
0
 /**
  * Render
  * 
  * @param string $type
  * @return string
  */
 public function render($type)
 {
     $result = '';
     $session = new session();
     // main switch
     switch ($type) {
         case 'pdf':
             // document properties
             $this->header['pdf']['orientation'] = isset($this->header['pdf']['orientation']) ? $this->header['pdf']['orientation'] : 'P';
             $this->header['pdf']['unit'] = 'mm';
             $this->header['pdf']['format'] = isset($this->header['pdf']['format']) ? $this->header['pdf']['format'] : 'LETTER';
             $this->header['pdf']['encoding'] = isset($this->header['pdf']['encoding']) ? $this->header['pdf']['encoding'] : 'UTF-8';
             $this->header['pdf']['font'] = isset($this->header['pdf']['font']) ? $this->header['pdf']['font'] : array('family' => 'helvetica', 'style' => '', 'size' => 8);
             //include 'tcpdf/tcpdf.php';
             // create new PDF document
             $pdf = new TCPDF($this->header['pdf']['orientation'], $this->header['pdf']['unit'], $this->header['pdf']['format'], true, $this->header['pdf']['encoding'], false);
             // set margins
             $pdf->SetMargins(0, 0, 0);
             $pdf->setPrintHeader(false);
             // disable auto break
             $pdf->SetAutoPageBreak(false, 0);
             // set default font subsetting mode
             $pdf->setFontSubsetting(true);
             // set color for background
             $pdf->SetFillColor(255, 255, 255);
             // set font
             $pdf->SetFont($this->header['pdf']['font']['family'], $this->header['pdf']['font']['style'], $this->header['pdf']['font']['size']);
             // stats
             $page_counter = 1;
             $page_y = 0;
             $flag_new_page = true;
             $flag_filter = true;
             $flag_first_row = true;
             $columns = array();
             $all_columns = array();
             // gethering all columns
             foreach ($this->data as $k => $v) {
                 if ($v['t'] == 'columns') {
                     $all_columns[] = $v;
                 }
             }
             // looping through the data
             foreach ($this->data as $k => $v) {
                 if ($v['t'] == 'columns') {
                     continue;
                 }
                 if ($flag_new_page) {
                     // add new page
                     $pdf->AddPage($this->header['pdf']['orientation'], '', true);
                     // drawing header
                     $pdf->MultiCell(40, 5, format::datetime(format::now()), 0, 'L', 1, 0, 5, 5, true, 0, false, true, 10, 'T');
                     // company + book name
                     $pw = $pdf->getPageWidth();
                     $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                     // todo: fix here
                     $pdf->MultiCell($pw - 90, 5, $session->company_name . ': ' . $session->book_name, 0, 'C', 1, 0, 40, 5, true, 0, false, true, 10, 'T');
                     // page counter
                     $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                     $pdf->MultiCell(40, 5, 'Page ' . $page_counter, 0, 'R', 1, 0, $pw - 45, 5, true, 0, false, true, 10, 'T');
                     // report name
                     $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                     $report_name = $this->header['name'] . ' (' . implode('-', application::get(array('mvc', 'controllers'))) . ')';
                     $pdf->MultiCell($pw - 10, 5, $report_name, 0, 'L', 1, 0, 5, 10, true, 0, false, true, 10, 'T');
                     if (isset($this->header['description'])) {
                         $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                         $pdf->MultiCell(205, 5, $this->header['description'], 0, 'L', 1, 0, 5, 15, true, 0, false, true, 10, 'T');
                         $page_y = 25;
                     } else {
                         $page_y = 20;
                     }
                     // if we need to add a filter
                     if ($flag_filter) {
                         if (isset($this->header['filter'])) {
                             foreach ($this->header['filter'] as $k2 => $v2) {
                                 $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                                 $pdf->MultiCell(50, 5, $k2 . ':', 0, 'L', 1, 0, 5, $page_y, true, 0, false, true, 10, 'T');
                                 $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                                 $number_of_cells = $pdf->MultiCell($pdf->getPageWidth() - 60, 5, $v2, 0, 'L', 1, 0, 55, $page_y, true, 0, false, true, 10, 'T');
                                 if ($number_of_cells > 1) {
                                     $page_y += 5 * ($number_of_cells - 1);
                                 }
                                 $page_y += 5;
                             }
                         }
                         $flag_filter = false;
                         // adding one line space
                         $page_y += 5;
                     }
                     // page counter
                     $page_counter++;
                     $flag_new_page = false;
                 }
                 // rendering rows
                 if ($flag_first_row) {
                     if (empty($columns)) {
                         $columns = current($all_columns);
                         // repopulate width
                         $count_empty = 0;
                         $taken = 0;
                         foreach ($columns['d'] as $k2 => $v2) {
                             if (empty($v2['w'])) {
                                 $count_empty++;
                             } else {
                                 $taken += $v2['w'];
                             }
                         }
                         if (!empty($count_empty)) {
                             $new_width = floor(($pdf->getPageWidth() - 10 - $taken) / $count_empty);
                             foreach ($v['d'] as $k2 => $v2) {
                                 $columns['d'][$k2]['w'] = $new_width;
                             }
                         }
                     }
                     $flag_first_row = false;
                     // columns
                     foreach ($all_columns as $k20 => $v20) {
                         $x = 5;
                         foreach ($columns['d'] as $k10 => $v10) {
                             foreach (array('v', 'c', 'a', 'b', 's', 't', 'u') as $v30) {
                                 if (isset($v20['d'][$k10][$v30])) {
                                     $v10[$v30] = $v20['d'][$k10][$v30];
                                 }
                             }
                             $new_width = @$v10['w'];
                             if (!empty($v10['c'])) {
                                 // we need to get width of next elements
                                 for ($i = $k10 + 1; $i < $k10 + $v10['c']; $i++) {
                                     $new_width += $columns['d'][$k10]['w'];
                                 }
                             }
                             $align = str_replace(array('left', 'right', 'center'), array('L', 'R', 'C'), @$v10['a']);
                             if (empty($align)) {
                                 $align = 'L';
                             }
                             if (@$v10['b']) {
                                 $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                             } else {
                                 $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                             }
                             $pdf->MultiCell($new_width, 5, @$v10['v'], $this->flag_pdf_show_borders, $align, 1, 0, $x, $page_y, true, 0, false, true, 10, 'T');
                             // underline
                             if (@$v10['u']) {
                                 $pdf->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
                                 $pdf->Line($x, $page_y + 5, $x + @$v10['w'], $page_y + 5);
                             }
                             $x += @$v10['w'];
                         }
                         $page_y += 5;
                     }
                 }
                 $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                 $x = 5;
                 foreach ($columns['d'] as $k10 => $v10) {
                     // we do do render cells if no data
                     if (isset($v['d'][$k10]['v'])) {
                         $align = str_replace(array('left', 'right', 'center'), array('L', 'R', 'C'), @$v['d'][$k10]['a']);
                         if (empty($align)) {
                             $align = 'L';
                         }
                         if (@$v['d'][$k10]['b']) {
                             $pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
                         } else {
                             $pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
                         }
                         // if we override width
                         $width = $v10['w'];
                         if (isset($v['d'][$k10]['w'])) {
                             $width = $v['d'][$k10]['w'];
                         } else {
                             if (isset($v['d'][$k10]['c'])) {
                                 // colspan
                                 // we need to get width of next elements
                                 for ($i = $k10 + 1; $i < $k10 + $v['d'][$k10]['c']; $i++) {
                                     $width += @$columns['d'][$i]['w'];
                                 }
                             }
                         }
                         $value = @$v['d'][$k10]['v'];
                         $value = str_replace('&nbsp;', ' ', $value);
                         // rendering cell
                         $pdf->MultiCell($width, 5, $value, $this->flag_pdf_show_borders, $align, 1, 0, $x, $page_y, true, 0, false, true, 10, 'T');
                         // underline
                         if (@$v['d'][$k10]['u']) {
                             $pdf->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
                             $pdf->Line($x, $page_y + 5, $x + $v10['w'], $page_y + 5);
                         }
                         // subtotal
                         if (@$v['d'][$k10]['s']) {
                             $pdf->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
                             $pdf->Line($x + 1, $page_y, $x + $v10['w'] - 1, $page_y);
                         }
                         // total
                         if (@$v['d'][$k10]['t']) {
                             $pdf->SetLineStyle(array('width' => 0, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
                             $pdf->Line($x + 1, $page_y, $x + $v10['w'] - 1, $page_y);
                             $pdf->Line($x + 1, $page_y - 0.75, $x + $v10['w'] - 1, $page_y - 0.75);
                         }
                     }
                     $x += @$v10['w'];
                 }
                 // incrementing
                 $page_y += 5;
                 if ($page_y > $pdf->getPageHeight() - 10) {
                     $flag_new_page = true;
                     $flag_first_row = true;
                 }
             }
             $pdf->Output($this->header['name'] . '.pdf', 'I');
             exit;
             break;
         case 'csv':
         case 'txt':
         case 'xlsx':
             $sheet = strip_tags($this->header['name']);
             $sheet = str_replace(['/', '\\'], '', $sheet);
             // generating header
             $header = [];
             $header[$sheet][] = [format::datetime(format::now()), '', $session->company_name . ': ' . $session->book_name, '', 'Page 1'];
             $controllers = application::get(['mvc', 'controllers']);
             $header[$sheet][] = [strip_tags($this->header['name']) . ' (' . implode('-', $controllers) . ')'];
             if (isset($this->header['description'])) {
                 $header[$sheet][] = [$this->header['description']];
             }
             $header[$sheet][] = [' '];
             $temp = $header;
             // displaying filter
             if (isset($this->header['filter'])) {
                 $temp2 = [];
                 foreach ($this->header['filter'] as $k => $v) {
                     $temp[$sheet][] = [strip_tags($k), strip_tags($v)];
                 }
                 $temp[$sheet][] = [' '];
             }
             // converting data
             foreach ($this->data as $k => $v) {
                 $temp2 = [];
                 foreach ($v['d'] as $k2 => $v2) {
                     if (is_array($v2)) {
                         $value = $v2['v'] ?? null;
                     } else {
                         $value = $v2;
                     }
                     // replaces
                     $value = str_replace('&nbsp;', ' ', $value);
                     $temp2[] = strip_tags($value);
                 }
                 $temp[$sheet][] = $temp2;
             }
             // get output buffering
             helper_ob::clean_all();
             // content
             switch ($type) {
                 case 'xlsx':
                     echo io::array_to_excel($temp, io::$formats[$type]['excel_code'], null);
                     break;
                 default:
                     // csv or text
                     header('Content-Type: ' . numbers_frontend_exports_csv_base::$formats[$type]['content_type']);
                     header('Content-Disposition: attachment; filename="' . $sheet . '.' . $type . '"');
                     header('Cache-Control: max-age=0');
                     echo numbers_frontend_exports_csv_base::array_to_csv($temp, numbers_frontend_exports_csv_base::$formats[$type]['delimiter'], numbers_frontend_exports_csv_base::$formats[$type]['enclosure']);
             }
             exit;
             break;
         case 'html':
         case 'html2':
         default:
             // rendering data
             $table = ['options' => []];
             $counter = 1;
             foreach ($this->data as $k => $v) {
                 $flag_colspan = 0;
                 $row = [];
                 if (!empty($v['d'])) {
                     foreach ($v['d'] as $k2 => $v2) {
                         if ($flag_colspan > 0) {
                             $flag_colspan--;
                             continue;
                         }
                         $colspan = '';
                         if ($v2['c'] ?? null) {
                             $colspan = $v2['c'];
                             $flag_colspan = $v2['c'] - 1;
                         }
                         $align = 'left';
                         $title = '';
                         $style = '';
                         if (is_array($v2)) {
                             $value = $v2['v'] ?? null;
                             if (!empty($v2['h'])) {
                                 $v2['h']['value'] = $value;
                                 $value = html::a($v2['h']);
                             }
                             if (!empty($v2['a'])) {
                                 $align = $v2['a'];
                             }
                             if (!empty($v2['l'])) {
                                 $title = $v2['l'];
                             }
                             // bold lines
                             if ($v2['b'] ?? null) {
                                 $value = '<b>' . $value . '</b>';
                             }
                             // todo: convert styles to classes
                             if ($v2['s'] ?? null) {
                                 $style .= 'border-top: 1px solid #000;';
                             }
                             if ($v2['t'] ?? null) {
                                 $style .= 'border-top: 3px double #000;';
                             }
                             if ($v2['u'] ?? null) {
                                 $style .= 'border-bottom: 1px solid #000;';
                             }
                         } else {
                             $value = $v2;
                         }
                         $row[$k2] = ['value' => $value, 'align' => $align, 'colspan' => $colspan, 'style' => $style, 'title' => $title, 'nowrap' => true];
                     }
                 } else {
                     $row[0] = ['value' => '&nbsp;'];
                 }
                 $table['options'][$counter] = $row;
                 $counter++;
             }
             $result = html::table($table);
             // printable export
             if ($type == 'html2') {
                 $header = ['options' => []];
                 $header['options'][] = [0 => format::datetime(format::now()), 1 => '', 2 => $session->company_name . ': ' . $session->book_name, 3 => '', 4 => 'Page 1'];
                 $controllers = application::get(['mvc', 'controllers']);
                 $header['options'][] = [['value' => strip_tags($this->header['name']) . ' (' . implode('-', $controllers) . ')', 'colspan' => 5]];
                 if (isset($this->header['description'])) {
                     $header['options'][] = [$this->header['description']];
                 }
                 $header['options'][] = ['&nbsp;'];
                 // displaying filter
                 if (isset($this->header['filter'])) {
                     $temp2 = [];
                     foreach ($this->header['filter'] as $k => $v) {
                         $header['options'][] = [strip_tags($k) . ':', strip_tags($v)];
                     }
                     $header['options'][] = ['&nbsp;'];
                 }
                 $header = html::table($header);
                 layout::render_as($header . $result, 'text/html');
             }
     }
     return $result;
 }
Exemplo n.º 9
0
<?php

echo loader_box('cms/nav');
loader_import('saf.HTML');
echo template_simple(CMS_JS_ALERT_MESSAGE, $GLOBALS['cgi']);
if (false && @is_dir(site_docroot() . '/inc/app/sitetracker')) {
    echo html::table(html::tr(html::td(html::h1(intl_get('Inbox')) . loader_box('cms/messages/inbox') . html::hr() . html::h1(intl_get('Bookmarks')) . loader_box('cms/bookmarks'), array('valign' => 'top', 'width' => '66%', 'style' => 'padding-right: 10px')) . html::td(loader_box('sitetracker/stats/summary'), array('valign' => 'top', 'width' => '33%', 'style' => 'padding-left: 10px'))), array('border' => 0, 'cellpadding' => 0, 'cellspacing' => 0, 'width' => '100%'));
} else {
    echo html::table(html::tr(html::td(html::h1(intl_get('Inbox')) . loader_box('cms/messages/inbox') . html::h1(intl_get('Drafts')) . loader_box('cms/autosave/drafts'), array('valign' => 'top', 'width' => '66%', 'style' => 'padding-right: 10px')) . html::td(html::h1(intl_get('Bookmarks')) . loader_box('cms/bookmarks'), array('valign' => 'top', 'width' => '33%', 'style' => 'padding-left: 10px'))), array('border' => 0, 'cellpadding' => 0, 'cellspacing' => 0, 'width' => '100%'));
}
Exemplo n.º 10
0
 /**
  * Details - render table
  *
  * @param array $rows
  * @param array $values
  * @param array $options
  */
 public function render_container_type_details_rows($rows, $values, $options = [])
 {
     $result = '';
     // empty_warning_message
     if (empty($options['details_new_rows']) && empty($values) && isset($options['details_empty_warning_message'])) {
         if (empty($options['details_empty_warning_message'])) {
             return html::message(['type' => 'warning', 'options' => [object_content_messages::no_rows_found]]);
         } else {
             return html::message(['type' => 'warning', 'options' => [$options['details_empty_warning_message']]]);
         }
     }
     // building table
     $table = ['header' => ['row_number' => '', 'row_data' => '', 'row_delete' => ''], 'options' => [], 'skip_header' => true];
     if (!empty($options['details_11'])) {
         $table['class'] = 'table grid_table_details_11';
         $table['header'] = ['row_data' => ''];
     }
     // header rows for table
     if ($options['details_rendering_type'] == 'table') {
         foreach ($rows as $k => $v) {
             array_key_sort($v['elements'], ['order' => SORT_ASC]);
             // group by
             $groupped = [];
             foreach ($v['elements'] as $k2 => $v2) {
                 $groupped[$v2['options']['label_name'] ?? ''][$k2] = $v2;
             }
             foreach ($groupped as $k2 => $v2) {
                 $first = current($v2);
                 $first_key = key($v2);
                 foreach ($v2 as $k3 => $v3) {
                     // hidden row
                     if ($k === $this::hidden && !application::get('flag.numbers.frontend.html.form.show_field_settings')) {
                         $v3['options']['row_class'] = ($v3['options']['row_class'] ?? '') . ' grid_row_hidden';
                     }
                     $data['options'][$k][$k2][$k3] = ['label' => $this->render_element_name($first), 'options' => $v3['options'], 'row_class' => $v3['options']['row_class'] ?? null];
                 }
             }
         }
         // add a row to a table
         $table['options']['__header'] = ['row_number' => ['value' => '&nbsp;', 'width' => '1%'], 'row_data' => ['value' => html::grid($data), 'width' => !empty($options['details_11']) ? '100%' : '98%'], 'row_delete' => ['value' => '&nbsp;', 'width' => '1%']];
     }
     // we must sort
     array_key_sort($rows, ['order' => SORT_ASC]);
     // generating rows
     $row_number = 1;
     // 1 to 1
     if (!empty($options['details_11'])) {
         $max_rows = 1;
         $processing_values = 1;
     } else {
         $max_rows = count($values) + ($options['details_new_rows'] ?? 0);
         $processing_values = !empty($values);
     }
     do {
         // we exit if there's no rows and if we have no values
         if ($row_number > $max_rows) {
             break;
         }
         // render
         $data = ['options' => []];
         // grab next element from an array
         if ($processing_values) {
             if (!empty($options['details_11'])) {
                 $k0 = null;
                 $v0 = $values;
             } else {
                 $k0 = key($values);
                 $v0 = current($values);
             }
         } else {
             $k0 = $row_number;
             $v0 = [];
         }
         $i0 = $row_number;
         // we need to preset default values
         if (!empty($options['details_parent_key'])) {
             $fields = $this->sort_fields_for_processing($this->detail_fields[$options['details_parent_key']]['subdetails'][$options['details_key']]['elements'], $this->detail_fields[$options['details_parent_key']]['subdetails'][$options['details_key']]['options']);
         } else {
             $fields = $this->sort_fields_for_processing($this->detail_fields[$options['details_key']]['elements'], $this->detail_fields[$options['details_key']]['options']);
         }
         // todo: handle changed field
         foreach ($fields as $k19 => $v19) {
             if (array_key_exists('default', $v19['options']) && !isset($v0[$k19])) {
                 $temp = $this->process_default_value($k19, $v19['options']['default'], $v0[$k19] ?? null, $v0, true);
             }
         }
         // looping though rows
         foreach ($rows as $k => $v) {
             // row_id
             if (empty($options['details_parent_key'])) {
                 $row_id = "form_{$this->form_link}_details_{$options['details_key']}_{$row_number}_row";
             } else {
                 $row_id = "form_{$this->form_link}_subdetails_{$options['details_parent_key']}_{$options['__parent_row_number']}_{$options['details_key']}_{$row_number}_row";
             }
             array_key_sort($v['elements'], ['order' => SORT_ASC]);
             // group by
             $groupped = [];
             foreach ($v['elements'] as $k2 => $v2) {
                 $groupped[$v2['options']['label_name'] ?? ''][$k2] = $v2;
             }
             foreach ($groupped as $k2 => $v2) {
                 $first = current($v2);
                 $first_key = key($v2);
                 if ($first_key == self::separator_horisontal) {
                     $data['options'][$row_number . '_' . $k][$k2][0] = ['value' => html::separator(['value' => $first['options']['label_name'], 'icon' => $first['options']['icon'] ?? null]), 'separator' => true];
                 } else {
                     $first['prepend_to_field'] = ':';
                     foreach ($v2 as $k3 => $v3) {
                         // generate id, name and error name
                         if (empty($options['details_parent_key'])) {
                             // 1 to 1
                             if (!empty($options['details_11'])) {
                                 $name = "{$options['details_key']}[{$k3}]";
                                 $id = "form_{$this->form_link}_details_{$options['details_key']}_{$k3}";
                                 $error_name = "{$options['details_key']}[{$k3}]";
                                 $values_key = [$options['details_key'], $k3];
                                 $field_values_key = [$options['details_key'], $k3];
                             } else {
                                 // 1 to M
                                 $name = "{$options['details_key']}[{$i0}][{$k3}]";
                                 $id = "form_{$this->form_link}_details_{$options['details_key']}_{$row_number}_{$k3}";
                                 $error_name = "{$options['details_key']}[{$k0}][{$k3}]";
                                 $values_key = [$options['details_key'], $k0, $k3];
                                 $field_values_key = [$options['details_key'], $i0, $k3];
                             }
                         } else {
                             $name = "{$options['details_parent_key']}[{$options['__parent_row_number']}][{$options['details_key']}][{$k0}][{$k3}]";
                             $id = "form_{$this->form_link}_subdetails_{$options['details_parent_key']}_{$options['__parent_row_number']}_{$options['details_key']}_{$row_number}_{$k3}";
                             $error_name = "{$options['details_parent_key']}[{$options['__parent_key']}][{$options['details_key']}][{$k0}][{$k3}]";
                             $values_key = [$options['details_parent_key'], $options['__parent_key'], $options['details_key'], $k0, $k3];
                             $field_values_key = [$options['details_parent_key'], $options['__parent_row_number'], $options['details_key'], $k0, $k3];
                         }
                         // error
                         $error = $this->get_field_errors(['options' => ['name' => $error_name]]);
                         // counter for 1 to M only
                         if (!empty($error['counters'])) {
                             $this->error_in_tabs($error['counters']);
                         }
                         // hidden row
                         $hidden = false;
                         if ($k === $this::hidden && !application::get('flag.numbers.frontend.html.form.show_field_settings')) {
                             $v3['options']['row_class'] = ($v3['options']['row_class'] ?? '') . ' grid_row_hidden';
                             $hidden = true;
                         }
                         // generate proper element
                         $value_options = $v3;
                         $value_options['options']['id'] = $id;
                         $value_options['options']['name'] = $name;
                         $value_options['options']['error_name'] = $error_name;
                         $value_options['options']['details_parent_key'] = $options['details_parent_key'] ?? null;
                         $value_options['options']['__parent_row_number'] = $options['__parent_row_number'] ?? null;
                         $value_options['options']['__row_number'] = $row_number;
                         $value_options['options']['__new_row'] = !$processing_values;
                         // need to set values_key
                         $value_options['options']['values_key'] = $values_key;
                         $value_options['options']['field_values_key'] = $field_values_key;
                         // tabindex but not for subdetails
                         if (!$hidden && empty($options['__parent_row_number'])) {
                             $value_options['options']['tabindex'] = $this->tabindex;
                             $this->tabindex++;
                         }
                         // label
                         $label = null;
                         if ($options['details_rendering_type'] == 'grid_with_label') {
                             $label = $this->render_element_name($first);
                         }
                         // add element to grid
                         $data['options'][$row_number . '_' . $k][$k2][$k3] = ['error' => $error, 'label' => $label, 'value' => $this->render_element_value($value_options, $v0[$k3] ?? null, $v0), 'description' => $v3['options']['description'] ?? null, 'options' => $v3['options'], 'row_class' => ($value_options['options']['row_class'] ?? '') . (!($row_number % 2) ? ' grid_row_even' : ' grid_row_odd')];
                     }
                 }
             }
         }
         // increase counter
         if ($processing_values && empty($options['details_11'])) {
             $this->error_in_tabs(['records' => 1]);
         }
         // subdetails
         if (!empty($this->detail_fields[$options['details_key']]['subdetails'])) {
             $tab_id = "form_tabs_{$this->form_link}_subdetails_{$options['details_key']}_{$row_number}";
             $tab_header = ['tabs_subdetails_none' => html::icon(['type' => 'toggle-on'])];
             $tab_values = ['tabs_subdetails_none' => ''];
             $tab_options = ['tabs_subdetails_none' => []];
             // sort subdetail tabs
             $tab_sorted = [];
             foreach ($this->detail_fields[$options['details_key']]['subdetails'] as $k10 => $v10) {
                 $tab_sorted[$k10] = ['order' => $v10['options']['order'] ?? 0];
             }
             array_key_sort($tab_sorted, ['order' => SORT_ASC]);
             // render tabs
             $have_tabs = false;
             foreach ($tab_sorted as $k10 => $v10) {
                 $v10 = $this->detail_fields[$options['details_key']]['subdetails'][$k10];
                 $this->current_tab[] = "{$tab_id}_{$k10}";
                 $labels = '';
                 foreach (['records', 'danger', 'warning', 'success', 'info'] as $v78) {
                     $labels .= html::label2(['type' => $v78 == 'records' ? 'primary' : $v78, 'style' => 'display: none;', 'value' => 0, 'id' => implode('__', $this->current_tab) . '__' . $v78]);
                 }
                 $tab_header[$k10] = i18n(null, $v10['options']['label_name']) . $labels;
                 $tab_values[$k10] = '';
                 // handling override_tabs method
                 if (!empty($this->wrapper_methods['override_tabs']['main'])) {
                     $tab_options[$k10] = call_user_func_array($this->wrapper_methods['override_tabs']['main'], [&$this, &$v10, &$k10, &$v0]);
                     if (empty($tab_options[$k10]['hidden'])) {
                         $have_tabs = true;
                     }
                 } else {
                     $have_tabs = true;
                 }
                 $v10['__values'] = $v0[$v10['options']['details_key']] ?? [];
                 $v10['__parent_row_number'] = $row_number;
                 $v10['__parent_key'] = $k0;
                 $temp = $this->render_container_type_subdetails($v10['options']['container_link'], $v10);
                 if ($temp['success']) {
                     $tab_values[$k10] .= $temp['data']['html'];
                 }
                 // we must unset it
                 array_pop($this->current_tab);
             }
             // if we do not have tabs
             if (!$have_tabs) {
                 $tab_options['tabs_subdetails_none']['hidden'] = true;
             }
             $subdetails = html::tabs(['id' => $tab_id, 'header' => $tab_header, 'options' => $tab_values, 'class' => 'tabs_subdetails', 'tab_options' => $tab_options]);
             // add row to the end
             $data['options'][$row_number . '_subdetails']['subdetails']['subdetails'] = ['error' => null, 'label' => null, 'value' => $subdetails, 'description' => null, 'options' => ['percent' => 100], 'row_class' => !($row_number % 2) ? 'grid_row_even' : 'grid_row_odd'];
         }
         // delete link
         if (empty($options['details_cannot_delete'])) {
             $link = html::a(['href' => 'javascript:void(0);', 'value' => '<i class="fa fa-trash-o"></i>', 'onclick' => "if (confirm('" . strip_tags(i18n(null, object_content_messages::confirm_delete)) . "')) { numbers.form.details_delete_row('form_{$this->form_link}_form', '{$row_id}'); } return false;"]);
         } else {
             $link = '';
             unset($table['header']['row_delete']);
         }
         // add a row to a table
         $table['options'][$row_number] = ['row_number' => ['value' => format::id($row_number) . '.', 'width' => '1%', 'row_id' => $row_id], 'row_data' => ['value' => html::grid($data), 'width' => !empty($options['details_11']) ? '100%' : '98%'], 'row_delete' => ['value' => $link, 'width' => '1%']];
         $row_number++;
         // we need to determine if we have values
         if (next($values) === false) {
             $processing_values = false;
         }
     } while (1);
     return html::table($table);
 }
 function reloadAttachments($_composeID)
 {
     $bocompose =& CreateObject('felamimail.bocompose', $_composeID);
     $tableRows = array();
     $table = '';
     $imgClearLeft = $GLOBALS['phpgw']->common->image('felamimail', 'clear_left');
     foreach ((array) $bocompose->sessionData['attachments'] as $id => $attachment) {
         switch (strtoupper($attachment['type'])) {
             case 'MESSAGE/RFC822':
                 $linkData = array('menuaction' => 'felamimail.uidisplay.display', 'uid' => $attachment['uid'], 'part' => $attachment['partID']);
                 $windowName = 'displayMessage_';
                 $att_link = "egw_openWindowCentered('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "','{$windowName}',700,egw_getWindowOuterHeight()); return false;";
                 break;
             case 'IMAGE/JPEG':
             case 'IMAGE/PNG':
             case 'IMAGE/GIF':
             default:
                 $linkData = array('menuaction' => 'felamimail.uicompose.getAttachment', 'attID' => $id, '_composeID' => $_composeID);
                 $windowName = 'displayAttachment_';
                 $att_link = "egw_openWindowCentered('" . $GLOBALS['phpgw']->link('/index.php', $linkData) . "','{$windowName}',800,600);";
                 break;
         }
         $tempArray = array('1' => '<a href="#" onclick="' . $att_link . '">' . $attachment['name'] . '</a>', '2' => $attachment['type'], '.2' => "style='text-align:center;'", '3' => $attachment['size'], '4' => "<img src='{$imgClearLeft}' onclick=\"fm_compose_deleteAttachmentRow(this,'{$_composeID}','{$id}')\">");
         $tableRows[] = $tempArray;
     }
     if (count($tableRows) > 0) {
         $table = html::table($tableRows, "style='width:100%'");
     }
     $response =& new xajaxResponse();
     $response->addAssign('divAttachments', 'innerHTML', $table);
     return $response->getXML();
 }
Exemplo n.º 12
0
    /**
     * Render widget
     *
     * @return mixed
     */
    public function render()
    {
        $result = '';
        // action bar
        $result .= '<div style="text-align: right;">';
        $result .= html::a(array('value' => html::icon(['type' => 'comment']) . ' ' . i18n(null, 'New'), 'href' => 'javascript:void(0);', 'onclick' => "numbers.frontend_form.trigger_submit('#form_numbers_frontend_html_widgets_comments_model_form_comment_form', false, true); numbers.modal.show('widgets_comments_{$this->widget_link}_comment');"));
        $result .= '</div>';
        $result .= '<hr class="simple" />';
        // form
        $pk = http_build_query2($this->options['pk']);
        $js = <<<TTT
\t\t\tvar mask_id = 'widgets_comments_{$this->widget_link}_mask';
\t\t\t\$.ajax({
\t\t\t\turl: numbers.controller_full,
\t\t\t\tmethod: 'post',
\t\t\t\tdata: '__ajax=1&__ajax_form_id=widgets_comments_{$this->widget_link}_list&{$pk}',
\t\t\t\tdataType: 'json',
\t\t\t\tsuccess: function (data) {
\t\t\t\t\tif (data.success) {
\t\t\t\t\t\t\$('#widgets_comments_{$this->widget_link}_wrapper').html(data.html);
\t\t\t\t\t\teval(data.js);
\t\t\t\t\t\t// remove mask after 100 miliseconds to let js to take affect
\t\t\t\t\t\tsetTimeout(function() {
\t\t\t\t\t\t\t\$('#' + mask_id).unmask();
\t\t\t\t\t\t\t// we need to trigger resize to redraw a screen
\t\t\t\t\t\t\t\$(window).trigger('resize');
\t\t\t\t\t\t}, 100);
\t\t\t\t\t}
\t\t\t\t}
\t\t\t});
TTT;
        $form = new numbers_frontend_html_widgets_comments_model_form_comment(['input' => $this->options['input'], 'no_actions' => true, 'bypass_hidden_values' => $this->options['pk'], 'other' => ['model' => $this->options['model'], 'pk' => $this->options['pk'], 'map' => $this->options['map']], 'on_success_js' => "numbers.modal.hide('widgets_comments_{$this->widget_link}_comment');" . $js]);
        $body = $form->render();
        $footer = html::button2(['name' => 'submit_comment', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.frontend_form.trigger_submit('#form_numbers_frontend_html_widgets_comments_model_form_comment_form', true); return false;"]);
        $result .= html::modal(['id' => "widgets_comments_{$this->widget_link}_comment", 'class' => 'large', 'title' => i18n(null, 'Add Comment'), 'body' => $body, 'footer' => $footer]);
        // list of comments in descending order
        $where = [];
        foreach ($this->options['map'] as $k => $v) {
            $where[$v] = $this->options['pk'][$k];
        }
        $datasource = new numbers_frontend_html_widgets_comments_model_datasource_comments();
        $data = $datasource->get(['model' => $this->options['model'], 'where' => $where]);
        if (!empty($data)) {
            $table = ['header' => ['id' => ['value' => '#', 'width' => '1%'], 'inserted' => ['value' => i18n(null, 'Date & Time'), 'width' => '1%', 'nowrap' => true], 'important' => ['value' => i18n(null, 'Important'), 'width' => '1%'], 'em_entity_name' => ['value' => i18n(null, 'Entity'), 'width' => '10%'], 'comment_value' => i18n(null, 'Comment')], 'options' => []];
            $row_number = 1;
            foreach ($data as $k => $v) {
                // we need to hide old comments
                $row_style = '';
                if ($row_number > 10) {
                    $row_style = 'display: none;';
                }
                $table['options'][$v['id']] = ['id' => ['value' => $row_number . '.', 'row_style' => $row_style, 'row_class' => "widgets_comments_{$this->widget_link}_list_hiden " . ($v['important'] ? 'success' : null)], 'inserted' => format::datetime($v['inserted']), 'important' => ['value' => $v['important'] ? i18n(null, 'Yes') : ''], 'em_entity_name' => ['value' => $v['em_entity_name'], 'width' => '10%', 'nowrap' => true], 'comment_value' => nl2br($v['comment_value'])];
                $row_number++;
            }
            $result_list = html::table($table);
            // link to show all rows
            $total_comments = count($data);
            if ($total_comments > 10) {
                $result_list .= '<div style="text-align: right;">' . html::a(['href' => 'javascript:void(0);', 'value' => i18n(null, '[count] comment(s) are hidden. Show all comments.', ['replace' => ['[count]' => $total_comments - 10]]), 'onclick' => "\$('.widgets_comments_{$this->widget_link}_list_hiden').show(); \$(this).hide();"]) . '</div>';
            }
        } else {
            $result_list = html::message(['type' => 'warning', 'options' => [i18n(null, object_content_messages::no_rows_found)]]);
        }
        // if we are making an ajax call
        if (!empty($this->options['input']['__ajax']) && ($this->options['input']['__ajax_form_id'] ?? '') == "widgets_comments_{$this->widget_link}_list") {
            layout::render_as(['success' => true, 'error' => [], 'html' => $result_list, 'js' => ''], 'application/json');
        }
        // load mask
        numbers_frontend_media_libraries_loadmask_base::add();
        // put list into result
        $result .= "<div id=\"widgets_comments_{$this->widget_link}_mask\"><div id=\"widgets_comments_{$this->widget_link}_wrapper\">" . $result_list . '</div></div>';
        // wrap everything into segment
        if (isset($this->options['segment'])) {
            $temp = is_array($this->options['segment']) ? $this->options['segment'] : [];
            $temp['value'] = $result;
            $result = html::segment($temp);
        }
        // anchor
        $result = html::a(['name' => "widgets_comments_{$this->widget_link}_anchor"]) . $result;
        return $result;
    }
Exemplo n.º 13
0
 function createAccountDataTable($_identities)
 {
     $linkData = array('menuaction' => 'felamimail.uipreferences.editAccountData');
     $urlEditAccountData = $GLOBALS['phpgw']->link('/index.php', $linkData);
     if (is_array($_identities) && !empty($_identities)) {
         foreach ($_identities as $identity) {
             $description = $identity['id'] . ":" . $identity['realName'] . " " . $identity['organization'] . " <" . $identity['emailAddress'] . ">";
             $description = $identity['default'] == true ? $description . ' (' . lang('default') . ')' : $description;
             $tableRows[] = array('1' => $identity['id'] != -1 ? html::checkbox('accountID', false, $identity['id']) : '', '.1' => 'style="width:30px"', '2' => '<a href="' . $urlEditAccountData . "&accountID=" . $identity['id'] . '">' . @htmlspecialchars($description, ENT_QUOTES, $this->charset) . '</a>');
         }
         return html::table($tableRows, 'style="width:100%;"');
     }
     return '';
 }
Exemplo n.º 14
0
 /**
  * Data default renderer
  *
  * @return string
  */
 private final function render_data_default()
 {
     $result = '';
     // if we have no rows we display a messsage
     if ($this->num_rows == 0) {
         return html::message(['type' => 'warning', 'options' => [i18n(null, object_content_messages::no_rows_found)]]);
     }
     $counter = 1;
     $table = ['header' => [], 'options' => []];
     // action flags
     $actions = [];
     if (object_controller::can('record_view')) {
         $actions['view'] = true;
     }
     // generate columns
     foreach ($this->columns as $k => $v) {
         // if we can not view we skip action column
         if (empty($actions) && $k == 'action') {
             continue;
         }
         $table['header'][$k] = ['value' => i18n(null, $v['name']), 'nowrap' => true, 'width' => $v['width'] ?? null];
     }
     // generate rows
     foreach ($this->rows as $k => $v) {
         // process all columns first
         $row = [];
         foreach ($this->columns as $k2 => $v2) {
             // if we can not view we skip action column
             if (empty($actions) && $k2 == 'action') {
                 continue;
             }
             $value = [];
             // create cell properties
             foreach (['width', 'align'] as $v3) {
                 if (isset($v2[$v3])) {
                     $value[$v3] = $v2[$v3];
                 }
             }
             // process rows
             if ($k2 == 'action') {
                 $value['value'] = [];
                 if (!empty($actions['view'])) {
                     $mvc = application::get('mvc');
                     $pk = extract_keys($this->model_object->pk, $v);
                     $url = $mvc['controller'] . '/_edit?' . http_build_query2($pk);
                     $value['value'][] = html::a(['value' => i18n(null, 'View'), 'href' => $url]);
                 }
                 $value['value'] = implode(' ', $value['value']);
             } else {
                 if ($k2 == 'row_number') {
                     $value['value'] = format::id($counter) . '.';
                 } else {
                     if ($k2 == 'offset_number') {
                         $value['value'] = format::id($this->offset + $counter) . '.';
                     } else {
                         if (!empty($v2['options_model'])) {
                             if (strpos($v2['options_model'], '::') === false) {
                                 $v2['options_model'] .= '::options';
                             }
                             $params = $v2['options_params'] ?? [];
                             if (!empty($v2['options_depends'])) {
                                 foreach ($v2['options_depends'] as $k0 => $v0) {
                                     $params[$k0] = $v[$v0];
                                 }
                             }
                             $crypt_object = new crypt();
                             $hash = $crypt_object->hash($v2['options_model'] . serialize($params));
                             if (!isset($this->cached_options[$hash])) {
                                 $method = factory::method($v2['options_model'], null, true);
                                 $this->cached_options[$hash] = call_user_func_array($method, [['where' => $params]]);
                             }
                             if (isset($this->cached_options[$hash][$v[$k2]])) {
                                 $value['value'] = $this->cached_options[$hash][$v[$k2]]['name'];
                             } else {
                                 $value['value'] = null;
                             }
                         } else {
                             if (!empty($v2['options']) && !is_array($v[$k2])) {
                                 if (isset($v2['options'][$v[$k2]])) {
                                     $value['value'] = $v2['options'][$v[$k2]]['name'];
                                 } else {
                                     $value['value'] = null;
                                 }
                             } else {
                                 if (isset($v[$k2])) {
                                     $value['value'] = $v[$k2];
                                 } else {
                                     $value['value'] = null;
                                 }
                             }
                         }
                     }
                 }
             }
             // put value into row
             if (!empty($v2['format'])) {
                 $format_options = $v2['format_options'] ?? [];
                 if (!empty($v2['format_depends'])) {
                     $format_depends = $v2['format_depends'];
                     $this->process_params_and_depends($format_depends, $v);
                     $format_options = array_merge_hard($format_options, $format_depends);
                 }
                 $method = factory::method($v2['format'], 'format');
                 $value['value'] = call_user_func_array([$method[0], $method[1]], [$value['value'], $format_options]);
             }
             $row[$k2] = $value;
         }
         // put processed columns though user defined function
         if (method_exists($this, 'render_data_rows')) {
             $table['options'][$counter] = $this->render_data_rows($row, $v);
         } else {
             $table['options'][$counter] = $row;
         }
         $counter++;
     }
     return html::table($table);
 }
 public static function simple($attributes, $headers, $rows)
 {
     return html::table($attributes, self::thead($headers) . self::tbody($rows));
 }