/** * Class constructor * Creates the page */ function __construct() { parent::__construct(); // create the form $this->form = new TForm(); $this->form->class = 'tform'; // creates the form field container $table = new TTable(); $table->width = '100%'; $this->form->add($table); // title row $table->addRowSet(new TLabel('Automatic selections'), '')->class = 'tformtitle'; // create the form fields // parameters (name, database, model, key, value) $radio = new TDBRadioGroup('radio', 'samples', 'Category', 'id', 'name'); $check = new TDBCheckGroup('check', 'samples', 'Category', 'id', 'name'); $combo = new TDBCombo('combo', 'samples', 'Category', 'id', 'name'); $select = new TDBSelect('select', 'samples', 'Category', 'id', 'name'); $search = new TDBMultiSearch('search', 'samples', 'Category', 'id', 'name'); $autocomp = new TDBEntry('autocomplete', 'samples', 'Category', 'name'); $search->setMinLength(3); $search->setOperator('like'); //default data: $radio->setValue(2); $check->setValue(array(1, 3)); $combo->setValue(2); $select->setValue(array(1, 3)); $search->setValue(array(99 => 'Predefined')); $radio->setLayout('horizontal'); $check->setLayout('horizontal'); $combo->setSize(160); $select->setSize(200, 70); $search->setSize(300, 70); // add the fields to the table $table->addRowSet(new TLabel('TDBRadioGroup:'), $radio); $table->addRowSet(new TLabel('TDBCheckGroup:'), $check); $table->addRowSet(new TLabel('TDBCombo:'), $combo); $table->addRowSet(new TLabel('TDBSelect:'), $select); $table->addRowSet(new TLabel('TDBMultiSearch:'), $search); $table->addRowSet(new TLabel('TDBEntry:'), $autocomp); // creates the action button $button1 = new TButton('action1'); // define the button action $button1->setAction(new TAction(array($this, 'onSave')), 'Save'); $button1->setImage('ico_save.png'); $table->addRowSet($button1, '')->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($radio, $check, $combo, $select, $search, $autocomp, $button1)); // wrap the page content using vertical box $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->form); parent::add($vbox); }
/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); // security check if (TSession::getValue('logged') !== TRUE) { throw new Exception(_t('Not logged')); } // creates the form $this->form = new TForm('form_search_Issue'); $this->form->class = 'tform'; // creates a table $table = new TTable(); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Issues')), '', '', '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $filter_status = new TDBCombo('id_status', 'changeman', 'Status', 'id', 'description_translated'); $filter_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description'); $filter_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated'); $filter_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated'); $filter_title = new TEntry('title'); $filter_status->setValue(TSession::getValue('Issue_id_status')); $filter_project->setValue(TSession::getValue('Issue_id_project')); $filter_priority->setValue(TSession::getValue('Issue_id_priority')); $filter_category->setValue(TSession::getValue('Issue_id_category')); $filter_title->setValue(TSession::getValue('Issue_title')); $filter_title->setSize(480); // add a row for the filter field $row = $table->addRow(); $row->addCell(new TLabel(_t('Status') . ': ')); $row->addCell($filter_status); $row->addCell(new TLabel(_t('Project') . ': ')); $row->addCell($filter_project); $row = $table->addRow(); $row->addCell(new TLabel(_t('Priority') . ': ')); $row->addCell($filter_priority); $row->addCell(new TLabel(_t('Category') . ': ')); $row->addCell($filter_category); $row = $table->addRow(); $row->addCell(new TLabel(_t('Title') . ': ')); $cell = $row->addCell($filter_title); $cell->colspan = 3; // create two action buttons to the form $find_button = new TButton('find'); $new_button = new TButton('new'); // define the button actions $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find')); $find_button->setImage('ico_find.png'); TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'CUSTOMER') { $class = 'NewIssueForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); } else { $class = 'UpdateIssueForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); } TTransaction::close(); $buttons = new THBox(); $buttons->add($find_button); $buttons->add($new_button); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 4; // define wich are the form fields $this->form->setFields(array($filter_status, $filter_project, $filter_priority, $filter_category, $filter_title, $find_button, $new_button)); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = new TDataGridColumn('id', 'ID', 'right', 50); $title = new TDataGridColumn('title', _t('Title'), 'left', 260); $id_status = new TDataGridColumn('status', _t('Status'), 'left', 100); $id_priority = new TDataGridColumn('priority', _t('Priority'), 'left', 100); $id_category = new TDataGridColumn('category', _t('Category'), 'left', 100); $register_date = new TDataGridColumn('register_date', _t('Start date'), 'left', 110); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order3 = new TAction(array($this, 'onReload')); $order4 = new TAction(array($this, 'onReload')); $order5 = new TAction(array($this, 'onReload')); $order6 = new TAction(array($this, 'onReload')); $order7 = new TAction(array($this, 'onReload')); $order8 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'title'); $order3->setParameter('order', 'id_status'); $order4->setParameter('order', 'id_priority'); $order5->setParameter('order', 'id_category'); $order6->setParameter('order', 'register_date'); // assign the ordering actions $id->setAction($order1); $title->setAction($order2); $id_status->setAction($order3); $id_priority->setAction($order4); $id_category->setAction($order5); $register_date->setAction($order6); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($title); $this->datagrid->addColumn($id_status); $this->datagrid->addColumn($id_priority); $this->datagrid->addColumn($id_category); $this->datagrid->addColumn($register_date); // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'ADMINISTRATOR' or Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MANAGER') { // creates two datagrid actions $class = 'UpdateIssueForm'; $action1 = new TDataGridAction(array($class, 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); } else { if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MEMBER') { // creates two datagrid actions $class = 'UpdateIssueForm'; $action1 = new TDataGridAction(array($class, 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); } } // creates two datagrid actions $class = 'ViewIssueForm'; $action3 = new TDataGridAction(array($class, 'onView')); $action3->setLabel(_t('View')); $action3->setImage('ico_view.png'); $action3->setField('id'); $class = 'NoteForm'; $action4 = new TDataGridAction(array($class, 'onEdit')); $action4->setLabel(_t('Comment')); $action4->setImage('ico_new.png'); $action4->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action3); $this->datagrid->addAction($action4); TTransaction::close(); // 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 vbox $container = new TVBox(); $container->add($this->form); $container->add($this->datagrid); $container->add($this->pageNavigation); // add the vbox inside the page parent::add($container); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // creates the form $this->form = new TForm('form_Ticket'); $this->form->class = 'tform'; // CSS class $table = new TTable(); $table->style = 'width: 600px'; $tablePagamento = new TTable(); $tablePagamento->style = 'width: 600px'; $notebook = new TNotebook(600, 650); $notebook->appendPage('Ticket - Cadastramento', $table); $notebook->appendPage('Ticket - Orçamento / Pagamento', $tablePagamento); // create the form fields $id = new TEntry('id'); $id->setEditable(FALSE); $titulo = new TEntry('titulo'); $origem = new TCombo('origem'); $combo_origem = array(); $combo_origem['I'] = 'Interno'; $combo_origem['E'] = 'Externo'; $origem->addItems($combo_origem); $origem->setDefaultOption(FALSE); $solicitacao_descricao = new TText('solicitacao_descricao'); $providencia = new TText('providencia'); $orcamento_horas = new TEntry('orcamento_horas'); $orcamento_horas->setMask('999999'); $orcamento_valor_hora = new TEntry('orcamento_valor_hora'); $orcamento_valor_hora->setNumericMask(2, ',', '.'); $valor_desconto = new TEntry('valor_desconto'); $valor_desconto->setNumericMask(2, ',', '.'); $valor_total = new TEntry('valor_total'); $valor_total->setNumericMask(2, ',', '.'); $valor_total->setEditable(FALSE); $forma_pagamento = new TEntry('forma_pagamento'); $data_ultimo_pgto = new TEntry('data_ultimo_pgto'); $data_ultimo_pgto->setEditable(FALSE); $valor_ultimo_pgto = new TEntry('valor_ultimo_pgto'); $valor_ultimo_pgto->setNumericMask(2, ',', '.'); $valor_ultimo_pgto->setEditable(FALSE); $valor_total_pago = new TEntry('valor_total_pago'); $valor_total_pago->setNumericMask(2, ',', '.'); $valor_total_pago->setEditable(FALSE); $data_pagamento = new TDate('data_pagamento'); $data_pagamento->setMask('dd/mm/yyyy'); $valor_pagamento = new TEntry('valor_pagamento'); $valor_pagamento->setNumericMask(2, ',', '.'); $valor_total_parcial = new TEntry('valor_total_parcial'); $valor_total_parcial->setNumericMask(2, ',', '.'); $valor_total_parcial->setEditable(FALSE); $valor_saldo = new TEntry('valor_saldo'); $valor_saldo->setNumericMask(2, ',', '.'); $valor_saldo->setEditable(FALSE); $data_cadastro = new TEntry('data_cadastro'); $data_cadastro->setEditable(FALSE); $data_cadastro->setMask('dd/mm/yyyy'); $data_cadastro->setValue(date('d/m/Y')); $data_inicio = new TDate('data_inicio'); $data_inicio->setMask('dd/mm/yyyy'); $data_inicio_oculta = new THidden('data_inicio_oculta'); $data_cancelamento = new TDate('data_cancelamento'); $data_cancelamento->setMask('dd/mm/yyyy'); $data_encerramento = new TDate('data_encerramento'); $data_encerramento->setMask('dd/mm/yyyy'); $data_prevista = new TDate('data_prevista'); $data_prevista->setMask('dd/mm/yyyy'); $data_aprovacao = new TDate('data_aprovacao'); $data_aprovacao->setMask('dd/mm/yyyy'); $observacao = new TText('observacao'); $nome_dtr = new TEntry('nome_dtr'); $nome_dtr->setEditable(FALSE); $criteria = new TCriteria(); $criteria->add(new TFilter("origem", "=", 1)); $criteria->add(new TFilter("ativo", "=", 1)); $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100)); $responsavel_id = new TDBCombo('responsavel_id', 'atividade', 'Pessoa', 'pessoa_codigo', 'pessoa_nome', 'pessoa_nome', $criteria); $tipo_ticket_id = new TDBCombo('tipo_ticket_id', 'atividade', 'TipoTicket', 'id', 'nome'); $tipo_ticket_id->setDefaultOption(FALSE); $sistema_id = new TDBCombo('sistema_id', 'atividade', 'Sistema', 'id', 'nome'); $status_ticket_id = new TDBCombo('status_ticket_id', 'atividade', 'StatusTicket', 'id', 'nome'); $status_ticket_id->setValue(2); $status_ticket_id->setEditable(FALSE); $prioridade_id = new TDBCombo('prioridade_id', 'atividade', 'Prioridade', 'id', 'nome'); $prioridade_id->setDefaultOption(FALSE); $prioridade_id->setValue(3); $combo_tipo_origens = new TCombo('tipo_origens'); $combo_tipo_origens->addItems(array(1 => 'Entidade', 2 => 'Estabelecimento', 3 => 'Empresa')); $combo_codigo_origem = new TCombo('codigo_cadastro_origem'); $combo_solicitante_id = new TCombo('solicitante_id'); try { TTransaction::open('atividade'); $logado = Pessoa::retornaUsuario(); TTransaction::close(); } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message } $logado_id = new THidden('logado_id'); $logado_id->setValue($logado->pessoa_codigo); // define the sizes $id->setSize(100); $origem->setSize(200); $solicitacao_descricao->setSize(400, 180); $data_inicio->setSize(90); $data_encerramento->setSize(90); $data_cancelamento->setSize(90); $providencia->setSize(400, 80); $orcamento_horas->setSize(100); $orcamento_valor_hora->setSize(100); $valor_desconto->setSize(100); $valor_total->setSize(100); $valor_saldo->setSize(121); $forma_pagamento->setSize(400); $data_ultimo_pgto->setSize(100); $data_pagamento->setSize(100); $valor_pagamento->setSize(121); $valor_ultimo_pgto->setSize(100); $valor_total_pago->setSize(100); $valor_total_parcial->setSize(121); $data_cadastro->setSize(100); $data_prevista->setSize(100); $data_aprovacao->setSize(100); $observacao->setSize(400, 80); $nome_dtr->setSize(400); $titulo->setSize(390); $responsavel_id->setSize(390); $tipo_ticket_id->setSize(200); $sistema_id->setSize(200); $status_ticket_id->setSize(200); $prioridade_id->setSize(200); $combo_tipo_origens->setSize(135); $combo_codigo_origem->setSize(250); $combo_solicitante_id->setSize(390); // validações $titulo->addValidation('Titulo', new TRequiredValidator()); $combo_solicitante_id->addValidation('Solicitante', new TRequiredValidator()); $responsavel_id->addValidation('Responsável', new TRequiredValidator()); $sistema_id->addValidation('Sistema', new TRequiredValidator()); $gerar_dr = TButton::create('gerar_dr', array('RequisitoDesenvolvimentoForm', 'onEdit'), 'Gerar DTR', 'ico_add.png'); $link_dtr = new TButton('link_dtr'); $link_dtr->setImage('bs:edit green'); $link_dtr->setLabel('ir para DTR'); $link_dtr->addFunction("__adianti_load_page('index.php?class=RequisitoDesenvolvimentoForm&method=onBuscaDTR&key={$_REQUEST['key']}');"); $this->form->addField($gerar_dr); $this->form->addField($link_dtr); TButton::disableField('form_Ticket', 'gerar_dr'); TButton::disableField('form_Ticket', 'link_dtr'); // add one row for each form field // notebook Cadastramento $table->addRowSet(new TLabel('Ticket:'), array($id, new TLabel('Data Cadastro'), $data_cadastro)); $table->addRowSet($label_combo_origem = new TLabel('Origem:'), array($combo_tipo_origens, $combo_codigo_origem)); $label_combo_origem->setFontColor('#FF0000'); $table->addRowSet($label_solicitante = new TLabel('Solicitante:'), $combo_solicitante_id); $label_solicitante->setFontColor('#FF0000'); $table->addRowSet($label_responsavel = new TLabel('Responsável:'), $responsavel_id); $label_responsavel->setFontColor('#FF0000'); $table->addRowSet($label_titulo = new TLabel('Título:'), $titulo); $label_titulo->setFontColor('#FF0000'); $table->addRowSet(new TLabel('Data Inicio'), array($data_inicio, $label_status = new TLabel('Status:'), $status_ticket_id)); $label_status->setSize(70); $table->addRowSet(new TLabel('Data Encerramento:'), array($data_encerramento, $label_data_cancelamento = new TLabel('Data Cancelamento:'), $data_cancelamento)); $label_data_cancelamento->setSize(160); $table->addRowSet(new TLabel('Prioridade:'), $prioridade_id); $table->addRowSet(new TLabel('Origem:'), $origem); $table->addRowSet(new TLabel('Tipo Ticket:'), $tipo_ticket_id); $table->addRowSet($label_sistema = new TLabel('Sistema:'), $sistema_id); $label_sistema->setFontColor('#FF0000'); $table->addRowSet(new TLabel('Descrição Solicitação:'), $solicitacao_descricao); $table->addRowSet(new TLabel('DR.:'), $nome_dtr); $table->addRowSet(new TLabel(''), array($gerar_dr, $link_dtr)); $table->addRowSet(new TLabel(''), $data_inicio_oculta); // notebook Pagamento $tablePagamento->addRowSet(new TLabel('Data Prevista:'), $data_prevista); $tablePagamento->addRowSet(new TLabel('Data Aprovação:'), $data_aprovacao); $tablePagamento->addRowSet(new TLabel('Qte Horas:'), $orcamento_horas); $tablePagamento->addRowSet(new TLabel('Valor Hora:'), $orcamento_valor_hora); $tablePagamento->addRowSet(new TLabel('Valor Desconto:'), $valor_desconto); $tablePagamento->addRowSet(new TLabel('Valor Total:'), $valor_total); $tablePagamento->addRowSet(new TLabel('Forma de Pgto:'), $forma_pagamento); $tablePagamento->addRowSet(new TLabel('Descrição Providência:'), $providencia); $tablePagamento->addRowSet(new TLabel('Observação:'), $observacao); // creates a frame $frame = new TFrame(); $frame->oid = 'frame-measures'; $frame->setLegend('Pagamentos:'); $row = $tablePagamento->addRow(); $cell = $row->addCell($frame); $cell->colspan = 2; $page2 = new TTable(); $frame->add($page2); $page2->addRowSet(new TLabel('Valor Pgto:'), array($valor_pagamento, $tamanho_label = new TLabel('Valor Ultimo Pgto:'), $valor_ultimo_pgto)); $tamanho_label->setSize(150); $page2->addRowSet(new TLabel('Data Pgto:'), array($data_pagamento, $tamanho_label = new TLabel('Data Ultimo Pgto:'), $data_ultimo_pgto)); $tamanho_label->setSize(150); $page2->addRowSet(new TLabel('Valor Total:'), array($valor_total_parcial, $tamanho_label = new TLabel('Valor Total Pago: '), $valor_total_pago)); $tamanho_label->setSize(150); $page2->addRowSet(new TLabel('Saldo a pagar:'), $valor_saldo); $tablePagamento->addRowSet(new TLabel(''), $logado_id); // Envia campos para o formulario $this->form->setFields(array($id, $titulo, $data_inicio, $data_inicio_oculta, $data_encerramento, $data_cancelamento, $origem, $solicitacao_descricao, $nome_dtr, $providencia, $orcamento_horas, $orcamento_valor_hora, $valor_desconto, $valor_total, $forma_pagamento, $data_ultimo_pgto, $valor_ultimo_pgto, $valor_total_pago, $data_cadastro, $data_prevista, $data_aprovacao, $observacao, $tipo_ticket_id, $sistema_id, $status_ticket_id, $prioridade_id, $responsavel_id, $valor_total_parcial, $valor_pagamento, $data_pagamento, $valor_saldo, $combo_tipo_origens, $combo_codigo_origem, $combo_solicitante_id, $logado_id)); // create the form actions $save_button = TButton::create('save', array($this, 'onSave'), _t('Save'), 'fa:floppy-o'); $new_button = TButton::create('new', array($this, 'onEdit'), _t('New'), 'fa:plus-square green'); $del_button = TButton::create('delete', array($this, 'onDelete'), _t('Delete'), 'fa:trash-o red fa-lg'); $list_button = TButton::create('list', array('TicketList', 'onReload'), _t('List'), 'fa:table blue'); $enviar_email = TButton::create('email', array($this, 'onEnviaEmail'), 'Enviar Email', 'ico_email.png'); $sincronizar = TButton::create('sincronizar', array($this, 'onSincronizarContatos'), 'Sincronizar Contatos', 'sincronizar.png'); $this->form->addField($save_button); $this->form->addField($new_button); $this->form->addField($del_button); $this->form->addField($list_button); $this->form->addField($enviar_email); $this->form->addField($sincronizar); $subtable = new TTable(); $row = $subtable->addRow(); $row->addCell($save_button); $row->addCell($new_button); $row->addCell($del_button); $row->addCell($list_button); $row->addCell($enviar_email); $row->addCell($sincronizar); $pretable = new TTable(); $pretable->style = 'width: 100%'; $row = $pretable->addRow(); $row->class = 'tformtitle'; // CSS class $row->addCell(new TLabel('Cadastro de Ticket'))->colspan = 2; $change_action = new TAction(array($this, 'onCalculaValorTotal')); $orcamento_horas->setExitAction($change_action); $orcamento_valor_hora->setExitAction($change_action); $valor_desconto->setExitAction($change_action); $change_data_action = new TAction(array($this, 'onChangeDataAction')); $data_aprovacao->setExitAction($change_data_action); $change_data_prev = new TAction(array($this, 'onChangeDataPrevista')); $data_prevista->setExitAction($change_data_prev); $change_data_pagamento = new TAction(array($this, 'onChangeDataPagamento')); $data_pagamento->setExitAction($change_data_pagamento); $change_valor = new TAction(array($this, 'onCalculaValorParcial')); $valor_pagamento->setExitAction($change_valor); $change_status = new TAction(array($this, 'onChangeDataInicio')); $data_inicio->setExitAction($change_status); $change_status = new TAction(array($this, 'onChangeDataCancelamento')); $data_cancelamento->setExitAction($change_status); $change_status = new TAction(array($this, 'onChangeDataEncerramento')); $data_encerramento->setExitAction($change_status); $change_origem = new TAction(array($this, 'onChangeOrigem')); $combo_tipo_origens->setChangeAction($change_origem); $change_tipo_origem = new TAction(array($this, 'onChangeTipoOrigem')); $combo_codigo_origem->setChangeAction($change_tipo_origem); $vbox = new TVBox(); $vbox->add($pretable); $vbox->add($notebook); $vbox->add($subtable); $this->form->add($vbox); parent::add($this->form); }
/** * Class constructor * Creates the page, the form and the listing */ public 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_search_Book'); $this->form->class = 'tform'; // creates a table $table = new TTable(); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Books')), '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $title = new TEntry('title'); $author_id = new TSeekButton('author_id'); $author_name = new TEntry('author_name'); $collection_id = new TDBCombo('collection_id', 'library', 'Collection', 'id', 'description'); $classification_id = new TDBCombo('classification_id', 'library', 'Classification', 'id', 'description'); $title->setValue(TSession::getValue('Book_title')); $author_id->setValue(TSession::getValue('Book_author_id')); $author_name->setValue(TSession::getValue('Book_author_name')); $collection_id->setValue(TSession::getValue('Book_collection_id')); $classification_id->setValue(TSession::getValue('Book_classification_id')); $author_name->setEditable(FALSE); $title->setSize(320); $author_id->setSize(100); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_search_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); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Title') . ': ')); $cell = $row->addCell($title); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Author') . ': ')); $row->addMultiCell($author_id, $author_name); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Collection') . ': ')); $cell = $row->addCell($collection_id); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Classification') . ': ')); $cell = $row->addCell($classification_id); // create two action buttons to the form $find_button = new TButton('find'); $new_button = new TButton('new'); // define the button actions $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find')); $find_button->setImage('ico_find.png'); $new_button->setAction(new TAction(array('BookForm', 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); $table->addRowSet('', array($find_button, $new_button))->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($title, $author_id, $author_name, $collection_id, $classification_id, $find_button, $new_button)); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(280); // creates the datagrid columns $id = new TDataGridColumn('id', _t('Code'), 'right', 50); $title = new TDataGridColumn('title', _t('Title'), 'left', 200); $main_author = new TDataGridColumn('author_name', _t('Author'), 'left', 160); $edition = new TDataGridColumn('edition', _t('Edition'), 'left', 50); $call = new TDataGridColumn('call_number', _t('Call'), 'left', 80); // 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', 'title'); // assign the ordering actions $id->setAction($order1); $title->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($title); $this->datagrid->addColumn($main_author); $this->datagrid->addColumn($edition); $this->datagrid->addColumn($call); // creates two datagrid actions $action1 = new TDataGridAction(array('BookForm', 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); // 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 vbox $container = new TVBox(); $container->add($this->form); $container->add($this->datagrid); $container->add($this->pageNavigation); // add the vbox inside the page parent::add($container); }
/** * 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')); } // creates a table $table = new TTable(); $table1 = new TTable(); $table2 = new TTable(); // creates the form $this->form = new TForm('form_Issue'); $this->form->class = 'tform'; $this->form->style = 'width: 750px'; $table->width = '100%'; $this->form->add($table); $table->addRowSet(new TLabel(_t('Issue')), '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $id_project = new TCombo('id_project'); $id_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated'); $id_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated'); $register_date = new TDate('register_date'); $time = new TEntry('issue_time'); $title = new TEntry('title'); $description = new THtmlEditor('description'); $file = new TFile('file'); $register_date->setValue(date('Y-m-d')); $register_date->setMask('yyyy-mm-dd'); $time->setValue(date('H:i')); $id_priority->setValue(2); // default $description->style = 'margin: 10px'; TTransaction::open('changeman'); $member = Member::newFromLogin(TSession::getValue('login')); $member_projects = $member->getProjectsList(); $id_project->addItems($member_projects); // if just one project, its the default if (count($member_projects) == 1) { $project_keys = array_keys($member_projects); $id_project->setValue($project_keys[0]); } TTransaction::close(); $id_project->addValidation(_t('Project'), new TRequiredValidator()); $id_priority->addValidation(_t('Priority'), new TRequiredValidator()); $id_category->addValidation(_t('Category'), new TRequiredValidator()); $register_date->addValidation(_t('Start date'), new TRequiredValidator()); $title->addValidation(_t('Title'), new TRequiredValidator()); $description->addValidation(_t('Description'), new TRequiredValidator()); // define the sizes $id_project->setSize(200); $id_priority->setSize(200); $id_category->setSize(200); $register_date->setSize(100); $file->setSize(250); $time->setSize(50); $time->setMask('99:99'); $title->setSize(200, 40); $description->setSize(680, 300); $table1->addRowSet(new TLabel(_t('Project') . ': '), $id_project); $table1->addRowSet(new TLabel(_t('Priority') . ': '), $id_priority); $table1->addRowSet(new TLabel(_t('Category') . ': '), $id_category); $table2->addRowSet(new TLabel(_t('Start date') . ':'), array($register_date, $time)); $table2->addRowSet(new TLabel(_t('Title') . ':'), $title); $table2->addRowSet(new TLabel(_t('File') . ':'), $file); $row = $table->addRow(); $row->addCell($table1); $row->addCell($table2); $label_description = new TLabel(_t('Description')); $label_description->setFontStyle('b'); $row = $table->addRow(); $row->addCell($label_description); $row = $table->addRow(); $cell = $row->addCell($description); $cell->colspan = 3; // 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'); $table->addRowSet($save_button, '')->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($id_project, $id_priority, $id_category, $register_date, $time, $title, $file, $description, $save_button)); // add the form to the page parent::add($this->form); }