/**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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
     $action1 = new TAction(array($this, 'Delete'));
     $action1->setParameters($param);
     // pass 'key' parameter ahead
     // shows a dialog to the user
     new TQuestion('Você realmete quer deletar este registro?', $action1);
 }
示例#5
0
 /**
  * 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('Você deseja excluir este endereço ?', $action);
 }
 /**
  * method deleteCollection()
  * Delete many records
  */
 public function deleteCollection($param)
 {
     // decode json with record id's
     $selected = json_decode($param['selected']);
     try {
         TTransaction::open('sample');
         if ($selected) {
             // delete each record from collection
             foreach ($selected as $id) {
                 $object = new telefone();
                 $object->delete($id);
             }
             $posAction = new TAction(array($this, 'onReload'));
             $posAction->setParameters($param);
             new TMessage('info', AdiantiCoreTranslator::translate('Records deleted'), $posAction);
         }
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
         TTransaction::rollback();
     }
 }
示例#7
0
 function onDelete($param)
 {
     $action = new TAction(array($this, 'Delete'));
     $action->setParameters($param);
     // pass the key parameter ahead
     new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
 }
 /**
 * Metodo para alterar a quantidade do item 
 */
 public function updateItem($param)
 {
     // pega o item a ser alterado
     $produtos = $this->cart->getIten($param['key']);
     try {
         TTransaction::open('sample');
         $produto_old = new Produtos($param['key']);
         // pega o item antigo ara podermos usar a imagem do banco
         /**
         * nessa parte usamos os get da class PProduto para 
         mostrar os dados, lembrando que todo produto inserido no carinho 
         é do tipo PProduto da PWD */
         $row = $this->table->addRow();
         $row->addCell(new PLabel($produtos->getNome(), 'primary'))->colspan = 2;
         $row = $this->table->addRow();
         $row->addCell(new TImage('uploads/' . $produto_old->imagem));
         $row->addCell($produtos->getDescricao());
         $row = $this->table->addRow();
         $row->addCell(new PLabel('R$ ' . $produtos->getPreco(), 'success'));
         $row = $this->table->addRow();
         $row->addCell('Qtd');
         $qtd = new TEntry('qtd');
         $qtd->setValue($produtos->getQtd());
         $row->addCell($qtd);
         $row = $this->table->addRow();
         $btn = new PButton('add', 'success');
         $btn->setLabel('Update');
         $action = new TAction(array($this, 'addItem'));
         $action->setParameter('id', $param['key']);
         $action->setParameters(array('id' => $param['key'], 'qtd' => $qtd->getValue()));
         $btn->setAction($action, 'add+');
         $row->addCell($btn);
         $this->form->setFields(array($btn, $qtd));
         // inserimos os campos no form
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('info', $e->getMessage());
     }
 }
 public function onGenerateKanban()
 {
     try {
         TTransaction::open('atividade');
         $object = $this->form->getData();
         $desenvolvimento = new RequisitoDesenvolvimento($object->id);
         $cliente_id = $desenvolvimento->ticket->solicitante_id;
         $responsavel_id = $desenvolvimento->ticket->responsavel_id;
         $pessoa = new Pessoa($cliente_id);
         $cliente = $pessoa->pessoa_nome;
         $pessoa = new Pessoa($responsavel_id);
         $responsavel = $pessoa->pessoa_nome;
         $data = $desenvolvimento->data_cadastro;
         $data = explode('-', $data);
         $data_prevista = '___/___/___';
         if ($desenvolvimento->ticket->data_prevista) {
             $data_prevista = $this->string->formatDateBR($desenvolvimento->ticket->data_prevista);
         }
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/kanban.pdf.xml');
         $designer->replace('{ID_DTR}', $desenvolvimento->ticket_id . '/' . $data[0]);
         $designer->replace('{CADASTRO}', $this->string->formatDateBR($desenvolvimento->data_cadastro));
         $designer->replace('{INICIO}', date('d/m/Y'));
         $designer->replace('{PREVISTA}', $data_prevista);
         $designer->replace('{SISTEMA}', utf8_decode($desenvolvimento->ticket->sistema->nome));
         $designer->replace('{TICKET}', $desenvolvimento->ticket_id);
         $designer->replace('{TITULO}', utf8_decode($desenvolvimento->titulo));
         $designer->replace('{SOLICITANTE}', utf8_decode($cliente));
         $designer->replace('{RESPONSAVEL}', utf8_decode($responsavel));
         $designer->generate();
         $tipo = array(4 => 'D', 5 => 'A', 6 => 'C');
         $nome = 'DTR011' . $tipo[$desenvolvimento->ticket->tipo_ticket_id] . $desenvolvimento->ticket_id . '-' . $data[0] . ' - ' . $desenvolvimento->titulo;
         $file = 'app/output/' . $nome . '.pdf';
         $designer->save($file);
         parent::openFile($file);
         TButton::enableField('form_RequisitoDesenvolvimento', 'save');
         $this->form->setData($object);
         // define the onEdit action
         $action = new TAction(array($this, 'onEdit'));
         $param['key'] = $object->id;
         $action->setParameters($param);
         // pass the key parameter ahead
         new TMessage('info', 'Cartão kambam gerado com sucesso!', $action);
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage);
     }
 }