protected function build() { $this->add(new HiddenBox($this->id)); $build_tag_from_datasource = false; if ($this->get_par('database-save-parameters')) { $this->att('class', 'osy-taglist-onextab', true); $build_tag_from_datasource = true; } $ul = $this->add(tag::create('ul')); if ($sql = $this->get_par('datasource-sql')) { $sql = HelperOsy::replacevariable($sql); $res = $this->db->exec_query($sql, null, 'NUM'); $datalist = $this->add(tag::create('datalist')); $datalist->att('id', $this->id . '_data'); foreach ($res as $k => $rec) { if ($rec[2] == 1) { $ul->add('<li class="osy-taglist-entry" tid="' . $rec[0] . '"><span class="osy-taglist-entry-text">' . $rec[1] . '</span><a href="#" class="osy-taglist-entry-remove">remove</a></li>'); } $datalist->add(tag::create('option'))->add($rec[1]); } } if (!$build_tag_from_datasource && !empty($_REQUEST[$this->id])) { $item_list = explode(',', $_REQUEST[$this->id]); foreach ($item_list as $k => $v) { $ul->add('<li class="osy-taglist-entry" pos="' . $k . '"><span class="osy-taglist-entry-text">' . $v . '</span><a href="#" class="osy-taglist-entry-remove">remove</a></li>'); } } $txt = $ul->add(tag::create('li'))->att('class', 'listbuilder-entry-text')->add(tag::create('input'))->att('name', $this->id . '_add')->att('type', 'text')->att('class', 'add osy-taglist-input'); if (isset($datalist)) { $txt->att('list', $this->id . '_data'); } $ul->add('<br style="clear: both">'); }
protected function build() { if (!($txt = get_global($this->id, $_REQUEST))) { $txt = $this->get_par('text'); $txt = HelperOsy::replaceVariable($txt); } $this->add($txt); }
protected function init() { $this->form->att('class', self::getParam('form-type')); $this->param['default_component_parent'] = 0; $this->response->addCss('/vendor/font-awesome-4.2.0/css/font-awesome.min.css'); $this->response->addCss('/vendor/jquery/smoothness/jquery-ui-1.9.1.custom.css'); $this->response->addCss(OSY_WEB_ROOT . HelperOsy::nvl($this->param['css-instance'], '/css/style.css')); $this->response->addJsFile('/vendor/jquery/jquery-1.10.2.min.js'); $this->response->addJsFile('/vendor/jquery/jquery-ui-1.10.3.custom.min.js'); $this->response->addJsFile('js/view/Form.js'); $this->response->addJsFile('js/view/FormMain.js'); }
protected function build() { $a_val = array(); if ($val = $this->get_par('values')) { $a_val_raw = explode(',', $val); foreach ($a_val_raw as $k => $val) { $a_val[] = explode('=', $val); } } if ($sql = $this->get_par('datasource-sql')) { $sql = HelperOsy::replaceVariable($sql); $sql = HelperOsy::parseString($sql); $a_val = $this->db->exec_query($sql, null, 'NUM'); } $dir = $this->get_par('direction'); foreach ($a_val as $k => $val) { //$tr = $this->add(tag::create('tr')); //$tr->add(tag::create('td'))->add('<input type="radio" name="'.$this->id.'" value="'.$val[0].'"'.(!empty($_REQUEST[$this->id]) && $_REQUEST[$this->id] == $val[0] ? ' checked' : '').'>'); //$tr->add(tag::create('td'))->add($val[1]); $rd = new RadioBox($this->id); $rd->value = $val[0]; if ($this->cols) { $rst = $k % $this->cols; if (empty($rst)) { $row += 10; } $col = $resto * 10 + 10; $this->put(null, $rd . ' ' . $val[1], $row, $col); } elseif ($dir == 'O') { $this->put(null, $rd . ' ' . $val[1], 10, $k * 10 + 9); } else { $this->put(null, $rd . ' ' . $val[1], $k * 10 + 9, 10); } //$this->put(null,$val[1],$k+9,10); } parent::build(); }
/** ** @abstract Metodo che si occupa di caricare i parametri dei diversi campi prelevati dal db ** all'interno dell'oggetto form al fine di instanziarli e visualizzarli. ** @private ** @return void **/ private static function buildForm() { foreach (self::$model->field as $id => $f) { /*Istanzio il componente attraverso la ComponentFactory*/ self::$model->field[$id]['object'] = ComponentFactory::create($f); //If ComponentFactory don't return a valid component obscure visibility if (!is_object(self::$model->field[$id]['object'])) { self::$model->field[$id]['visible'] = false; continue; } //Define visible the component (model will work on the visible component) self::$model->field[$id]['visible'] = true; if (array_key_exists('ajax', $_REQUEST) && $_REQUEST['ajax'] == $f['name']) { //Da migliorare creando metodo separato di gestione self::$form->put(self::$model->field[$id]['object'], 'dummy', 'dummy', 1, 1, 0); return; } self::$model->field[$id]['object']->appendRequired(self::$page); //If component is displayed on foot add is to command array if (!empty($f['in-command-panel'])) { self::$model->field[$id]['object']->att('class', 'extra wmin80'); self::$param['command'][] = self::$model->field[$id]['object']; continue; } //Add component on the form self::$form->put(self::$model->field[$id]['object'], $f['label'], $f['name'], HelperOsy::nvl($f['position-row'], -1), HelperOsy::nvl($f['position-column'], 0), HelperOsy::nvl($f['position-panel-parent'], 0)); } }
protected function excelBuild($sql) { $sql = HelperOsy::parseString($sql); require_once OSY_PATH_LIB_EXT . '/phpexcel-1.8.0/PHPExcel.php'; require_once OSY_PATH_LIB_EXT . '/phpexcel-1.8.0/PHPExcel/Writer/Excel2007.php'; $sql = HelperOsy::replaceVariable($sql); $sql = HelperOsy::parseString($sql); if (!empty($_REQUEST['osy']['tid'])) { $sql = "SELECT a.* \n FROM ({$sql}) a \n WHERE a.\"_tab\" = '{$_REQUEST['osy']['tid']}'\n ORDER BY 1"; //mail('*****@*****.**','errore',$sql); } $rs = env::$dba->exec_query($sql, null, 'ASSOC'); $exc = new PHPExcel(); $exc->getProperties()->setCreator("Service Portal"); $exc->getProperties()->setLastModifiedBy("Service Portal"); $exc->getProperties()->setTitle("Order export"); $exc->getProperties()->setSubject("Order export"); $exc->getProperties()->setDescription("Esportazione ordini generata dal Service Portal"); $letters = array_unshift(range('A', 'Z'), ''); $cell = ''; function calc_pos($n) { $l = range('A', 'Z'); if ($n <= 26) { return $l[$n - 1]; } $r = $n % 26; $i = ($n - $r) / 26 - (empty($r) ? 1 : 0); return calc_pos($i) . (!empty($r) ? calc_pos($r) : 'Z'); } for ($i = 0; $i < count($rs); $i++) { $j = 0; foreach ($rs[$i] as $k => $v) { if ($k[0] == '_') { continue; } $col = calc_pos($j + 1); $cel = $col . ($i + 2); try { if (empty($i)) { $exc->getActiveSheet()->SetCellValue($col . ($i + 1), str_replace(array('_X', '!'), '', strtoupper($k))); } $exc->getActiveSheet()->SetCellValue($cel, str_replace('<br/>', ' ', $v)); } catch (Exception $e) { } $j++; } } $exc->getActiveSheet()->setTitle('Ordini'); $objWriter = new PHPExcel_Writer_Excel2007($exc); $filename = OSY_PATH_VAR . '/tmp/' . str_replace(' ', '-', strtolower($this->__par['form-title'])) . date('-Y-m-d-H-i-s') . '.xlsx'; $objWriter->save($filename); die(str_replace(OSY_PATH_VAR, '/var', $filename)); }
private static function testCondition($condition) { return HelperOsy::execString('', 'return (' . str_replace('TEST', '', $condition) . ');'); }
protected function build() { $sql = $this->get_par('datasource-sql'); if (empty($sql)) { die('[ERROR] - Multibox ' . $this->id . ' - query builder assente'); } $sql = $this->replacePlaceholder($sql); $res = $this->db->exec_query($sql, null, 'ASSOC'); //die($sql); if (empty($res)) { return; } $mlt_tbl = $this->add(tag::create('table')); $val_from_db = array_key_exists($this->id, $_REQUEST) && is_array($_REQUEST[$this->id]) ? false : true; foreach ($res as $k => $cmp_raw) { if ($val_from_db) { $_REQUEST[$this->id][$cmp_raw['id']] = $cmp_raw['val']; } $mlt_row = $mlt_tbl->add(tag::create('tr')); $cmp = $lbl = null; if (strlen($this->readonly) > 4) { $this->readonly = HelperOsy::exec_string(null, 'return ' . $this->readonly . ';'); } if ($this->readonly) { $cmp = tag::create('span'); if ($cmp_raw['typ'] == 'CMB') { $cmp_raw['val'] = label::getFromDatasource($cmp_raw['val'], $cmp_raw['sql_qry'], $this->db); } $cmp->add($cmp_raw['val']); } else { $is_req = $cmp_raw['is_req']; $cmp_nam = "{$this->id}[{$cmp_raw['id']}]"; switch ($cmp_raw['typ']) { case 'DAT': $cmp = new DateBox($cmp_nam); $cmp->par('date-format', 'dd/mm/yyyy'); break; case 'TXT': case 'NUM': $cmp = new TextBox($cmp_nam); if ($cmp_raw['typ'] == 'NUM') { $cmp->att('class', 'numeric', true); } else { $cmp->att('class', 'text', true); } break; case 'CMB': $cmp = new ComboBox($cmp_nam); //echo $cmp_raw['sql_qry']; $cmp->par('datasource-sql', HelperOsy::replaceVariable($cmp_raw['sql_qry'])); break; } $cmp->att('label', $cmp_raw['nam']); if (!empty($is_req)) { $lbl = '(*) '; $cmp->att('class', 'is-request', true); } } if (!is_null($cmp)) { $lbl = "<label class=\"multibox\">{$lbl}{$cmp_raw['nam']}</label>"; $mlt_row->add(new Tag('td'))->add($lbl); $mlt_row->add(new Tag('td'))->add($cmp); } } }