public function __construct() { parent::__construct(); // creates one datagrid $this->datagrid = new TDataGrid(); // create the datagrid columns $code = new TDataGridColumn('code', 'Code', 'left', 50); $name = new TDataGridColumn('name', 'Name', 'left', 180); $address = new TDataGridColumn('address', 'Address', 'left', 140); $telephone = new TDataGridColumn('fone', 'Phone', 'center', 100); // add the columns to the datagrid $this->datagrid->addColumn($code); $this->datagrid->addColumn($name); $this->datagrid->addColumn($address); $this->datagrid->addColumn($telephone); $action1 = new TAction(array($this, 'onColumnAction')); $action1->setParameter('column', 'code'); $code->setAction($action1); $action2 = new TAction(array($this, 'onColumnAction')); $action2->setParameter('column', 'name'); $name->setAction($action2); // creates the datagrid model $this->datagrid->createModel(); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->datagrid); parent::add($vbox); }
public function __construct() { parent::__construct(); // instancia objeto DataGrid $this->datagrid = new TDataGrid(); // instancia as colunas da DataGrid $codigo = new TDataGridColumn('id', 'Código', 'right', 50); $nome = new TDataGridColumn('nome', 'Nome', 'left', 180); $endereco = new TDataGridColumn('endereco', 'Endereço', 'left', 140); $qualifica = new TDataGridColumn('qualifica', 'Qualificações', 'left', 200); $action1 = new TAction(array($this, 'onReload')); $action1->setParameter('order', 'id'); $action2 = new TAction(array($this, 'onReload')); $action2->setParameter('order', 'nome'); $codigo->setAction($action1); $nome->setAction($action2); // adiciona as colunas à DataGrid $this->datagrid->addColumn($codigo); $this->datagrid->addColumn($nome); $this->datagrid->addColumn($endereco); $this->datagrid->addColumn($qualifica); // cria o modelo da DataGrid, montando sua estrutura $this->datagrid->createModel(); // adiciona a DataGrid à página parent::add($this->datagrid); }
public function __construct() { parent::__construct(); $this->form = new TForm(); // creates one datagrid $this->datagrid = new TQuickGrid(); $this->datagrid->disableDefaultClick(); $this->form->add($this->datagrid); // creates the action button $button1 = new TButton('action1'); // define the button action $action_button1 = new TAction(array($this, 'onUpdate')); $action_button1->setParameter('id', filter_input(INPUT_GET, 'id')); $button1->setAction($action_button1, 'Atualizar'); $button1->setImage('fa:check-circle-o green'); $this->form->addField($button1); // add the columns $this->datagrid->addQuickColumn('Tipo de Atividade', 'nome', 'left', 180); $this->datagrid->addQuickColumn('Ticket', 'ticket', 'left', 180); $this->datagrid->addQuickColumn('Sistema', 'sistema', 'left', 180); // creates the datagrid model $this->datagrid->createModel(); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add($button1); $vbox->add($this->form); parent::add($vbox); }
/** * Class Constructor * @param $type Type of the message (info, error) * @param $message Message to be shown * @param $action Action to be processed when closing the dialog */ public function __construct($type, $message, TAction $action = NULL) { $this->id = uniqid(); if ($action) { $this->action = "__adianti_load_page('{$action->serialize()}');"; } if (TPage::isMobile()) { $img = new TElement('img'); $img->src = "lib/adianti/images/{$type}.png"; $table = new TTable(); $table->width = '250px'; $table->bgcolor = '#E5E5E5'; $table->style = "border-collapse:collapse"; $row = $table->addRow(); $row->addCell($img); $row->addCell($message); $table->show(); } else { TPage::include_css('lib/adianti/include/tmessage/tmessage.css'); // creates a pannel to show the dialog $painel = new TElement('div'); $painel->{'class'} = 'tmessage'; $painel->id = 'tmessage_' . $this->id; // creates a table for layout $table = new TTable(); // creates a row for the icon and the message $row = $table->addRow(); $row->addCell(new TImage("lib/adianti/images/{$type}.png")); $scroll = new TScroll(); $scroll->setSize(400, 200); $scroll->add($message); $cell = $row->addCell($scroll); // add the table to the pannel $painel->add($table); // show the pannel $painel->show(); $script = new TElement('script'); $script->{'type'} = 'text/javascript'; $script->add(' $(function() { $( "#' . $painel->id . '" ).dialog({ height: 340, width: 500, stack: false, zIndex: 3000, modal: true, buttons: { OK: function() { $( this ).dialog( "close" ); ' . $this->action . ' } } }).css("visibility", "visible"); $( "#' . $painel->id . ' a" ).click(function () { window.open($(this).attr(\'href\')); }); });'); $script->show(); } }
/** * Define o ID para carregar o conteudo dinamicamente * @param $id ID a ser carregada * @param $getContentAjax Campo a ser carregado via ajax */ public function setAction(TAction $action, $getContentAjax = null) { if (is_null($getContentAjax)) { $this->action = '__adianti_load_page(\'' . $action->serialize() . '\');'; } else { $this->action = '__adianti_load_page(\'' . $action->serialize() . '&' . $getContentAjax . '=\'+$("#' . $getContentAjax . '").val());'; } }
/** * method onDelete() * executed whenever the user clicks at the delete button * Ask if the user really wants to delete the record */ function onDelete($param) { // define the next action $action = new TAction(array($this, 'Delete')); $action->setParameters($param); // pass 'key' parameter ahead // shows a dialog to the user new TQuestion('Do you really want to delete ?', $action); }
/** * Define the action to be executed when the user changes the combo * @param $action TAction object */ public function setChangeAction(TAction $action) { if ($action->isStatic()) { $this->changeAction = $action; } else { $string_action = $action->toString(); throw new Exception(TAdiantiCoreTranslator::translate('Action (^1) must be static to be used in ^2', $string_action, __METHOD__)); } }
/** * Define the action to be executed when the user leaves the form field * @param $action TAction object */ function setExitAction(TAction $action) { if ($action->isStatic()) { $this->exitAction = $action; } else { $string_action = $action->toString(); throw new Exception(TAdiantiCoreTranslator::translate('Action (^1) must be static to be used in ^2', $string_action, __METHOD__)); } $this->widget->connect_after('focus-out-event', array($this, 'onExecuteExitAction')); }
/** * Class Constructor * @param $message A string containint the question * @param $action_yes Action taken for YES response * @param $action_no Action taken for NO response */ public function __construct($message, TAction $action_yes, TAction $action_no = NULL) { $buttons = array(Gtk::STOCK_YES, Gtk::RESPONSE_YES); if ($action_no instanceof TAction) { $buttons[] = Gtk::STOCK_NO; $buttons[] = Gtk::RESPONSE_NO; } $buttons[] = Gtk::STOCK_CANCEL; $buttons[] = Gtk::RESPONSE_CANCEL; parent::__construct('', NULL, Gtk::DIALOG_MODAL, $buttons); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_size_request(500, 300); $textview = new GtkTextView(); $textview->set_wrap_mode(Gtk::WRAP_WORD); $textview->set_border_width(12); $textbuffer = $textview->get_buffer(); $tagtable = $textbuffer->get_tag_table(); $customTag = new GtkTextTag(); $tagtable->add($customTag); $customTag->set_property('foreground', '#525252'); $tagBegin = $textbuffer->create_mark('tagBegin', $textbuffer->get_end_iter(), true); $textbuffer->insert_at_cursor("\n " . $message); $tagEnd = $textbuffer->create_mark('tagEnd', $textbuffer->get_end_iter(), true); $start = $textbuffer->get_iter_at_mark($tagBegin); $end = $textbuffer->get_iter_at_mark($tagEnd); $textbuffer->apply_tag($customTag, $start, $end); $textview->set_editable(FALSE); $textview->set_cursor_visible(FALSE); $pango = new PangoFontDescription('Sans 14'); $textview->modify_font($pango); $image = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $scroll = new GtkScrolledWindow(); $scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); $scroll->add($textview); $hbox = new GtkHBox(); $this->vbox->pack_start($hbox); $hbox->pack_start($image, FALSE, FALSE); $hbox->pack_start($scroll, TRUE, TRUE); $this->show_all(); $result = parent::run(); if ($result == Gtk::RESPONSE_YES) { parent::destroy(); call_user_func_array($action_yes->getAction(), array($action_yes->getParameters())); } else { if ($result == Gtk::RESPONSE_NO) { parent::destroy(); call_user_func_array($action_no->getAction(), array($action_no->getParameters())); } else { parent::destroy(); } } }
/** * Add a column * @param $label Field Label * @param $object Field Object * @param $size Field Size */ public function addQuickColumn($label, $name, $align = 'left', $size = 200, TAction $action = NULL, $param = NULL) { // creates a new column $object = new TDataGridColumn($name, $label, $align, $size); if ($action instanceof TAction) { // create ordering $action->setParameter($param[0], $param[1]); $object->setAction($action); } // add the column to the datagrid parent::addColumn($object); return $object; }
public function __construct() { parent::__construct(); // create two actions $action1 = new TAction(array($this, 'onAction1')); $action2 = new TAction(array($this, 'onAction2')); // define os parâmetros de cada ação $action1->setParameter('parameter', 1); $action2->setParameter('parameter', 2); // shows the question dialog new TQuestion('Do you really want to perform this operation ?', $action1, $action2); parent::add(new TXMLBreadCrumb('menu.xml', __CLASS__)); }
/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); new TSession(); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(280); // creates the datagrid columns $id = new TDataGridColumn('id', 'id', 'right', 40); $name = new TDataGridColumn('name', 'Name', 'left', 200); $address = new TDataGridColumn('address', 'Address', 'left', 200); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'name'); // assign the ordering actions $id->setAction($order1); $name->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); $this->datagrid->addColumn($address); // creates a datagrid action $action1 = new TDataGridAction(array('CustomerFormView', 'onEdit')); $action1->setLabel('Edit'); $action1->setImage('ico_edit.png'); $action1->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); // creates the edit action $editaction = new TDataGridAction(array($this, 'onEdit')); $editaction->setField('id'); $name->setEditAction($editaction); // create the datagrid model $this->datagrid->createModel(); // creates the page navigation $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // creates the page structure using a table $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->datagrid); $vbox->add($this->pageNavigation); // add the table inside the page parent::add($vbox); }
/** * método construtor * instancia objeto TQuestion * @param $message = pergunta ao usuário * @param $action_yes = ação para resposta positiva * @param $action_no = ação para resposta negativa */ function __construct($message, TAction $action_yes, TAction $action_no) { $style = new TStyle('tquestion'); $style->position = 'absolute'; $style->left = '30%'; $style->top = '30%'; $style->width = '300'; $style->height = '150'; $style->border_width = '1px'; $style->color = 'black'; $style->background = '#DDDDDD'; $style->border = '4px solid #000000'; $style->z_index = '10000000000000000'; // converte os nomes de métodos em URL's $url_yes = $action_yes->serialize(); $url_no = $action_no->serialize(); // exibe o estilo na tela $style->show(); // instancia o painel para exibir o diálogo $painel = new TElement('div'); $painel->class = "tquestion"; // cria um botão para a resposta positiva $button1 = new TElement('input'); $button1->type = 'button'; $button1->value = 'Sim'; $button1->onclick = "javascript:location='{$url_yes}'"; // cria um botão para a resposta negativa $button2 = new TElement('input'); $button2->type = 'button'; $button2->value = 'Não'; $button2->onclick = "javascript:location='{$url_no}'"; // cria uma tabela para organizar o layout $table = new TTable(); $table->align = 'center'; $table->cellspacing = 10; // cria uma linha para o ícone e a mensagem $row = $table->addRow(); $row->addCell(new TImage('app.images/question.png')); $row->addCell($message); // cria uma linha para os botões $row = $table->addRow(); $row->addCell($button1); $row->addCell($button2); // adiciona a tabela ao painél $painel->add($table); // exibe o painél $painel->show(); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); parent::setDatabase('esales'); // defines the database parent::setActiveRecord('Pessoa'); // defines the active record // creates the form $this->form = new TQuickForm('form_Pessoa'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; // define the form title $this->form->setFormTitle('Pessoa'); // create the form fields $id = new TEntry('id'); $nome = new TEntry('nome'); $telefone = new TEntry('telefone'); $email = new TEntry('email'); $endereco = new TEntry('endereco'); $numero = new TEntry('numero'); $cidade_id = new TSeekButton('cidade_id'); $cidade_id->addValidation('Cidade', new TRequiredValidator()); $cidade_name = new TEntry('cidade_name'); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'esales'); $action->setParameter('parent', 'form_Pessoa'); $action->setParameter('model', 'Cidade'); $action->setParameter('display_field', 'descricao'); $action->setParameter('receive_key', 'cidade_id'); $action->setParameter('receive_field', 'cidade_name'); $cidade_id->setAction($action); $cep = new TEntry('cep'); $cpf_cnpj = new TEntry('cpf_cnpj'); $tipo_pessoa = new TRadioGroup('tipo_pessoa'); $tipo_pessoa->addItems(array('F' => 'Fisica', 'J' => 'Juridica')); // add the fields $this->form->addQuickField('Codigo', $id, 100); $this->form->addQuickField('Nome', $nome, 200); $this->form->addQuickField('Telefone', $telefone, 200); $this->form->addQuickField('Email', $email, 200); $this->form->addQuickField('Endereço', $endereco, 200); $this->form->addQuickField('Numero', $numero, 200); $this->form->addQuickFields('Cidade', array($cidade_id, $cidade_name), true); $this->form->addQuickField('CEP', $cep, 200); $this->form->addQuickField('CPF/CNPJ', $cpf_cnpj, 100); $this->form->addQuickField('Tipo de pessoa', $tipo_pessoa, 200); // create the form actions $this->form->addQuickAction('Salvar', new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction('Novo', new TAction(array($this, 'onEdit')), 'ico_new.png'); // add the form to the page parent::add($this->form); }
/** * Class Constructor * @param $type Type of the message (info, error) * @param $message Message to be shown * @param $action Action to be processed when closing the dialog */ public function __construct($type, $message, TAction $action = NULL) { parent::__construct('', NULL, Gtk::DIALOG_MODAL, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK)); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_size_request(500, 300); $textview = new GtkTextView(); $textview->set_wrap_mode(Gtk::WRAP_WORD); $textview->set_border_width(12); $textbuffer = $textview->get_buffer(); $tagtable = $textbuffer->get_tag_table(); $customTag = new GtkTextTag(); $tagtable->add($customTag); $customTag->set_property('foreground', '#525252'); $message = "\n " . str_replace('<br>', "\n ", $message); $tagBegin = $textbuffer->create_mark('tagBegin', $textbuffer->get_end_iter(), true); $textbuffer->insert_at_cursor(strip_tags($message)); $tagEnd = $textbuffer->create_mark('tagEnd', $textbuffer->get_end_iter(), true); $start = $textbuffer->get_iter_at_mark($tagBegin); $end = $textbuffer->get_iter_at_mark($tagEnd); $textbuffer->apply_tag($customTag, $start, $end); $textview->set_editable(FALSE); $textview->set_cursor_visible(FALSE); $pango = new PangoFontDescription('Sans 14'); $textview->modify_font($pango); $image = $type == 'info' ? GtkImage::new_from_stock(Gtk::STOCK_DIALOG_INFO, Gtk::ICON_SIZE_DIALOG) : GtkImage::new_from_stock(Gtk::STOCK_DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG); $scroll = new GtkScrolledWindow(); $scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); $scroll->add($textview); $hbox = new GtkHBox(); $this->vbox->pack_start($hbox); $hbox->pack_start($image, FALSE, FALSE); $hbox->pack_start($scroll, TRUE, TRUE); $this->show_all(); parent::connect('key_press_event', array($this, 'onClose')); $result = parent::run(); if ($result == Gtk::RESPONSE_OK) { if ($action) { $parameters = $action->getParameters(); call_user_func_array($action->getAction(), array($parameters)); } } parent::destroy(); }
/** * Class Constructor * @param $name name of the form field * @param $database name of the database connection * @param $form name of the parent form * @param $model name of the Active Record to be searched * @param $display_field name of the field to be searched and shown * @param $receive_key name of the form field to receive the primary key * @param $receive_display_field name of the form field to receive the "display field" */ public function __construct($name, $database, $form, $model, $display_field, $receive_key, $receive_display_field) { parent::__construct($name); $obj = new TStandardSeek(); // define the action parameters $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', $database); $action->setParameter('parent', $form); $action->setParameter('model', $model); $action->setParameter('display_field', $display_field); $action->setParameter('receive_key', $receive_key); $action->setParameter('receive_field', $receive_display_field); parent::setAction($action); }
/** * Define the action for the SeekButton * @param $action Action taken when the user clicks over the Seek Button (A TAction object) */ public function setAction(TAction $action) { $callback = $action->getAction(); $this->btn->setAction($action, ''); $param = array(); if (is_array($callback)) { $classname = get_class($callback[0]); if ($classname == 'TStandardSeek') { $param['key'] = 3; $param['parent'] = $action->getParameter('parent'); $param['database'] = $action->getParameter('database'); $param['model'] = $action->getParameter('model'); $param['display_field'] = $action->getParameter('display_field'); $param['receive_key'] = $action->getParameter('receive_key'); $param['receive_field'] = $action->getParameter('receive_field'); } } if ($this->useOutEvent) { // get_text aqui não é on-the-fly, tem que chamar um método na hora do evento $this->entry->connect_simple('focus-out-event', array($this, 'onBlur'), $callback, $param); } }
function __construct() { parent::__construct(); //Cria uma Tabela $this->table = new TTable(); //Define as propriedades da Tabela $this->table->border = 1; $this->table->width = 500; $this->table->style = 'border-collapse:collapse'; //Adiciona uma linha na tabela $row = $this->table->addRow(); //Cria tres Ações $action1 = new TAction(array($this, 'onProdutos')); $action2 = new TAction(array($this, 'onContatos')); $action3 = new TAction(array($this, 'onEmpresa')); //Cria tres Links $link1 = new TElement('a'); $link2 = new TElement('a'); $link3 = new TElement('a'); //Define Ação dos Links $link1->href = $action1->serialize(); $link2->href = $action2->serialize(); $link3->href = $action3->serialize(); //Define o Rotulo dos Links $link1->add('Produtos'); $link2->add('Contatos'); $link3->add('Empresa'); //Adiciona os Links na Linha //Logo serão Criadas 3 Linhas $row->addCell($link1); $row->addCell($link2); $row->addCell($link3); //Cria uma linha para o Conteudo //Cria uma linha e atribui a referencia a $content $this->content = $this->table->addRow(); //Adiciona a tabela na pagina parent::add($this->table); }
/** * método __construct() * instancia uma nova página */ function __construct() { parent::__construct(); // cria uma tabela $this->table = new TTable(); // define algumas propriedades para tabela $this->table->border = 1; $this->table->width = 500; $this->table->style = 'border-collapse:collapse'; // adiciona uma linha na tabela $row = $this->table->addRow(); $row->bgcolor = '#d0d0d0'; // cria três ações $action1 = new TAction(array($this, 'onProdutos')); $action2 = new TAction(array($this, 'onContato')); $action3 = new TAction(array($this, 'onEmpresa')); // cria três links $link1 = new TElement('a'); $link2 = new TElement('a'); $link3 = new TElement('a'); // define a ação dos links $link1->href = $action1->serialize(); $link2->href = $action2->serialize(); $link3->href = $action3->serialize(); // define o rótulo de texto dos links $link1->add('Produtos'); $link2->add('Contato'); $link3->add('Empresa'); // adiciona os links na linha $row->addCell($link1); $row->addCell($link2); $row->addCell($link3); // cria uma linha para conteúdo $this->content = $this->table->addRow(); // adiciona a tabela na página parent::add($this->table); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); parent::setDatabase('esales'); // defines the database parent::setActiveRecord('Produto'); // defines the active record // creates the form $this->form = new TQuickForm('form_Produto'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; // define the form title $this->form->setFormTitle('Produto'); // create the form fields $id = new TEntry('id'); $descricao = new TEntry('descricao'); $preco_compra = new TEntry('preco_compra'); $preco_venda = new TEntry('preco_venda'); $marca_id = new TEntry('marca_id'); $marca_id = new TSeekButton('marca_id'); $marca_name = new TEntry('marca_name'); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'esales'); $action->setParameter('parent', 'form_Produto'); $action->setParameter('model', 'Marca'); $action->setParameter('display_field', 'descricao'); $action->setParameter('receive_key', 'marca_id'); $action->setParameter('receive_field', 'marca_name'); $marca_id->setAction($action); // add the fields $this->form->addQuickField('Codigo', $id, 100); $this->form->addQuickField('Descricao', $descricao, 200); $this->form->addQuickField('Preco compra', $preco_compra, 200); $this->form->addQuickField('Preco venda', $preco_venda, 200); $this->form->addQuickFields('Marca', array($marca_id, $marca_name)); // create the form actions $this->form->addQuickAction('Salvar', new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction('Novo', new TAction(array($this, 'onEdit')), 'ico_new.png'); // add the form to the page parent::add($this->form); }
/** * Show the widget */ public function show() { // check if it's not editable if (parent::getEditable()) { $serialized_action = ''; if ($this->action) { // get the action class name if (is_array($callback = $this->action->getAction())) { $classname = get_class($callback[0]); $inst = new $classname(); $ajaxAction = new TAction(array($inst, 'onSelect')); if ($classname == 'TStandardSeek') { $ajaxAction->setParameter('parent', $this->action->getParameter('parent')); $ajaxAction->setParameter('database', $this->action->getParameter('database')); $ajaxAction->setParameter('model', $this->action->getParameter('model')); $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field')); $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key')); $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field')); } $string_action = $ajaxAction->serialize(FALSE); if ($this->useOutEvent) { $this->setProperty('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n ajaxLookup('{$string_action}&'+serialform, this)"); } } $serialized_action = $this->action->serialize(FALSE); } parent::show(); $image = new TImage('lib/adianti/images/ico_find.png'); $link = new TElement('a'); $link->onmouseover = 'style.cursor = \'pointer\''; $link->onmouseout = 'style.cursor = \'default\''; $link->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n __adianti_append_page('engine.php?{$serialized_action}&'+serialform)"; $link->add($image); $link->show(); if ($this->auxiliar) { echo ' '; $this->auxiliar->show(); } } else { parent::show(); } }
/** * constructor method */ public function __construct() { parent::__construct(); // creates the form $this->form = new TForm('form_item_Seek'); // creates the table $table = new TTable(); // add the table inside the form $this->form->add($table); // create the form fields $barcode = new TEntry('barcode'); // keep the session value $barcode->setValue(TSession::getValue('test_item_barcode')); // add the field inside the table $row = $table->addRow(); $row->addCell(new TLabel(_t('Barcode'))); $row->addCell($barcode); // create a find button $find_button = new TButton('search'); // define the button action $find_button->setAction(new TAction(array($this, 'onSearch')), 'Search'); $find_button->setImage('ico_find.png'); // add a row for the find button $row = $table->addRow(); $row->addCell($find_button); // define wich are the form fields $this->form->setFields(array($barcode, $find_button)); // create the datagrid $this->datagrid = new TDataGrid(); // create the datagrid columns $id = new TDataGridColumn('id', _t('Code'), 'right', 70); $barcode = new TDataGridColumn('barcode', _t('Barcode'), 'left', 100); $title = new TDataGridColumn('title', _t('Title'), 'left', 200); $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order1->setParameter('order', 'id'); $order2->setParameter('order', 'barcode'); // define the column actions $id->setAction($order1); $barcode->setAction($order2); // add the columns inside the datagrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($barcode); $this->datagrid->addColumn($title); // create one datagrid action $action1 = new TDataGridAction(array($this, 'onSelect')); $action1->setLabel('Selecionar'); $action1->setImage('ico_apply.png'); $action1->setField('barcode'); // add the action to the datagrid $this->datagrid->addAction($action1); // create the datagrid model $this->datagrid->createModel(); // create the page navigator $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // create a table for layout $table = new TTable(); // create a row for the form $row = $table->addRow(); $row->addCell($this->form); // create a row for the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // create a row for the page navigator $row = $table->addRow(); $row->addCell($this->pageNavigation); // add the table inside the page parent::add($table); }
/** * Construtor de classe * Cria o formulário de material consumo */ function __construct() { parent::__construct(); parent::setDatabase("app"); parent::setActiveRecord("MaterialConsumoDerivado"); parent::setDefaultOrder("id", "asc"); // Cria o formulário $this->form = new TQuickForm('form_MaterialConsumo'); $this->form->class = 'tform'; // CSS class $this->form->setFormTitle('Material de consumo (novos ou necessidade extraordinária) a ser incluído na Proposta Orçamentária de 2017'); // define the form title // Cria os campos de formulário $id = new THidden('id'); $tipo_material_consumo_id = new TDBCombo('tipo_material_consumo_id', 'app', 'TipoMaterialConsumo', 'id', 'nome', 'nome'); $tipo_material_consumo_id->addValidation('Tipo do material', new TRequiredValidator()); $change_action = new TAction(array($this, 'onChangeAction')); $tipo_material_consumo_id->setChangeAction($change_action); $descricao = new TEntry('descricao'); $justificativa = new TText('justificativa'); $justificativa->addValidation('Justificativa', new TRequiredValidator()); $quantidade = new TEntry('quantidade'); $quantidade->addValidation('Quantidade', new TRequiredValidator()); $quantidade->addValidation('Quantidade', new TNumericValidator()); $custo = new TEntry('custo'); $custo->addValidation('Custo', new TRequiredValidator()); $custo->addValidation('Custo', new TNumericValidator()); $total = new TEntry('total'); $total->setEditable(false); // Adiciona os campos $this->form->addQuickField('', $id); //$this->form->add($id); $this->form->addQuickField('Tipo de material consumo', $tipo_material_consumo_id, 480); $this->form->addQuickField('Descrição', $descricao, 480); $this->form->addQuickField('Justificativa', $justificativa, 200); $justificativa->setSize(480, 100); $this->form->addQuickField('Quantidade', $quantidade, 200); $this->form->addQuickField('Previsão de custo unitário', $custo, 200); $this->form->addQuickField('Total', $total, 200); // Cria as ações do formulário $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png'); $actionHelp = new TAction(array("PaginaAjuda", 'onHelp')); $actionHelp->setParameters(array("key" => 3)); $this->form->addQuickAction(_t('Help'), $actionHelp, 'ico_help.png'); // Cria o datagrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // Cria as colunas do datagrid $this->datagrid->addQuickColumn('Tipo de material consumo', 'tipoMaterialConsumo->nome', 'left', 200); $this->datagrid->addQuickColumn('Descrição', 'descricao', 'left', 200); $this->datagrid->addQuickColumn('Quant.', 'quantidade', 'right', 100); $this->datagrid->addQuickColumn('Previsão de custo', 'custo', 'right', 100); $this->datagrid->addQuickColumn('Total', 'total', 'right', 100); // Cria as ações do datagrid $edit_action = new TDataGridAction(array($this, 'onEdit')); $delete_action = new TDataGridAction(array($this, 'onDelete')); // Adiciona as ações do datagrid $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'ico_edit.png'); $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'ico_delete.png'); // Cria o modelo do datagrid $this->datagrid->createModel(); // Cria a navegação de página $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // Cria o container da página $container = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation); parent::add($container); }
/** * Class Constructor * @param $message A string containint the question * @param $action_yes Action taken for YES response * @param $action_no Action taken for NO response */ public function __construct($message, TAction $action_yes = NULL, TAction $action_no = NULL) { $this->id = uniqid(); if (TPage::isMobile()) { $img = new TElement('img'); $img->src = "lib/adianti/images/question.png"; $yes = new TElement('a'); $yes->href = $action_yes->serialize(); $yes->generator = 'adianti'; $yes->add(TAdiantiCoreTranslator::translate('Yes')); $no = new TElement('a'); $no->href = $action_no->serialize(); $no->generator = 'adianti'; $no->add(TAdiantiCoreTranslator::translate('No')); $table = new TTable(); $table->width = '250px'; $table->bgcolor = '#E5E5E5'; $table->style = "border-collapse:collapse"; $row = $table->addRow(); $row->addCell($img); $table2 = new TTable(); $row->addCell($table2); $row = $table2->addRow(); $c = $row->addCell($message); $c->colspan = 2; $row = $table2->addRow(); $row->addCell($yes); $row->addCell($no); $table->show(); } else { TPage::include_css('lib/adianti/include/tmessage/tmessage.css'); // creates a layer to show the dialog $painel = new TElement('div'); $painel->{'class'} = "tmessage"; $painel->id = 'tquestion_' . $this->id; $url_yes = ''; $url_no = ''; if ($action_yes) { // convert the actions into URL's $url_yes = TAdiantiCoreTranslator::translate('Yes') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_yes->serialize() . '\');},'; } if ($action_no) { $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_no->serialize() . '\');},'; } else { $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" );},'; } // creates a table for layout $table = new TTable(); // creates a row for the icon and the message $row = $table->addRow(); $row->addCell(new TImage("lib/adianti/images/question.png")); $scroll = new TScroll(); $scroll->setSize(400, 200); $scroll->add($message); $cell = $row->addCell($scroll); // add the table to the pannel $painel->add($table); // show the pannel $painel->show(); $script = new TElement('script'); $script->add(' $(function() { $( "#' . $painel->id . '" ).dialog({ height: 340, width: 500, modal: true, stack: false, zIndex: 3000, buttons: { ' . $url_yes . $url_no . TAdiantiCoreTranslator::translate('Cancel') . ': function() { $( this ).dialog( "close" ); } } }).css("visibility", "visible"); });'); $script->show(); } }
/** * method onDelete() * executed whenever the user clicks at the delete button * Ask if the user really wants to delete the record */ function onDelete($param) { // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'ADMINISTRATOR') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // get the parameter $key $key = $param['key']; // define two actions $action = new TAction(array($this, 'Delete')); // define the action parameters $action->setParameter('key', $key); // shows a dialog to the user new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action); }
/** * Recarrega tela */ public function onReload($param) { $dados = TSession::getValue('person_dados'); $this->lista->clear(); if ($dados) { foreach ($dados as $dado) { $item_name = 'check_' . $dado[0]; $item = new StdClass(); $action_del = new TAction(array($this, 'onDeleteItem')); $action_del->setParameter('item', $dado[0]); $action_edi = new TAction(array($this, 'onEditItem')); $action_edi->setParameter('item', $dado[0]); $button_del = new TButton('delete_' . $dado[0]); $button_del->class = 'btn btn-default btn-sm'; $button_del->setAction($action_del, ''); $button_del->setImage('fa:trash-o'); $button_edi = new TButton('edit_' . $dado[0]); $button_edi->class = 'btn btn-default btn-sm'; $button_edi->setAction($action_edi, ''); $button_edi->setImage('fa:edit'); $item->edit = $button_edi; $item->delete = $button_del; $this->formFields[$item_name . '_edit'] = $item->edit; $this->formFields[$item_name . '_delete'] = $item->delete; $item->code = $dado[0]; $item->description = $dado[1]; $item->value = $dado[2]; $this->lista->addItem($item); } $this->form->setFields($this->formFields); } $this->loaded = TRUE; }
/** * Converts the action into an URL * @param $format_action = format action with document or javascript (ajax=no) */ public function serialize($format_action = TRUE) { if (is_array($this->action) and is_object($this->action[0])) { if (isset($_REQUEST['offset'])) { $this->setParameter('offset', $_REQUEST['offset']); } if (isset($_REQUEST['limit'])) { $this->setParameter('limit', $_REQUEST['limit']); } if (isset($_REQUEST['page'])) { $this->setParameter('page', $_REQUEST['page']); } if (isset($_REQUEST['first_page'])) { $this->setParameter('first_page', $_REQUEST['first_page']); } if (isset($_REQUEST['order'])) { $this->setParameter('order', $_REQUEST['order']); } } return parent::serialize($format_action); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // security check if (TSession::getValue('logged') !== TRUE) { throw new Exception(_t('Not logged')); } // security check TTransaction::open('library'); if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'LIBRARIAN') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // creates the form $this->form = new TForm('form_Book'); // creates a table $table1 = new TTable(); $table2 = new TTable(); $table3 = new TTable(); $notebook = new TNotebook(550, 400); $notebook->appendPage(_t('Basic data'), $table1); $notebook->appendPage(_t('Secundary data'), $table2); $notebook->appendPage(_t('Items'), $table3); // add the table inside the form $this->form->add($notebook); // create the form fields $id = new TEntry('id'); $title = new TEntry('title'); $isbn = new TEntry('isbn'); $call_number = new TEntry('call_number'); $author_id = new TSeekButton('author_id'); $author_name = new TEntry('author_name'); $edition = new TEntry('edition'); $volume = new TEntry('volume'); $collection_id = new TDBCombo('collection_id', 'library', 'Collection', 'id', 'description'); $classification_id = new TDBCombo('classification_id', 'library', 'Classification', 'id', 'description'); $publisher_id = new TSeekButton('publisher_id'); $publisher_name = new TEntry('publisher_name'); $publish_place = new TEntry('publish_place'); $publish_date = new TDate('publish_date'); $abstract = new TText('abstract'); $notes = new TText('notes'); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_Book'); $action->setParameter('model', 'Publisher'); $action->setParameter('display_field', 'name'); $action->setParameter('receive_key', 'publisher_id'); $action->setParameter('receive_field', 'publisher_name'); $publisher_id->setAction($action); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_Book'); $action->setParameter('model', 'Author'); $action->setParameter('display_field', 'name'); $action->setParameter('receive_key', 'author_id'); $action->setParameter('receive_field', 'author_name'); $author_id->setAction($action); // define the sizes $id->setSize(100); $title->setSize(340); $isbn->setSize(120); $call_number->setSize(120); $author_id->setSize(100); $edition->setSize(120); $volume->setSize(120); $collection_id->setSize(100); $classification_id->setSize(100); $publisher_id->setSize(100); $publish_place->setSize(140); $publish_date->setSize(100); $abstract->setSize(400, 40); $notes->setSize(400, 40); $id->setEditable(FALSE); $publisher_name->setEditable(FALSE); $author_name->setEditable(FALSE); // add a row for the field id $row = $table1->addRow(); $row->addCell(new TLabel(_t('Code'))); $cell = $row->addCell($id); $cell->colspan = 3; // add a row for the field title $row = $table1->addRow(); $row->addCell(new TLabel(_t('Title'))); $cell = $row->addCell($title); $cell->colspan = 3; // add a row for the field isbn/call_nuber $row = $table1->addRow(); $row->addCell(new TLabel('ISBN' . ': ')); $row->addCell($isbn); $row->addCell(new TLabel(_t('Call'))); $row->addCell($call_number); // add a row for the field author_id $row = $table1->addRow(); $row->addCell(new TLabel(_t('Author') . ': ')); $row->addCell($author_id); $row->addCell(new TLabel(_t('Name') . ': ')); $row->addCell($author_name); // add a row for the field edition/volume $row = $table1->addRow(); $row->addCell(new TLabel(_t('Edition') . ': ')); $row->addCell($edition); $row->addCell(new TLabel(_t('Volume') . ': ')); $row->addCell($volume); // add a row for the field collection_id/classification_id $row = $table1->addRow(); $row->addCell(new TLabel(_t('Collection') . ': ')); $row->addCell($collection_id); $row->addCell(new TLabel(_t('Classification') . ': ')); $row->addCell($classification_id); // add a row for the field publisher_id $row = $table1->addRow(); $row->addCell(new TLabel(_t('Publisher') . ': ')); $row->addCell($publisher_id); $row->addCell(new TLabel(_t('Name') . ': ')); $row->addCell($publisher_name); // add a row for the field publish_place $row = $table1->addRow(); $row->addCell(new TLabel(_t('Place') . ': ')); $row->addCell($publish_place); $row->addCell(new TLabel(_t('Date') . ': ')); $row->addCell($publish_date); // add a row for the field abstract $row = $table1->addRow(); $row->addCell(new TLabel(_t('Abstract') . ': ')); $cell = $row->addCell($abstract); $cell->colspan = 3; // add a row for the field notes $row = $table1->addRow(); $row->addCell(new TLabel(_t('Notes') . ': ')); $cell = $row->addCell($notes); $cell->colspan = 3; // secundary authors $authors = new TMultiField('author_list'); $sub_author_id = new TSeekButton('id'); $sub_author_name = new TEntry('name'); $sub_author_name->setEditable(FALSE); $sub_author_id->setSize(50); $sub_author_name->setSize(300); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_Book'); $action->setParameter('model', 'Author'); $action->setParameter('display_field', 'name'); $action->setParameter('receive_key', 'author_list_id'); $action->setParameter('receive_field', 'author_list_name'); $sub_author_id->setAction($action); $authors->setHeight(80); $authors->setClass('Author'); $authors->addField('id', _t('Author'), $sub_author_id, 50); $authors->addField('name', _t('Name'), $sub_author_name, 300); $row = $table2->addRow(); $row->addCell($l = new TLabel(_t('Authors'))); $l->setFontStyle('b'); $row = $table2->addRow(); $row->addCell($authors); // secundary subjects $subjects = new TMultiField('subject_list'); $sub_subject_id = new TSeekButton('id'); $sub_subject_name = new TEntry('name'); $sub_subject_name->setEditable(FALSE); $sub_subject_id->setSize(50); $sub_subject_name->setSize(300); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_Book'); $action->setParameter('model', 'Subject'); $action->setParameter('display_field', 'name'); $action->setParameter('receive_key', 'subject_list_id'); $action->setParameter('receive_field', 'subject_list_name'); $sub_subject_id->setAction($action); $subjects->setHeight(80); $subjects->setClass('Subject'); $subjects->addField('id', _t('Subject'), $sub_subject_id, 50); $subjects->addField('name', _t('Name'), $sub_subject_name, 300); $row = $table2->addRow(); $row->addCell($l = new TLabel(_t('Subjects'))); $l->setFontStyle('b'); $row = $table2->addRow(); $row->addCell($subjects); // items $items = new TMultiField('item_list'); $item_barcode = new TEntry('barcode'); $item_status_id = new TComboCombined('status_id', 'status_description'); $item_cost = new TEntry('cost'); $item_acquire_date = new TDate('acquire_date'); $item_notes = new TEntry('notes'); $item_status_id->setSize(150); $item_cost->setSize(100); $item_acquire_date->setSize(100); TTransaction::open('library'); $rep = new TRepository('Status'); $objects = $rep->load(new TCriteria()); $options = array(); if ($objects) { foreach ($objects as $object) { $options[$object->id] = $object->description; } } $item_status_id->addItems($options); TTransaction::close(); $items->setHeight(140); $items->setClass('Item'); $items->addField('barcode', _t('Barcode'), $item_barcode, 80); $items->addField('status_id', _t('Status'), $item_status_id, 100); $items->addField('cost', _t('Cost'), $item_cost, 80); $items->addField('acquire_date', _t('Acquire date'), $item_acquire_date, 80); $items->addField('notes', _t('Notes'), $item_notes, 150); $row = $table3->addRow(); $row->addCell($l = new TLabel(_t('Items'))); $l->setFontStyle('b'); $row = $table3->addRow(); $row->addCell($items); // create an action button (save) $save_button = new TButton('save'); // define the button action $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save')); $save_button->setImage('ico_save.png'); // add a row for the form action $row = $table1->addRow(); $row->addCell($save_button); // define wich are the form fields $this->form->setFields(array($id, $title, $isbn, $call_number, $author_id, $author_name, $edition, $volume, $collection_id, $classification_id, $publisher_id, $publisher_name, $publish_place, $publish_date, $abstract, $notes, $authors, $subjects, $items, $save_button)); // add the form to the page parent::add($this->form); }
/** * method onDelete() * executed whenever the user clicks at the delete button * Ask if the user really wants to delete the record */ function onDelete($param) { // get the parameter $key $key = $param['key']; // define two actions $action = new TAction(array($this, 'Delete')); // define the action parameters $action->setParameter('key', $key); // shows a dialog to the user new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action); }
/** * method onDelete() * executed whenever the user clicks at the delete button * Ask if the user really wants to delete the record */ function onDelete($param) { // define the delete action $action = new TAction(array($this, 'Delete')); $action->setParameters($param); // pass the key parameter ahead // shows a dialog to the user new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action); }