public function excluir($id) { $processo = ORM::Factory('processo', $id); if ($processo->procedimentos->count()) { $conteudo = '<h1>Excluir Processo</h1>'; $texto = 'Para remover este processo, é necessário move/remover todos os procedimentos vinculados a ele.<br>'; $texto .= html::anchor('processos/formulario/' . $processo->id, 'Ver o formulário deste processo'); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $processo->delete(); html::flash_message('Processo excluído com sucesso!', 'success'); url::redirect('processos/'); } }
public function excluir($id) { $esfera = ORM::Factory('esfera', $id); if ($esfera->orgaos->count()) { $conteudo = '<h1>Excluir esfera</h1>'; $texto = 'Para remover esta esfera, é necessário remover seus orgãos primeiro.<br>'; $texto .= html::anchor('esferas/formulario/' . $esfera->id, 'Voltar a esfera: ' . $esfera->nome); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $esfera->delete(); html::flash_message('Esfera excluída com sucesso!', 'success'); url::redirect('esferas/'); } }
public function excluir($id) { $grupo = ORM::Factory('grupo_procedimento', $id); if ($grupo->tipo_procedimentos->count()) { $conteudo = '<h1>Excluir Grupo de Procedimentos</h1>'; $texto = 'Para remover este grupo de procedimentos, é necessário remover seus tipos de procedimentos primeiro.<br>'; $texto .= html::anchor('grupo_procedimentos/formulario/' . $grupo->id, 'Voltar ao Grupo: ' . $grupo->nome); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $grupo->delete(); html::flash_message('Grupo de procedimentos excluído com sucesso!', 'success'); url::redirect('grupo_procedimentos/'); } }
public function excluir($id) { $advogado = ORM::Factory('advogado', $id); if ($advogado->procedimentos->count()) { $conteudo = '<h1>Excluir Advogado</h1>'; $texto = 'Para remover este advogado, é necessário move/remover todos os procedimentos que ele é responsável.<br>'; $texto .= html::anchor('advogados/', 'Voltar a lista de Advogados'); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $advogado->delete(); html::flash_message('Advogado excluído com sucesso!', 'success'); url::redirect('advogados/'); } }
public function excluir($id) { $pessoa = ORM::Factory('pessoa', $id); if ($pessoa->processos()->count()) { $conteudo = '<h1>Excluir Pessoa</h1>'; $texto = 'Para remover esta pessoa, é necessário remover todos os processos que ela faz parte.<br>'; $texto .= html::anchor('pessoas/', 'Voltar a lista de Pessoas'); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $pessoa->delete(); html::flash_message('Pessoa excluída com sucesso!', 'success'); url::redirect('pessoas/'); } }
public function excluir($id) { $grupo = ORM::Factory('grupo_acesso', $id); if ($grupo->usuarios->count()) { $conteudo = '<h1>Excluir Grupo de Acesso</h1>'; $texto = 'Para remover este Grupo de Acesso, é necessário remover/mover todos seus usuários primeiro.<br>'; $texto .= html::anchor('grupo_acessos', 'Voltar a lista de Grupos de Acesso'); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $nome = $grupo->nome; $grupo->delete(); html::flash_message('Grupo de Acesso <b>' . $nome . '</b> excluído com sucesso!', 'success'); url::redirect('grupo_acessos'); } }
public function excluir($id) { $gaveta = ORM::Factory('gaveta', $id); if ($gaveta->processos->count()) { $conteudo = '<h1>Excluir gaveta</h1>'; $texto = 'Para remover esta gaveta, é necessário remover/mover seus processos primeiro.<br>'; $texto .= html::anchor('armarios/formulario/' . $gaveta->armario->id, 'Voltar ao Armário: ' . $gaveta->armario->nome); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $armario = $gaveta->armario->id; $gaveta->delete(); html::flash_message('Gaveta excluída com sucesso!', 'success'); url::redirect('armarios/formulario/' . $armario); } }
public function excluir($id) { $orgao = ORM::Factory('orgao', $id); if ($orgao->processos->count()) { $conteudo = '<h1>Excluir orgão</h1>'; $texto = 'Para remover esta orgão, é necessário remover/mover seus processos primeiro.<br>'; $texto .= html::anchor('orgaos/formulario/' . $orgao->id, 'Voltar ao Orgão: ' . $orgao->nome); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $esfera = $orgao->esfera->id; $orgao->delete(); html::flash_message('Orgão excluído com sucesso!', 'success'); url::redirect('esferas/formulario/' . $esfera); } }
public function excluir($armario_id) { $armario = ORM::Factory('armario', $armario_id); //verifica se tem gavetas if ($armario->gavetas->count()) { $conteudo = '<h1>Excluir armário</h1>'; $texto = 'Para remover este armário, é necessário remover suas gavetas primeiro.<br>'; $texto .= html::anchor('armarios/formulario/' . $armario->id, 'Voltar ao Armário: ' . $armario->nome); $conteudo = $conteudo . html::message($texto, 'Atenção', 'erro'); $this->template->content = $conteudo; } else { $armario->delete(); html::flash_message('Armário excluído com sucesso!', 'success'); url::redirect('armarios/'); } }
}); </script> <div class="clear"></div> <?php if ($esfera->id) { echo '<h2>Orgãos' . html::anchor('orgaos/formulario/0/' . $esfera->id, '[ Adicionar Orgão]') . '</h2>'; if ($esfera->orgaos->count()) { $caption = $esfera->orgaos->count() . ' Orgãos encontradas'; $headers = array('Nome', 'Processos', 'Ações'); $headers['sizes'] = array(300, FALSE, 200); $footers = FALSE; $lines = array(); foreach ($esfera->orgaos as $orgao) { $col = array(); $col[] = $orgao->nome; $col[] = $orgao->processos->count(); $action_links = html::anchor('orgaos/formulario/' . $orgao->id, 'Vizualizar', array('class' => 'view')); $title = 'Tem certeza que deseja excluir ' . $orgao->nome . '?'; $action_links .= html::anchor('orgaos/excluir/' . $orgao->id, 'Excluir', array('class' => 'delete', 'title' => $title)); $col[] = $action_links; $lines[] = $col; } echo html::grid($headers, $lines, $footers, $caption); } else { $texto = 'Não existem Orgãos para esta esfera.'; echo html::message($texto, FALSE); } } ?>
/** * Names action */ public function action_names() { $input = request::input(); // legend echo self::render_topic('names'); // code naming conventions echo html::a(['name' => 'code']); echo '<h3>Naming Conventions: Code</h3>'; echo object_name_code::explain(null, ['html' => true]); // testing form echo html::a(['name' => 'code_test']); echo '<h3>Test name</h3>'; if (!empty($input['submit_yes'])) { $result = object_name_code::check($input['type'] ?? null, $input['name'] ?? null); if (!$result['success']) { echo html::message(['options' => $result['error'], 'type' => 'danger']); } else { echo html::message(['options' => 'Name is good!', 'type' => 'success']); } } $ms = 'Name: ' . html::input(['name' => 'name', 'value' => $input['name'] ?? null]) . ' '; $ms .= 'Type: ' . html::select(['name' => 'type', 'options' => object_name_code::$types, 'value' => $input['type'] ?? null]) . ' '; $ms .= html::submit(['name' => 'submit_yes']); echo html::form(['name' => 'code', 'action' => '#code_test', 'value' => $ms]); // database naming convention echo '<br/><br/><hr/>'; echo html::a(['name' => 'db']); echo '<h3>Naming Conventions: Database</h3>'; echo object_name_db::explain(null, ['html' => true]); // testing form echo html::a(['name' => 'db_test']); echo '<h3>Test name</h3>'; if (!empty($input['submit_yes2'])) { $result = object_name_db::check($input['type2'] ?? null, $input['name2'] ?? null); if (!$result['success']) { echo html::message(['options' => $result['error'], 'type' => 'danger']); } else { echo html::message(['options' => 'Name is good!', 'type' => 'success']); } } $ms = 'Name: ' . html::input(['name' => 'name2', 'value' => $input['name2'] ?? null]) . ' '; $ms .= 'Type: ' . html::select(['name' => 'type2', 'options' => object_name_db::$types, 'value' => $input['type2'] ?? null]) . ' '; $ms .= html::submit(['name' => 'submit_yes2']); echo html::form(['name' => 'db', 'action' => '#db_test', 'value' => $ms]); }
/** * 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' => ' ', 'width' => '1%'], 'row_data' => ['value' => html::grid($data), 'width' => !empty($options['details_11']) ? '100%' : '98%'], 'row_delete' => ['value' => ' ', '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); }
/** * 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; }
public function acesso_negado() { $texto = 'Você não tem permissão para acessar este recurso.<br>Por favor entre em contato com o administrador.'; $conteudo = html::message($texto, 'Acesso Negado', 'erro'); $this->template->content = $conteudo; }
/** * 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); }
/** * Render application messages * * @return string */ public static function render_messages() { $result = ''; // we need to see if we have postponed messages and render them first $postponed = session::get(['numbers', 'messages']); if (!empty($postponed)) { session::set(['numbers', 'messages'], []); foreach ($postponed as $k => $v) { $result .= html::message(['options' => $v, 'type' => $k]); } } // regular messages $messages = application::get(array('messages')); if (!empty($messages)) { foreach ($messages as $k => $v) { $result .= html::message(['options' => $v, 'type' => $k]); } } return $result; }