Пример #1
0
 protected function _build()
 {
     $this->trigger('onbuild');
     if ($is_pk = $this->get_par('db-field-is-pkey')) {
         $this->att('class', 'osy-pkey', true)->att('osypk', $this->get_par('db-field-connected'));
     }
     $this->build();
     return parent::_build(-1);
 }
Пример #2
0
 protected function build()
 {
     $form = $this->closest('form');
     if (is_object($form)) {
         $form->att('enctype', 'multipart/form-data');
     }
     $label = $this->add(new Tag('label'))->att('class', 'osy-filebox-virtual')->att('for', $this->id);
     $label->add('<span class="osy-filebox-filename"></span>');
     $label->add('<span class="fa fa-cloud-upload osy-filebox-button"></span>');
     if (!empty($_REQUEST[$this->id . '_message'])) {
         $this->add(Tag::create('div'))->att('class', 'osy-filebox-message')->add($_REQUEST[$this->id . '_message']);
     }
 }
Пример #3
0
 public function render()
 {
     $this->sendHeader();
     $html = new Tag('html');
     $sections = $this->get('section');
     foreach ($sections as $section => $tagSection) {
         if ($sectionContent = $this->get($section)) {
             foreach ($sectionContent as $key => $elems) {
                 foreach ($elems as $elem) {
                     if (empty($elem)) {
                         continue;
                     }
                     switch ($key) {
                         case 'jsfile':
                             $tagSection->add(new Tag('script'))->att('src', $elem);
                             break;
                         case 'jscode':
                             $elem = trim($elem);
                             if ($elem[0] == '<') {
                                 $tagSection->add(PHP_EOL . $elem);
                                 break;
                             }
                             $script = $tagSection->add(new Tag('script'));
                             $script->add($elem);
                             break;
                         case 'css':
                             $tagSection->add(new Tag('link'))->att(array('href' => $elem, 'rel' => 'stylesheet'));
                             break;
                         case 'error':
                             $tagSection->add(new Tag('div'))->att('class', 'hidden')->att('id', 'error')->add(implode('<br>', $elem));
                             break;
                     }
                 }
             }
         }
         $html->add($tagSection);
     }
     return '<!DOCTYPE ' . $this->get('doctype') . '>' . PHP_EOL . $html;
 }
