public function salva()
 {
     try {
         $model = new tutorialModel2();
         $model->codigo = '1';
         $model->link = $this->retornaLink();
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $model->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function atualizaCor()
 {
     try {
         $this->setCor(new coresModel2());
         $this->cor->codigo = $this->getCodigoCores();
         $this->cor->nome = $this->getNomeCores();
         $this->cor->cor1 = $this->getCor1Cores();
         $this->cor->cor2 = $this->getCor2Cores();
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $this->cor->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
     $controlador->setProdutoValor($_POST['valor']);
     $controlador->setProdutoLink($_POST['link']);
     $controlador->setProdutoAtivo($_POST['ativo']);
     if ($controlador->salvarProduto2() == true) {
         return true;
     } else {
         echo "<script> alert('Impossivel salvar Produto');</script>";
         return false;
     }
 } else {
     if ($request == 'uploadProduto') {
         $controlador = new controladorUpload();
         $produto = new catalogo_produtos2();
         TTransaction2::open('my_bd_site');
         $controlador->setNomeNovo($produto->getLast());
         TTransaction2::close();
         $controlador->setImagem_temp($_FILES["uploadBtn"]["tmp_name"]);
         $controlador->setImagem_nome($_FILES["uploadBtn"]["name"]);
         $controlador->setImagem_tamanho($_FILES["uploadBtn"]["size"]);
         $controlador->setImagem_tipo($_FILES["uploadBtn"]["type"]);
         if ($controlador->upload()) {
             return true;
         } else {
             echo "<script> alert('Impossivel fazer o upload da imagem do produto!');</script>";
             return false;
         }
     } else {
         if ($request == 'apagaProdutos') {
             $codigos = $_POST['codigos'];
             $apagado = 0;
             $controladorProdutos = new controladorProdutos();
 public function apagaCategorias2($codigo)
 {
     try {
         $this->categoria = NULL;
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $this->categoria = new kanban_tarefas_categoria2();
         $this->categoria->delete($codigo);
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 private function update()
 {
     try {
         //Inicia Transação com banco de dados
         TTransaction2::open('my_bd_site');
         //Cria instrução INSERT
         $sql = new TSqlUpdate();
         //Define entidade
         $sql->setEntity('tecnicoinformatica');
         //Cria um critério de seleção pelo ID
         $criteria = new TCriteria();
         $criteria->add(new TFilter('codigo', '=', 1));
         $sql->setCriteria($criteria);
         //Atribui o valor a cada coluna
         $sql->setRowData('conteudo', $this->conteudo);
         //Obtem a conexão ativa
         $conn = TTransaction2::get();
         //Executa Instrução SQL
         $result = $conn->Query($sql->getInstruction());
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function alteraSenhaChave()
 {
     try {
         $this->setCliente(new clientes2());
         $clienteAux = $this->getClienteByChave2($this->getChave());
         $this->cliente->codigo = $clienteAux->codigo;
         $this->cliente->senha = $this->getSenha();
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $this->cliente->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function apagaProdutoOrcamento($codigo)
 {
     try {
         $this->setOrcamento(new orcamentoprodutoModel2());
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $criteria = new TCriteria();
         $criteria->add(new TFilter('codigoOrcamento', '=', $codigo));
         $this->orcamento->deleteCriteria($criteria);
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function salvaProdutosOrcamento()
 {
     try {
         foreach ($this->collectionOrcamentosProdutos as $produto) {
             $this->setOrcamentoProduto(new orcamentoprodutoModel2());
             $this->orcamentoProduto->codigoOrcamento = $produto[0];
             $this->orcamentoProduto->codigoProduto = $produto[1];
             $this->orcamentoProduto->quantidadePP = $produto[2];
             $this->orcamentoProduto->quantidadeP = $produto[3];
             $this->orcamentoProduto->quantidadeM = $produto[4];
             $this->orcamentoProduto->quantidadeG = $produto[5];
             $this->orcamentoProduto->quantidadeGG = $produto[6];
             $this->orcamentoProduto->quantidade48 = $produto[7];
             $this->orcamentoProduto->quantidade50 = $produto[8];
             $this->orcamentoProduto->quantidade52 = $produto[9];
             $this->orcamentoProduto->quantidade54 = $produto[10];
             $this->orcamentoProduto->referencia = $produto[11];
             $this->orcamentoProduto->nome = $produto[12];
             //RECUPERA CONEXAO BANCO DE DADOS
             TTransaction2::open('my_bd_site');
             $result = $this->orcamentoProduto->store();
             TTransaction2::close();
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Beispiel #9
0
 public function __construct()
 {
     //Situação
     TTransaction2::open('my_bd_site');
     $situacaonew = new kanban_situacao2();
     $situacaonew->nome = 'Situação 5';
     $situacaonew->ordem = 5;
     $situacaonew->store();
     TTransaction2::close();
     //Usuario
     TTransaction2::open('my_bd_site');
     for ($i = 0; $i < 3; $i++) {
         $usuario = new kanban_usuario2();
         $usuario->nome = 'usu_' . $i;
         $usuario->usuario = 'usu_' . $i;
         $usuario->senha = 'usu_' . $i;
         if ($i == 0) {
             $usuario->cor = '#ff0000';
         } else {
             if ($i == 1) {
                 $usuario->cor = '#00ff00';
             } else {
                 if ($i == 2) {
                     $usuario->cor = '#0000ff';
                 }
             }
         }
         $usuario->store();
     }
     TTransaction2::close();
     //Categorias
     TTransaction2::open('my_bd_site');
     for ($i = 0; $i < 5; $i++) {
         $categoria = new kanban_tarefas_categoria2();
         $categoria->nome = 'categoria_' . $i;
         if ($i == 0) {
             $categoria->cor = '#ff0000';
         } else {
             if ($i == 1) {
                 $categoria->cor = '#00ff00';
             } else {
                 if ($i == 2) {
                     $categoria->cor = '#0000ff';
                 } else {
                     if ($i == 3) {
                         $categoria->cor = '#ffff00';
                     } else {
                         if ($i == 4) {
                             $categoria->cor = '#00ffff';
                         }
                     }
                 }
             }
         }
         $categoria->store();
     }
     TTransaction2::close();
     //Tarefas
     TTransaction2::open('my_bd_site');
     for ($i = 0; $i < 1000; $i++) {
         if ($this->prioridade == 4) {
             $this->prioridade = 0;
         }
         if ($this->usuariocont == 4) {
             $this->usuariocont = 0;
         }
         if ($this->categoriacont == 5) {
             $this->categoriacont = 0;
         }
         $tarefa = new kanban_tarefas2();
         $tarefa->nome = 'tar_' . $i;
         $tarefa->criacao = '2014-08-27';
         $tarefa->prioridade = $this->prioridade;
         $tarefa->descricao = 'descrição tarefa ' . $i;
         $tarefa->categoria = $this->categoriacont;
         $tarefa->usuario = $this->usuariocont;
         $this->categoriacont++;
         $this->usuariocont++;
         $this->prioridade++;
         if ($i <= 500) {
             $tarefa->situacao = 1;
         } else {
             if ($i > 500 && $i <= 750) {
                 $tarefa->situacao = 2;
             } else {
                 if ($i > 750 && $i <= 850) {
                     $tarefa->situacao = 3;
                 } else {
                     if ($i > 850 && $i <= 950) {
                         $tarefa->situacao = 4;
                     } else {
                         $tarefa->situacao = 5;
                     }
                 }
             }
         }
         $tarefa->store();
     }
     TTransaction2::close();
     //Subtarefas
     TTransaction2::open('my_bd_site');
     for ($i = 0; $i < 1000; $i++) {
         $subtarefa = new kanban_tarefas_subtarefas2();
         $subtarefa->codigo_tarefa = $i + 1;
         $subtarefa->nome = "sub-tar {$i}_1";
         $subtarefa->concluido = true;
         $subtarefa->store();
         $subtarefa = new kanban_tarefas_subtarefas2();
         $subtarefa->codigo_tarefa = $i + 1;
         $subtarefa->nome = "sub-tar {$i}_2";
         $subtarefa->concluido = true;
         $subtarefa->store();
         $subtarefa = new kanban_tarefas_subtarefas2();
         $subtarefa->codigo_tarefa = $i + 1;
         $subtarefa->nome = "sub-tar {$i}_3";
         $subtarefa->concluido = false;
         $subtarefa->store();
         $subtarefa = new kanban_tarefas_subtarefas2();
         $subtarefa->codigo_tarefa = $i + 1;
         $subtarefa->nome = "sub-tar {$i}_4";
         $subtarefa->concluido = false;
         $subtarefa->store();
     }
     TTransaction2::close();
     echo 'OK';
 }
 private function getUsuario()
 {
     try {
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         //TABELA exposition_gallery
         $criteria = new TCriteria();
         $criteria->add(new TFilter(' usuario ', ' = ', "{$this->usuario}"));
         // instancia a instrução de SELECT
         $sql = new TSqlSelect();
         $sql->addColumn("usuario");
         $sql->addColumn("senha");
         $sql->addColumn("nome");
         $sql->setEntity('usuario');
         //  atribui o critério passado como parâmetro
         $sql->setCriteria($criteria);
         // obtém transação ativa
         if ($conn = TTransaction2::get()) {
             // registra mensagem de log
             TTransaction2::log($sql->getInstruction());
             // executa a consulta no banco de dados
             $result = $conn->Query($sql->getInstruction());
             $this->results = array();
             if ($result) {
                 // percorre os resultados da consulta, retornando um objeto
                 while ($row = $result->fetchObject()) {
                     // armazena no array $this->results;
                     $this->results[] = $row;
                 }
             }
         }
         TTransaction2::close();
     } catch (Exception $e) {
         $this->results = NULL;
     }
 }
 function getCollectionCores2($codigo)
 {
     $this->setCollectionCores(NULL);
     //RECUPERA CONEXAO BANCO DE DADOS
     TTransaction2::open('my_bd_site');
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->add(new TFilter('p.codigoProduto', '=', $codigo));
     $criteria->add(new TFilter('p.codigoCoresDefinidas', '=', 'c.codigo'));
     $criteria->setProperty('order', 'nome');
     $this->repository = new TRepository2();
     $this->repository->addColumn('p.codigo as codigo');
     $this->repository->addColumn('p.codigoProduto as codigoProduto');
     $this->repository->addColumn('p.codigoProduto as codigoProduto');
     $this->repository->addColumn('p.banner1 as banner1');
     $this->repository->addColumn('p.banner2 as banner2');
     $this->repository->addColumn('p.banner3 as banner3');
     $this->repository->addColumn('p.home as home');
     $this->repository->addColumn('p.codigoCoresDefinidas as codigoCoresDefinidas');
     $this->repository->addColumn('c.nome as nome');
     $this->repository->addColumn('c.cor1 as cor1');
     $this->repository->addColumn('c.cor2 as cor2');
     $this->repository->addEntity('produtoscores p');
     $this->repository->addEntity('cores c');
     $this->setCollectionCores($this->repository->load($criteria));
     TTransaction2::close();
     return $this->collectionCores;
 }
 public function salvarSubTarefa2()
 {
     try {
         $this->subTarefa = new kanban_tarefas_subtarefas2();
         $this->subTarefa->codigo = $this->getCodigo();
         $this->subTarefa->codigo_tarefa = $this->getCodigoTarefa();
         $this->subTarefa->nome = $this->getNomeSubTarefa();
         $this->subTarefa->concluido = $this->getConcluido();
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $this->subTarefa->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Beispiel #13
0
 function count(TCriteria $criteria)
 {
     $sql = new TSqlSelect();
     $sql->addColumn(' count(*) ');
     $sql->addEntity($this->entity[0]);
     $sql->setCriteria($criteria);
     if ($conn = TTransaction2::get()) {
         if ($result) {
             $row = $result->fetch();
         }
         return $row[0];
     } else {
         throw new Exception('Não há transação ativa!');
     }
 }
 public function salvarTarefa2()
 {
     try {
         $this->tarefa = new kanban_tarefas2();
         $this->tarefa->codigo = $this->getCodigo();
         $this->tarefa->nome = $this->getNome();
         $this->tarefa->criacao = $this->getCriacao();
         $this->tarefa->categoria = $this->getCategoria();
         $this->tarefa->prioridade = $this->getPrioridade();
         $this->tarefa->link = $this->getLink();
         $this->tarefa->descricao = $this->getDescricao();
         $this->tarefa->situacao = $this->getSituacao();
         $this->tarefa->usuario = $this->getUsuario();
         $this->tarefa->data_inicio = $this->getData_inicio();
         $this->tarefa->tempo_estimado = $this->getTempo_estimado();
         $this->tarefa->data_conclusao = $this->getData_conclusao();
         $this->tarefa->concluido = $this->getConcluido();
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $this->tarefa->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function apaga2($codigo)
 {
     try {
         $this->setCategoria(new categoriasModel2());
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $this->categoria->delete($codigo);
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function getLast()
 {
     if ($conn = TTransaction2::get()) {
         // cria instrução SQL
         $sql = new TSqlSelect();
         $sql->addColumn('max(codigo) as codigo');
         $sql->addEntity($this->getEntity());
         $result = $conn->query($sql->getInstruction());
         $row = $result->fetch();
         return $row[0];
     } else {
         throw new Exception('Não há transação ativa');
     }
 }
 public static function setLogger(TLogger $logger)
 {
     self::$logger = $logger;
 }
 public function alteraSenha()
 {
     try {
         $this->usuario = new kanban_usuario2();
         $this->usuario->codigo = $_SESSION['usuario']->codigo;
         $this->usuario->nome = $_SESSION['usuario']->nome;
         $this->usuario->usuario = $_SESSION['usuario']->usuario;
         $this->usuario->senha = $this->getSenha();
         $this->usuario->cor = $_SESSION['usuario']->cor;
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $result = $this->usuario->store();
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 private function deletePortifolio()
 {
     try {
         foreach ($this->collectionCodigo as $codigo) {
             //RECUPERA CONEXAO BANCO DE DADOS
             TTransaction2::open('my_bd_site');
             //TABELA exposition_gallery
             $criteria = new TCriteria();
             $criteria->add(new TFilter(' codigo ', ' = ', "{$codigo}"));
             // instancia a instrução de SELECT
             $sql = new TSqlDelete();
             $sql->setEntity('portifolio');
             //Define criterio de Exclusao
             $sql->setCriteria($criteria);
             //Obtem transação ativa
             if ($conn = TTransaction2::get()) {
                 //Faz o log e executa o SQL
                 TTransaction2::log($sql->getInstruction());
                 $result = $conn->exec($sql->getInstruction());
             }
             TTransaction2::close();
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function apagaSituacoes2($codigo)
 {
     try {
         $this->situacao = NULL;
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $this->situacao = new kanban_situacao2();
         $this->situacao->delete($codigo);
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 public function apagaProdutos2($codigo)
 {
     try {
         $this->produto = NULL;
         //RECUPERA CONEXAO BANCO DE DADOS
         TTransaction2::open('my_bd_site');
         $this->produto = new catalogo_produtos2();
         $this->produto->delete($codigo);
         TTransaction2::close();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }