示例#1
0
 /**
  * método construtor
  * Cria a página e o formulário de cadastro
  */
 function __construct()
 {
     parent::__construct();
     // instancia um formulário
     $this->form = new TForm('form_login');
     // cria um notebook
     $notebook = new TNotebook();
     $notebook->setSize(340, 130);
     // instancia uma tabela
     $table = new TTable();
     // adiciona a tabela ao formulário
     $this->form->add($table);
     $langs = array();
     $langs['pt'] = 'Portugues';
     $langs['en'] = 'English';
     // cria os campos do formulário
     $user = new TEntry('user');
     $pass = new TPassword('password');
     $lang = new TCombo('language');
     $lang->addItems($langs);
     $lang->setValue(TSession::getValue('language'));
     // adiciona uma linha para o campo
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Login') . ':'));
     $row->addCell($user);
     // adiciona uma linha para o campo
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Password') . ':'));
     $row->addCell($pass);
     // adiciona uma linha para o campo
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Language') . ':'));
     $row->addCell($lang);
     // cria um botão de ação (salvar)
     $save_button = new TButton('login');
     // define a ação do botão
     $save_button->setAction(new TAction(array($this, 'onLogin')), _t('Login'));
     $save_button->setImage('ico_apply.png');
     // adiciona uma linha para a ação do formulário
     $row = $table->addRow();
     $row->addCell($save_button);
     // define quais são os campos do formulário
     $this->form->setFields(array($user, $pass, $lang, $save_button));
     $notebook->appendPage(_t('Data'), $this->form);
     // adiciona o notebook à página
     parent::add($notebook);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TForm('form_Ponto_report');
     $this->form->class = 'tform';
     // CSS class
     $this->form->style = 'width: 500px';
     $this->string = new StringsUtil();
     // creates the table container
     $table = new TTable();
     $table->width = '100%';
     // add the table inside the form
     $this->form->add($table);
     // define the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     $cell = $row->addCell(new TLabel('Indicador de produtividade por colaborador'));
     $cell->colspan = 2;
     // create the form fields
     $mes_atividade = new TCombo('mes_atividade');
     $mes_atividade->addItems($this->string->array_meses());
     $mes_atividade->setDefaultOption(FALSE);
     $mes_atividade->setValue(date('m'));
     $mes_atividade->setSize(250);
     $output_type = new TRadioGroup('output_type');
     $output_type->setSize(100);
     // validations
     $output_type->addValidation('Saida', new TRequiredValidator());
     // add one row for each form field
     $table->addRowSet(new TLabel('Mês referencia:'), $mes_atividade);
     $table->addRowSet($label_output_type = new TLabel('Saida:'), $output_type);
     $label_output_type->setFontColor('#FF0000');
     $this->form->setFields(array($mes_atividade, $output_type));
     $output_type->addItems(array('html' => 'HTML', 'pdf' => 'PDF', 'rtf' => 'RTF'));
     $output_type->setValue('html');
     $output_type->setLayout('horizontal');
     $generate_button = TButton::create('generate', array($this, 'onGenerate'), _t('Generate'), 'fa:check-circle-o green');
     $this->form->addField($generate_button);
     // add a row for the form action
     $table->addRowSet($generate_button, '')->class = 'tformaction';
     parent::add($this->form);
 }