Пример #4
0
 protected function build()
 {
     if ($range = $this->get_par('slider-range')) {
         $this->att('data-range', $range);
         $this->add(new HiddenBox($this->id . '_min'));
         $this->add(new HiddenBox($this->id . '_max'));
     } else {
         $this->add(new HiddenBox($this->id));
     }
     $min = $this->get_par('min');
     $div_min_max = $this->add(tag::create('div'));
     $div_min_max->att('class', 'osy-slider-min-max');
     $div_min_max->add('&nbsp');
     if ($min == '0' or !empty($min)) {
         if ($min[0] == '$') {
             eval('$min = ' . $min . ';');
         }
         $div_min_max->add('<span class="lbl-min">' . $min . '</span>');
         $this->att('data-min', $min);
     }
     $bar = $this->add(tag::create('div'))->att('class', 'osy-slider-bar');
     if ($max = $this->get_par('max')) {
         if ($max[0] == '$') {
             eval('$max = ' . $max . ';');
         }
         $div_min_max->add('<span class="lbl-max">' . $max . '</span>');
         $this->att('data-max', $max);
     }
     if (!empty($_REQUEST[$this->id . '_min']) && !empty($_REQUEST[$this->id . '_max'])) {
         $this->att('data-values', $_REQUEST[$this->id . '_min'] . ',' . $_REQUEST[$this->id . '_max']);
     }
     $this->add('<script>
     oslider.onevent("onstop","' . $this->id . '",function(event,ui){
     ' . $this->get_par('onstop') . '
     });
     </script>');
     //$this->add('<span class="osy-slider-result"></span>');
 }
Пример #5
0
 protected function buildFieldSearch()
 {
     if (!empty($_POST['ajax'])) {
         return;
     }
     $div = new Dummy('osy-dataview-2-search');
     $div->att('class', "osy-dataview-2-search");
     $div->par('colspan', '100', function ($key, $val, $self) {
         $self->man('onbuild', 'colspan', function ($key, $val, $self) {
             $cel = $self->closest('td,th');
             if (!is_object($cel)) {
                 return;
             }
             $cel->att('colspan', '100');
         });
     });
     $this->form->put($div, '', 'bar-search', 2, 1);
     $div->add("Cerca");
     $div->add(new TextBox('search_value'))->att('size', '40');
     $div->add(" in ");
     $select = $div->add(new ComboBox('search_field'));
     //Tasto ricerca
     $div->add(new Button('btn_search'))->att('label', 'Ricerca');
     //Tasto pulisci filtro
     $div->add(new Button('btn_search_reset'))->att('label', 'Elimina filtro');
     //Contenitore dei filtri attivi
     $div_flt_cnt = $div->add(tag::create("div"))->att('class', 'filter-active');
     if (array_key_exists('filter', $_POST) && is_array($_POST['filter'])) {
         foreach ($_POST['filter'] as $k => $v) {
             $div_flt = $div_flt_cnt->add(tag::create('div'))->att("class", "filter");
             $div_flt->add(new hidden_box("filter[{$k}]"))->Att('value', $v);
             switch ($k[0]) {
                 case '!':
                 case '€':
                 case '$':
                 case '#':
                     $k = substr($k, 1);
                     break;
                 case '_':
                     list($a, $k) = explode(',', $k);
                     break;
             }
             $div_flt->add("{$k} : {$v}");
         }
         $div->add($div_flt_cnt);
     } else {
         $div->par('init-cell', 'hidden', function ($key, $val, $self) {
             $self->man('onbuild', 'init-cell', function ($key, $val, $self) {
                 $cel = $self->closest('td,th');
                 if (!is_object($cel)) {
                     return;
                 }
                 $cel->att('class', $val)->att('colspan', '100');
             });
         });
     }
     $div_flt_cnt->add(tag::create("div"))->att("style", "clear: both");
 }
Пример #6
0
 public function buildAjax()
 {
     $form_pkey = array();
     if ($form = $this->get_par('form-related')) {
         $form_par = $this->getFormParam($form, true);
         $form_pkey = $form_par['pkey'];
     }
     $tbl = new Tag('div');
     $sql = $this->replacePlaceholder($this->get_par('datasource-sql'));
     $rs = $this->db->exec_query("SELECT * FROM (" . $sql . ") a", null, 'ASSOC');
     $cols = $this->db->get_columns();
     foreach ($cols as $col) {
         if ($col['name'] == '_group') {
             $rs = $this->groupRs($rs);
         }
     }
     $__g = '';
     foreach ($rs as $rec) {
         $tr = tag::create('div')->att('class', 'row');
         $__k = array();
         $_oid = array();
         foreach ($rec as $key => $fld) {
             $val = $fld;
             if (in_array($key, $form_pkey)) {
                 $__k[] = 'pkey[' . $key . ']=' . $val;
                 $_oid[] = $val;
                 continue;
             }
             $print = true;
             if ($key[0] == '_') {
                 $print = false;
                 switch ($key) {
                     case '_id':
                         $tr->att('data-oid', $val);
                         $print = false;
                         break;
                     case '_label':
                         $tr->att('data-label', $val);
                         $print = false;
                         break;
                     case '_group':
                         if ($val != $__g) {
                             $__g = $val;
                         } else {
                             $val = '&nbsp;';
                         }
                         $val = '<span class="osy-textsearch-inline-group">' . $val . '</span>';
                         $print = true;
                         break;
                     case '_img64x2':
                         $dimcls = 'osy-image-med';
                         //no-break
                     //no-break
                     case '_img64':
                         $val = '<span class="' . (empty($dimcls) ? 'osy-image-min' : $dimcls) . '">' . (empty($fld) ? '<span class="fa fa-ban"></span>' : '<img src="data:image/png;base64,' . base64_encode($fld) . '">') . '</span>';
                         $print = true;
                         break;
                     case '_label':
                         $tr->att('data-label', $val);
                         break;
                 }
             }
             if ($print) {
                 $tr->add(tag::create('div'))->add($val);
             }
         }
         //$tr->add('<br class="clear">');
         $tbl->add($tr);
         if (!empty($__k)) {
             $tr->att('data-pkey', implode('&', $__k));
             $tr->att('data-oid', implode('&', $_oid));
         }
     }
     return $tbl;
 }
Пример #7
0
 private function buildBranch($dat, $lev = 0)
 {
     if (empty($dat)) {
         return;
     }
     $len = count($dat) - 1;
     $cur_val = get_global($this->name, $_REQUEST);
     foreach ($dat as $k => $rec) {
         $val = array();
         foreach ($rec as $j => $v) {
             if (!is_numeric($j)) {
                 continue;
             }
             if (count($val) == 2) {
                 continue;
             }
             $sta = empty($lev) ? '' : '|';
             $end = $len == $k ? "\\" : "|";
             $val[] = empty($val) ? $v : str_repeat('&nbsp;', $lev * 5) . $v;
         }
         $sel = $cur_val == $val[0] ? ' selected' : '';
         $opt = $this->add(tag::create('option'))->att('value', $val[0]);
         $opt->add(nvl($val[1], $val[0]));
         if ($cur_val == $val[0]) {
             $opt->att('selected', 'selected');
         }
         if (array_key_exists($val[0], $this->__grp)) {
             $this->buildBranch($this->__grp[$val[0]], $lev + 1);
         }
     }
 }
Пример #8
0
 private function __cell($content = null, $colspan = null)
 {
     if (is_null($content)) {
         return;
     }
     $cel = $this->__crow->add(tag::create($this->__tag[1]));
     if (!empty($colspan)) {
         $cel->att('colspan', $colspan);
     }
     $cel->add2($content);
     return $cel;
 }
Пример #9
0
 public function getFormIconify()
 {
     $usr = $this->getCurrentUser();
     $sql = "SELECT f.o_id as form_id,f.o_nam as form_name,ic.p_vl as icon,coalesce(fw.p_vl,'640') as form_width,coalesce(fh.p_vl,'480') as form_height " . "FROM osy_obj_rel a " . "INNER JOIN osy_obj f ON (a.o_2 = f.o_own AND f.o_typ = 'form') " . "INNER JOIN osy_obj_prp i ON (f.o_id = i.o_id AND i.p_id = 'iconify' AND i.p_vl = '1') " . "LEFT JOIN osy_obj_prp ic ON (f.o_id = ic.o_id AND ic.p_id = 'iconify-icon') " . "LEFT JOIN osy_obj_prp fw ON (f.o_id = fw.o_id AND fw.p_id = 'width') " . "LEFT JOIN osy_obj_prp fh ON (f.o_id = fh.o_id AND fh.p_id = 'height') " . "WHERE a.o_1 = CONCAT('instance://',?,'/') AND a.r_typ = 'instance+application'";
     //echo $sql;
     $res = $this->model->dbo->exec_query($sql, array($this->request->get('instance.id')));
     $iconify = new Tag('span');
     $iconify->add(print_r($this->request->get('input'), true));
     if (!empty($res)) {
         $iconify = new Tag('ul');
         foreach ($res as $rec) {
             $item = new Tag('span');
             $item->att('id', $rec['form_name'])->att('data-fid', $rec['form_id'])->att('data-form-width', $rec['form_width'])->att('data-form-height', $rec['form_height'])->add(str_replace('CURRENT_USER', $usr, $rec['icon']));
             $iconify->add(tag::create('li'))->add($item);
         }
     }
     return $iconify->att('id', 'iconify-forms')->att('style', 'display:none;');
 }
Пример #10
0
 private function dataPivot($tr)
 {
     $data = array();
     $hcol = array();
     $hrow = array();
     $fcol = null;
     foreach ($this->__dat as $i => $rec) {
         $col = $row = null;
         foreach ($rec as $fld => $val) {
             if ($fld == '_pivot') {
                 $col = $val;
                 if (!in_array($col, $hcol)) {
                     $hcol[] = $col;
                 }
             } elseif (is_null($col)) {
                 if (empty($i)) {
                     $hcol[0] = $fld;
                 }
                 $row = $val;
                 if (!in_array($row, $hrow)) {
                     $hrow[] = $row;
                 }
             } else {
                 $data[$col][$row][] = $val;
             }
         }
     }
     $data_pivot = array();
     ksort($hrow);
     ksort($hcol);
     foreach ($hrow as $row) {
         foreach ($hcol as $i => $col) {
             if (empty($i)) {
                 $drow[$col] = $row;
                 //Aggiuno la label della riga
             } else {
                 $drow[$col] = array_key_exists($row, $data[$col]) ? array_sum($data[$col][$row]) : '0';
             }
         }
         $data_pivot[] = $drow;
     }
     $this->__dat = $data_pivot;
     $ncol = array();
     foreach ($hcol as $i => $col) {
         if (empty($i)) {
             continue;
         }
         $tr->add(tag::create('th'))->att('class', 'no-order')->add($col);
     }
     //return ; //Restituisco il record contenente l'header delle colonne in
 }