示例#3
0
 /**
  * método construtor
  * Cria a página e o formulário de cadastro
  */
 function __construct()
 {
     parent::__construct();
     $table = new TTable();
     $table->width = '100%';
     // creates the form
     $this->form = new TForm('form_login');
     $this->form->class = 'tform';
     $this->form->style = 'margin:auto;width: 350px';
     // add the notebook inside the form
     $this->form->add($table);
     $langs = array();
     $langs['pt'] = 'Portugues';
     $langs['en'] = 'English';
     // cria os campos do formulário
     $user = new TEntry('user');
     $pass = new TPassword('password');
     $lang = new TCombo('language');
     $lang->addItems($langs);
     $lang->setValue(TSession::getValue('language'));
     // add a row for the field login
     $row = $table->addRow();
     $cell = $row->addCell(new TLabel('Login'));
     $cell->colspan = 2;
     $row->class = 'tformtitle';
     $table->addRowSet(new TLabel(_t('Login') . ': '), $user);
     $table->addRowSet(new TLabel(_t('Password') . ': '), $pass);
     $table->addRowSet(new TLabel(_t('Language') . ': '), $lang);
     // cria um botão de ação (salvar)
     $save_button = new TButton('login');
     // define a ação do botão
     $save_button->setAction(new TAction(array($this, 'onLogin')), _t('Login'));
     $save_button->setImage('ico_apply.png');
     $row = $table->addRowSet($save_button, '');
     $row->class = 'tformaction';
     // define quais são os campos do formulário
     $this->form->setFields(array($user, $pass, $lang, $save_button));
     // add the form to the page
     parent::add($this->form);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TQuickForm('form_Ponto');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Ponto');
     // define the form title
     $this->string = new StringsUtil();
     // create the form fields
     $id = new THidden('id');
     $data_ponto = new TDate('data_ponto');
     $data_ponto->setMask('dd/mm/yyyy');
     $change_data_action = new TAction(array($this, 'onChangeDataAction'));
     $data_ponto->setExitAction($change_data_action);
     $hora_entrada = new THidden('hora_entrada');
     $hora_saida = new THidden('hora_saida');
     $qtde_horas = new TCombo('qtde_horas');
     $qtde_minutos = new TCombo('qtde_minutos');
     $qtde_horas_final = new TCombo('qtde_horas_final');
     $qtde_minutos_final = new TCombo('qtde_minutos_final');
     $colaborador_id = new THidden('colaborador_id');
     TTransaction::open('atividade');
     $logado = Pessoa::retornaUsuario();
     $saldo_mes = Ponto::saldoHorasMes($logado->pessoa_codigo);
     TTransaction::close();
     $colaborador_id->setValue($logado->pessoa_codigo);
     $colaborador_nome = new TEntry('colaborador_nome');
     $colaborador_nome->setEditable(FALSE);
     $colaborador_nome->setValue($logado->pessoa_nome);
     $saldo_horas = new TEntry('saldo_horas');
     $saldo_horas->setEditable(FALSE);
     $saldo_horas->setValue($saldo_mes);
     // cria combos de horas e minutos
     $combo_horas = array();
     $combo_horas_final = array();
     for ($i = 8; $i <= 18; $i++) {
         $combo_horas[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
         $combo_horas_final[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $combo_horas_final[19] = '19';
     $qtde_horas->addItems($combo_horas);
     $qtde_horas->setValue(8);
     $qtde_horas->setSize(60);
     $qtde_horas->setDefaultOption(FALSE);
     $qtde_horas_final->addItems($combo_horas_final);
     $qtde_horas_final->setSize(60);
     $combo_minutos = array();
     $combo_minutos_final = array();
     for ($i = 0; $i <= 59; $i++) {
         $combo_minutos[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
         $combo_minutos_final[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $qtde_minutos->addItems($combo_minutos);
     $qtde_minutos->setValue(0);
     $qtde_minutos->setSize(60);
     $qtde_minutos->setDefaultOption(FALSE);
     $qtde_minutos_final->addItems($combo_minutos_final);
     $qtde_minutos_final->setSize(60);
     // validations
     $data_ponto->addValidation('Data', new TRequiredValidator());
     // add the fields
     $this->form->addQuickField('Colaborador', $colaborador_nome, 200);
     $this->form->addQuickField('Data', $data_ponto, 100);
     $this->form->addQuickFields('Hora entrada', array($qtde_horas, $qtde_minutos));
     $this->form->addQuickFields('Hora saida', array($qtde_horas_final, $qtde_minutos_final));
     $this->form->addQuickField('Saldo no mês:', $saldo_horas, 125);
     $this->form->addQuickField('% Produtividade', new TLabel('<span style="background-color: #00B4FF;"><b>> 49% satisfatoria&nbsp;&nbsp;</b></span><br/><span style="background-color: #FFF800;"><b>30%-49% - Atenção</b></span><br/><span style="background-color: #FF0000;"><b>0-29% Baixa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></span>'), 200);
     $this->form->addQuickField('', $hora_entrada, 200);
     $this->form->addQuickField('', $hora_saida, 200);
     $this->form->addQuickField('', $colaborador_id, 100);
     $this->form->addQuickField('', $id, 100);
     // create the form actions
     $this->form->addQuickAction('Salvar', new TAction(array($this, 'onSave')), 'fa:floppy-o');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'fa:plus-square green');
     $this->form->addQuickAction('Excluir', new TAction(array($this, 'onDelete')), 'fa:trash-o red fa-lg');
     TButton::disableField('form_Ponto', 'salvar');
     TButton::disableField('form_Ponto', 'excluir');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $data_ponto = $this->datagrid->addQuickColumn('Data', 'data_ponto', 'left', 50);
     $hora_entrada = $this->datagrid->addQuickColumn('H.Ent', 'hora_entrada', 'left', 30);
     $hora_saida = $this->datagrid->addQuickColumn('H.Sai', 'hora_saida', 'left', 30);
     $hora_ponto = $this->datagrid->addQuickColumn('H.Pto', 'hora_ponto', 'left', 30);
     $intervalo = $this->datagrid->addQuickColumn('Atividades', 'intervalo', 'right', 30);
     $produtividade = $this->datagrid->addQuickColumn('% prod.', 'produtividade', 'right', 55);
     // transformers
     $hora_entrada->setTransformer(array($this, 'tiraSegundos'));
     $hora_saida->setTransformer(array($this, 'tiraSegundos'));
     $hora_ponto->setTransformer(array($this, 'calculaDiferenca'));
     $intervalo->setTransformer(array($this, 'retornaIntervalo'));
     $produtividade->setTransformer(array($this, 'calculaPercentualProdutividade'));
     // create the datagrid actions
     $edit_action = new TDataGridAction(array($this, 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'fa:pencil-square-o blue fa-lg');
     // 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());
     // 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());
     // create the page container
     $container = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation);
     parent::add($container);
 }
 /**
  * 
  */
 public function makeTCombo($properties)
 {
     $widget = new TCombo((string) $properties->{'name'});
     $pieces = explode("\n", (string) $properties->{'items'});
     $items = array();
     if ($pieces) {
         foreach ($pieces as $line) {
             $part = explode(':', $line);
             $items[$part[0]] = $part[1];
         }
     }
     $widget->addItems($items);
     if (isset($properties->{'value'})) {
         $widget->setValue((string) $properties->{'value'});
     }
     if (isset($properties->{'tip'})) {
         $widget->setTip((string) $properties->{'tip'});
     }
     $widget->setSize((int) $properties->{'width'});
     $this->fields[] = $widget;
     $this->fieldsByName[(string) $properties->{'name'}] = $widget;
     return $widget;
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     $this->string = new StringsUtil();
     // creates the form
     $this->form = new TForm('form_Atividade_Cliente');
     $this->form->class = 'tform';
     // CSS class
     $this->form->style = 'width: 500px';
     // creates the table container
     $table = new TTable();
     $table->width = '100%';
     // add the table inside the form
     $this->form->add($table);
     // define the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     $cell = $row->addCell(new TLabel('Indicador por Periodo'));
     $cell->colspan = 2;
     // create the form fields
     // cria array para popular as combos
     TTransaction::open('atividade');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("origem", "=", 1));
     $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100));
     $criteria->add(new TFilter("ativo", "=", 1));
     $newparam['order'] = 'pessoa_nome';
     $newparam['direction'] = 'asc';
     $criteria->setProperties($newparam);
     // order, offset
     $repo = new TRepository('Pessoa');
     $pessoas = $repo->load($criteria);
     $arrayPessoas[-1] = 'TODOS COLABORADORES';
     foreach ($pessoas as $pessoa) {
         $arrayPessoas[$pessoa->pessoa_codigo] = $pessoa->pessoa_nome;
     }
     $criteria = new TCriteria();
     $criteria->add(new TFilter("enttipent", "=", "1"));
     $newparam['order'] = 'entcodent';
     $newparam['direction'] = 'asc';
     $criteria->setProperties($newparam);
     // order, offset
     $repo = new TRepository('Entidade');
     $clientes = $repo->load($criteria);
     $arrayClientes[-1] = 'TODOS CLIENTES';
     foreach ($clientes as $cliente) {
         $arrayClientes[$cliente->entcodent] = str_pad($cliente->entcodent, 4, '0', STR_PAD_LEFT) . ' - ' . $cliente->entrazsoc;
     }
     $arrayClientes[999] = 'ECS 999';
     TTransaction::close();
     $colaborador_id = new TCombo('colaborador_id');
     $colaborador_id->setDefaultOption(FALSE);
     $colaborador_id->addItems($arrayPessoas);
     $cliente_id = new TCombo('cliente_id');
     $cliente_id->setDefaultOption(FALSE);
     $cliente_id->addItems($arrayClientes);
     $anos = array(2015 => '2015');
     $mes_atividade_inicial = new TCombo('mes_atividade_inicial');
     $mes_atividade_inicial->addItems($this->string->array_meses());
     $mes_atividade_inicial->setDefaultOption(FALSE);
     $mes_atividade_inicial->setValue(date('m'));
     $ano_atividade_inicial = new TCombo('ano_atividade_inicial');
     $ano_atividade_inicial->addItems($anos);
     $ano_atividade_inicial->setDefaultOption(FALSE);
     $mes_atividade_final = new TCombo('mes_atividade_final');
     $mes_atividade_final->addItems($this->string->array_meses());
     $mes_atividade_final->setDefaultOption(FALSE);
     $mes_atividade_final->setValue(date('m'));
     $ano_atividade_final = new TCombo('ano_atividade_final');
     $ano_atividade_final->addItems($anos);
     $ano_atividade_final->setDefaultOption(FALSE);
     $output_type = new TRadioGroup('output_type');
     // define the sizes
     $colaborador_id->setSize(353);
     $cliente_id->setSize(353);
     $mes_atividade_inicial->setSize(250);
     $ano_atividade_inicial->setSize(100);
     $mes_atividade_final->setSize(250);
     $ano_atividade_final->setSize(100);
     $output_type->setSize(100);
     // validations
     $output_type->addValidation('Output', new TRequiredValidator());
     // add one row for each form field
     $table->addRowSet(new TLabel('Colaborador:'), $colaborador_id);
     $table->addRowSet(new TLabel('Cliente:'), $cliente_id);
     $table->addRowSet(new TLabel('Mês ano inicial:'), array($mes_atividade_inicial, $ano_atividade_inicial));
     $table->addRowSet(new TLabel('Mês ano final:'), array($mes_atividade_final, $ano_atividade_final));
     $table->addRowSet(new TLabel('Output:'), $output_type);
     $this->form->setFields(array($colaborador_id, $cliente_id, $mes_atividade_inicial, $mes_atividade_final, $ano_atividade_inicial, $ano_atividade_final, $output_type));
     $output_type->addItems(array('html' => 'HTML', 'pdf' => 'PDF', 'rtf' => 'RTF'));
     $output_type->setValue('html');
     $output_type->setLayout('horizontal');
     $generate_button = TButton::create('generate', array($this, 'onGenerate'), _t('Generate'), 'fa:check-circle-o green');
     $this->form->addField($generate_button);
     // add a row for the form action
     $table->addRowSet($generate_button, '')->class = 'tformaction';
     parent::add($this->form);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TQuickForm('form_CargaHoraria');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Carga Horaria');
     // define the form title
     $this->string = new StringsUtil();
     // create the form fields
     $mes = new TCombo('mes');
     $mes->addItems($this->string->array_meses());
     $mes->setDefaultOption(FALSE);
     $mes->setValue(date('m'));
     $mes->setSize(100);
     $ano = new TCombo('ano');
     $anos = array(2015 => '2015');
     $ano->addItems($anos);
     $ano->setDefaultOption(FALSE);
     $ano->setSize(70);
     $qtde_horas = new TCombo('qtde_horas');
     $qtde_minutos = new TCombo('qtde_minutos');
     // cria combos de horas e minutos
     $combo_horas = array();
     for ($i = 0; $i <= 300; $i++) {
         $combo_horas[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $qtde_horas->addItems($combo_horas);
     $qtde_horas->setValue(180);
     $qtde_horas->setSize(60);
     $qtde_horas->setDefaultOption(FALSE);
     $combo_minutos = array();
     for ($i = 0; $i <= 59; $i++) {
         $combo_minutos[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $qtde_minutos->addItems($combo_minutos);
     $qtde_minutos->setValue(0);
     $qtde_minutos->setSize(60);
     $qtde_minutos->setDefaultOption(FALSE);
     // add the fields
     $this->form->addQuickFields('Mês/Ano', array($mes, $ano));
     $this->form->addQuickFields('Carga horaria', array($qtde_horas, $qtde_minutos));
     // create the form actions
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
     $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onReload')), 'ico_find.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $horario = $this->datagrid->addQuickColumn('horario', 'horario', 'left', 50);
     $colaborador_id = $this->datagrid->addQuickColumn('colaborador', 'pessoa->pessoa_nome', 'left', 100);
     $mes = $this->datagrid->addQuickColumn('mes', 'mes', 'left', 100);
     $ano = $this->datagrid->addQuickColumn('ano', 'ano', 'left', 50);
     $mes->setTransformer(array('StringsUtil', 'retorna_mes'));
     $horario->setTransformer(array('StringsUtil', 'retira_segundos'));
     $colaborador_id->setTransformer(array($this, 'retornaPessoa'));
     // creates the edit action
     $editaction = new TDataGridAction(array($this, 'onEdit'));
     $editaction->setField('id');
     $horario->setEditAction($editaction);
     // create the datagrid actions
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'fa:trash-o red fa-lg');
     // 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());
     // 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());
     // create the page container
     $container = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation);
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     $string = new StringsUtil();
     // creates the form
     $this->form = new TForm('form_Atividade');
     $this->form->class = 'tform';
     // CSS class
     $this->form->style = 'width: 500px';
     // add a table inside form
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     // add a row for the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $row->addCell(new TLabel('Atividade'))->colspan = 2;
     // busca dados do banco
     try {
         TTransaction::open('atividade');
         $logado = Pessoa::retornaUsuario();
         $ultimoPonto = Ponto::retornaUltimoPonto($logado->pessoa_codigo);
         $ponto = new Ponto($ultimoPonto);
         if ($ponto->hora_saida) {
             $action = new TAction(array('PontoFormList', 'onReload'));
             new TMessage('error', 'Não existe ponto com horario em aberto!', $action);
         }
         $data_padrao = $string->formatDateBR($ponto->data_ponto);
         $hora_padrao = Ponto::retornaHoraInicio($string->formatDate($data_padrao), $logado->pessoa_codigo);
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
     }
     // create the form fields
     $id = new THidden('id');
     $data_atividade = new TEntry('data_atividade');
     $data_atividade->setMask('dd/mm/yyyy');
     $data_atividade->setValue($data_padrao);
     $data_atividade->setEditable(FALSE);
     $hora_inicio = new TEntry('hora_inicio');
     $hora_inicio->setEditable(FALSE);
     $hora_inicio->setValue($hora_padrao);
     $hora_fim = new THidden('hora_fim');
     $hora_fim->setEditable(FALSE);
     $tempo_atividade = new TEntry('tempo_atividade');
     $tempo_atividade->setEditable(FALSE);
     $qtde_horas = new TCombo('qtde_horas');
     $qtde_minutos = new TCombo('qtde_minutos');
     $descricao = new TText('descricao');
     $colaborador_id = new THidden('colaborador_id');
     $colaborador_id->setValue($logado->pessoa_codigo);
     $colaborador_nome = new TEntry('colaborador_nome');
     $colaborador_nome->setEditable(FALSE);
     $colaborador_nome->setValue($logado->pessoa_nome);
     $tipo_atividade_id = new TDBCombo('tipo_atividade_id', 'atividade', 'TipoAtividade', 'id', 'nome', 'nome');
     $sistema_id = new TDBCombo('sistema_id', 'atividade', 'Sistema', 'id', 'nome');
     $ticket_id = new TCombo('ticket_id');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("status_ticket_id", "IN", array(1, 5)));
     $newparam['order'] = 'id';
     $newparam['direction'] = 'asc';
     $criteria->setProperties($newparam);
     // order, offset
     $this->onComboTicket($criteria);
     $horario = explode(':', $hora_padrao);
     // cria combos de horas e minutos
     $combo_horas = array();
     for ($i = 8; $i <= 18; $i++) {
         $combo_horas[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $qtde_horas->addItems($combo_horas);
     $qtde_horas->setValue($horario[0]);
     $qtde_horas->setDefaultOption(FALSE);
     $combo_minutos = array();
     for ($i = 0; $i <= 59; $i++) {
         $combo_minutos[$i] = str_pad($i, 2, 0, STR_PAD_LEFT);
     }
     $qtde_minutos->addItems($combo_minutos);
     $qtde_minutos->setValue($horario[1]);
     $qtde_minutos->setDefaultOption(FALSE);
     // set exit action for input_exit
     $change_action = new TAction(array($this, 'onChangeAction'));
     $qtde_horas->setChangeAction($change_action);
     $qtde_minutos->setChangeAction($change_action);
     $change_atividade_action = new TAction(array($this, 'onTrocaTipoAtividade'));
     $tipo_atividade_id->setChangeAction($change_atividade_action);
     $change_ticket_action = new TAction(array($this, 'onTrocaTicket'));
     $ticket_id->setChangeAction($change_ticket_action);
     // define the sizes
     $id->setSize(100);
     $data_atividade->setSize(100);
     $hora_inicio->setSize(100);
     $hora_fim->setSize(100);
     $qtde_horas->setSize(60);
     $qtde_minutos->setSize(60);
     $tempo_atividade->setSize(100);
     $descricao->setSize(300, 80);
     $colaborador_id->setSize(200);
     $tipo_atividade_id->setSize(200);
     $ticket_id->setSize(300);
     // validações
     $tempo_atividade->addValidation('Hora Fim', new THoraFimValidator());
     $tipo_atividade_id->addValidation('Tipo de Atividade', new TRequiredValidator());
     $ticket_id->addValidation('Ticket', new TRequiredValidator());
     $sistema_id->addValidation('Sistema', new TRequiredValidator());
     $descricao->addValidation('Descrição', new TMinLengthValidator(), array(10));
     $sem_atividade = TButton::create('atividade', array($this, 'onSemAtividade'), 'Sem Registro', 'ico_add.png');
     $this->form->addField($sem_atividade);
     // add one row for each form field
     $table->addRowSet(new TLabel('Colaborador:'), $colaborador_nome);
     $table->addRowSet(new TLabel('Data Atividade:'), array($data_atividade, $label_data = new TLabel('Data do último ponto')));
     $label_data->setFontColor('#A9A9A9');
     $table->addRowSet(new TLabel('Hora Inicio:'), $hora_inicio);
     $table->addRowSet($label_qtde_horas = new TLabel('Hora Fim:'), array($qtde_horas, $qtde_minutos, $sem_atividade));
     $label_qtde_horas->setFontColor('#FF0000');
     $table->addRowSet(new TLabel('Tempo Atividade:'), $tempo_atividade);
     $table->addRowSet($label_atividade = new TLabel('Tipo Atividade:'), $tipo_atividade_id);
     $label_atividade->setFontColor('#FF0000');
     $table->addRowSet($label_ticket = new TLabel('Ticket:'), $ticket_id);
     $label_ticket->setFontColor('#FF0000');
     $table->addRowSet($label_sistema = new TLabel('Sistema:'), $sistema_id);
     $label_sistema->setFontColor('#FF0000');
     $table->addRowSet($label_descricao = new TLabel('Descrição:'), $descricao);
     $label_descricao->setFontColor('#FF0000');
     $table->addRowSet(new TLabel(''), $id);
     $table->addRowSet(new TLabel(''), $colaborador_id);
     $table->addRowSet(new TLabel(''), $hora_fim);
     //esconder
     $this->form->setFields(array($id, $data_atividade, $hora_inicio, $qtde_horas, $qtde_minutos, $hora_fim, $tempo_atividade, $descricao, $colaborador_id, $colaborador_nome, $tipo_atividade_id, $ticket_id, $sistema_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('AtividadeList', 'onClean'), _t('List'), 'fa:table blue');
     $this->form->addField($save_button);
     $this->form->addField($new_button);
     $this->form->addField($del_button);
     $this->form->addField($list_button);
     $buttons_box = new THBox();
     $buttons_box->add($save_button);
     $buttons_box->add($new_button);
     $buttons_box->add($del_button);
     $buttons_box->add($list_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     //                        TScript::create(' $( "#descricao" ).focus(); ');
     parent::add($this->form);
 }
 /**
  * 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('Static selections'), '')->class = 'tformtitle';
     // create the form fields
     $radio = new TRadioGroup('radio');
     $check = new TCheckGroup('check');
     $combo = new TCombo('combo');
     $select = new TSelect('select');
     $search = new TMultiSearch('search');
     $autocomp = new TEntry('autocomplete');
     $radio->setLayout('horizontal');
     $check->setLayout('horizontal');
     $combo->setSize(100);
     $select->setSize(200, 70);
     $search->setSize(300, 70);
     $items = array();
     $items['a'] = 'Item a';
     $items['b'] = 'Item b';
     $items['c'] = 'Item c';
     $radio->addItems($items);
     $check->addItems($items);
     $combo->addItems($items);
     $select->addItems($items);
     $search->addItems($items);
     $autocomp->setCompletion(array_values($items));
     foreach ($radio->getLabels() as $key => $label) {
         $label->setTip("Radio {$key}");
     }
     foreach ($check->getLabels() as $key => $label) {
         $label->setTip("Check {$key}");
     }
     // define default values
     $search->setMinLength(3);
     $radio->setValue('a');
     $check->setValue(array('a', 'c'));
     $combo->setValue('b');
     $select->setValue(array('b', 'c'));
     $search->setValue(array('b' => 'Item b'));
     // add the fields to the table
     $table->addRowSet(new TLabel('TRadioGroup:'), $radio);
     $table->addRowSet(new TLabel('TCheckGroup:'), $check);
     $table->addRowSet(new TLabel('TCombo:'), $combo);
     $table->addRowSet(new TLabel('TSelect:'), $select);
     $table->addRowSet(new TLabel('TMultiSearch:'), $search);
     $table->addRowSet(new TLabel('Autocomplete:'), $autocomp);
     // creates the action button
     $button1 = new TButton('action1');
     $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);
 }
示例#10
0
 /**
  * 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);
 }