public function indexAction()
    {
        $this->view->headTitle('Contato');
        $categoriaModel = new Application_Model_Categoria();
        $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
        $this->view->categorias = $nome_categorias;
        require_once APPLICATION_PATH . '/forms/Contato.php';
        $this->view->form = new Application_Form_Contato();
        if ($this->_request->isPost()) {
            $this->view->form->setDefaults($this->_request->getPost());
            $data = $this->view->form->getValues();
            if ($this->view->form->isValid($data)) {
                $contatosModel = new Application_Model_Contatos();
                $id = $contatosModel->insert($data);
                $data = '<html><body><table>
					<tr><td>Nome</td>
					<td>' . $_POST['nome'] . '</td></tr>
					<tr><td>E-mail</td>
					<td>' . $_POST['email'] . '</td></tr>
					<tr><td>Telefone</td>
					<td>' . $_POST['telefone'] . '</td></tr>
					<tr><td>Texto</td>
					<td>' . $_POST['mensagem'] . '</td></tr>
					</table></body></html>';
                // Using the ini_set()
                ini_set("SMTP", "localhost");
                ini_set("sendmail_from", "*****@*****.**");
                ini_set("smtp_port", "587");
                $mail = new Zend_Mail('UTF-8', 'ISO-8859-8');
                $mail->setBodyHtml($data)->setFrom('*****@*****.**', 'Formulario de Contato')->addTo('*****@*****.**', 'Contato')->setSubject('Contato')->send();
                return $this->_helper->redirector('index');
            }
        }
    }
 public function indexAction()
 {
     $this->view->headTitle('Sobre nós');
     $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
     if (isset($sessao->produtos)) {
         $carrinhoContador = sizeof($sessao->produtos);
     } else {
         $carrinhoContador = 0;
     }
     if ($carrinhoContador == 0) {
         $this->view->carrinhoImagem = '';
     } else {
         if ($carrinhoContador < 5) {
             $this->view->carrinhoImagem = $carrinhoContador;
         } else {
             $this->view->carrinhoImagem = 4;
         }
     }
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $menuModel = new Application_Model_Menus();
     $menu = $menuModel->fetchAll($menuModel->select()->where('id_menu = 1'));
     $this->view->menu = $menu;
 }
 public function indexAction()
 {
     $this->view->headTitle('Como Comprar');
     $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
     if (isset($sessao->produtos)) {
         $carrinhoContador = sizeof($sessao->produtos);
     } else {
         $carrinhoContador = 0;
     }
     if ($carrinhoContador == 0) {
         $this->view->carrinhoImagem = '';
     } else {
         if ($carrinhoContador < 5) {
             $this->view->carrinhoImagem = $carrinhoContador;
         } else {
             $this->view->carrinhoImagem = 4;
         }
     }
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $comoModel = new Application_Model_Comocomprar();
     $como = $comoModel->fetchAll($comoModel->select()->where('id = 1'));
     $url = $como[0]['link'];
     $this->Youtube($url);
     $emb = $this->getObj($url);
     $this->view->video = $emb;
 }
 public function indexAction()
 {
     $this->view->headTitle('Novidades');
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
     if (isset($sessao->produtos)) {
         $carrinhoContador = sizeof($sessao->produtos);
     } else {
         $carrinhoContador = 0;
     }
     if ($carrinhoContador == 0) {
         $this->view->carrinhoImagem = '';
     } else {
         if ($carrinhoContador < 5) {
             $this->view->carrinhoImagem = $carrinhoContador;
         } else {
             $this->view->carrinhoImagem = 4;
         }
     }
     $noticiaModel = new Application_Model_Novidades();
     $this->view->noticia = $noticiaModel->fetchAll($noticiaModel->select()->where('excluido = 0'));
     $busca = $this->_request->getParam('busca');
 }
 public function indexAction()
 {
     $this->view->headTitle('Cardápio');
     $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
     if (isset($sessao->produtos) && sizeof($sessao->produtos) > 0) {
         foreach ($sessao->produtos as $produto => $quantidade) {
             for ($i = 0; $i < $quantidade; $i++) {
                 $produtos[] = $produto;
             }
         }
         $this->view->carro = $produtos;
     }
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $busca = $this->_request->getParam('categoria');
     $this->view->cat = $busca;
     if ($busca == 'Combos') {
         $comboModel = new Application_Model_Combo();
         $this->view->produto = $comboModel->fetchAll($comboModel->select()->where('excluido = 0'));
     } else {
         $produtoModel = new Application_Model_Produto();
         $this->view->produto = $produtoModel->fetchAll($produtoModel->select()->where('excluido = 0')->where('categoria LIKE :busca')->bind(array('busca' => '%' . $busca . '%')));
     }
     $produto = $this->_request->getParam('produto');
 }
 public function indexAction()
 {
     $this->view->headTitle('Sobre nós');
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $menuModel = new Application_Model_Menus();
     $menu = $menuModel->fetchAll($menuModel->select()->where('id_menu = 1'));
     $this->view->menu = $menu;
 }
 public function indexAction()
 {
     $this->view->headTitle('Novidades');
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $noticiaModel = new Application_Model_Novidades();
     $this->view->noticia = $noticiaModel->fetchAll($noticiaModel->select()->where('excluido = 0'));
     $busca = $this->_request->getParam('busca');
 }
 public function indexAction()
 {
     $this->view->headTitle('Como Comprar');
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $comoModel = new Application_Model_Comocomprar();
     $como = $comoModel->fetchAll($comoModel->select()->where('id = 1'));
     $url = $como[0]['link'];
     $this->Youtube($url);
     $emb = $this->getObj($url);
     $this->view->video = $emb;
 }
 public function detalhesAction()
 {
     $categoriaModel = new Application_Model_Categoria();
     $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $this->view->categorias = $nome_categorias;
     $busca = $this->_request->getParam('id');
     $produtoModel = new Application_Model_Produto();
     $this->view->produto = $produtoModel->fetchAll($produtoModel->select()->where('id_produto = ?', $busca)->where('excluido = 0'));
     $ingredientes = array();
     $ingredModel = new Application_Model_Relacionamentos();
     $dados = $ingredModel->fetchAll($ingredModel->select()->where('excluido = 0')->where('id_produto = ?', $busca));
     foreach ($dados as $chave => $valor) {
         $ingredientes[] = $dados[$chave];
     }
     $this->view->ingredientes = $ingredientes;
 }
 public function init()
 {
     $this->addElement('text', 'nome', array('label' => 'Nome*', 'class' => 'campo-txt', 'required' => true));
     $this->addElement('text', 'descricao', array('label' => 'Descrição*', 'class' => 'campo-txt', 'required' => true));
     $this->addElement('file', 'pFoto', array('label' => 'Foto*', 'required' => true));
     $this->addElement('text', 'preco', array('label' => 'Preço*', 'class' => 'campo-txt', 'required' => true));
     $categoriaModel = new Application_Model_Categoria();
     $categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
     $categoriasArr = array();
     foreach ($categorias as $categoria) {
         $categoriasArr[$categoria['nome_categoria']] = $categoria['nome_categoria'];
     }
     $this->addElement('select', 'categoria', array('label' => 'Categoria: ', 'class' => 'campo-txt', 'multiple' => false, 'multiOptions' => $categoriasArr, 'registerInArrayValidator' => false));
     $this->addElement('checkbox', 'promocao', array('label' => 'Promover Produto?', 'checkedValue' => 1, 'uncheckedValue' => 0));
     $this->addElement('submit', 'submit_button', array('label' => 'Salvar', 'class' => 'bt-enviar', 'ignore' => true));
 }
 public function removerAction()
 {
     $id = $this->_request->getParam('id');
     $confirma = $this->_request->getParam('confirma');
     if (isset($confirma)) {
         if ($confirma == 1) {
             $categoriaModel = new Application_Model_Categoria();
             $categoriaModel->update(array('excluido' => '1'), 'id_categoria = ' . $id);
         }
         return $this->_helper->redirector('index');
     } else {
         $this->view->id = $this->_request->getParam('id');
         $categoriaModel = new Application_Model_Categoria();
         $nome_categoria = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria'))->where('id_categoria = ?', $id));
         $this->view->categoria = $nome_categoria;
     }
 }
    public function finalizarAction()
    {
        Zend_Loader::loadClass('Zend_Auth');
        $authClass = Zend_Auth::getInstance();
        if ($authClass->hasIdentity()) {
            $auth = $authClass->getStorage()->read();
            $idx = $auth['usuario_id'];
            $usuarioModel = new Application_Model_Usuario();
            $dados = 0;
            $dadosUsuario = $usuarioModel->fetchAll($usuarioModel->select()->from($usuarioModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('usuario'))->where('idusuario = ?', $idx));
            $dados = $dadosUsuario[0]['usuario'];
            $contatoModel = new Application_Model_Contato();
            $dadosContato = $contatoModel->fetchAll($contatoModel->select()->from($contatoModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('completo'))->where('usuario = ?', $dados));
            $this->view->dadosContato = $dadosContato;
        }
        $categoriaModel = new Application_Model_Categoria();
        $nome_categorias = $categoriaModel->fetchAll($categoriaModel->select()->from($categoriaModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('nome_categoria')));
        $this->view->categorias = $nome_categorias;
        $confirmar = $this->_request->getParam('confirmar');
        if (isset($confirmar)) {
            if ($confirmar == 1) {
                $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
                Zend_Loader::loadClass('Zend_Auth');
                $authClass = Zend_Auth::getInstance();
                if ($authClass->hasIdentity()) {
                    $auth = $authClass->getStorage()->read();
                    $id = $auth['usuario_id'];
                }
                /// function to generate random number ///////////////
                function random_generator($digits)
                {
                    srand((double) microtime() * 10000000);
                    //Array of alphabets
                    $input = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
                    $random_generator = "";
                    // Initialize the string to store random numbers
                    for ($i = 1; $i < $digits + 1; $i++) {
                        // Loop the number of times of required digits
                        if (rand(1, 2) == 1) {
                            // to decide the digit should be numeric or alphabet
                            // Add one random alphabet
                            $rand_index = array_rand($input);
                            $random_generator .= $input[$rand_index];
                            // One char is added
                        } else {
                            // Add one numeric digit between 1 and 10
                            $random_generator .= rand(1, 10);
                            // one number is added
                        }
                        // end of if else
                    }
                    // end of for loop
                    return $random_generator;
                }
                // end of function
                $key = random_generator(10);
                $key = md5($key);
                $date = date_create();
                $pedido = array();
                $pedido['cliente'] = $auth['usuario_id'];
                $pedido['data'] = date_format($date, 'c');
                $pedido['secure'] = $key;
                $pedido['valor'] = str_replace(array(',', '.'), '', $sessao->total);
                $pedidoModel = new Application_Model_Pedido();
                $id = $pedidoModel->insert($pedido);
                $pedido_id = $pedidoModel->fetchAll($pedidoModel->select()->where('secure = ?', $key));
                $pedido_xid = $pedido_id[0]['id_pedido'];
                $prodpedModel = new Application_Model_ProdutoPedido();
                $addModel = new Application_Model_Adicionais();
                if (isset($sessao->produtos)) {
                    foreach ($sessao->produtos as $posicao => $id) {
                        $chave = random_generator(10);
                        $chave = md5($chave);
                        $prod = array();
                        $prod['id_pedido'] = $pedido_xid;
                        $prod['id_produto'] = $id;
                        $prod['id_adicionais'] = $chave;
                        $id = $prodpedModel->insert($prod);
                        if (isset($sessao->quantidades[$posicao])) {
                            foreach ($sessao->quantidades[$posicao] as $ingred => $quanti) {
                                $adi = array();
                                $adi['id_adicionais'] = $chave;
                                $adi['id_adicional'] = $ingred;
                                $adi['quantidade'] = $quanti;
                                $id = $addModel->insert($adi);
                            }
                        }
                    }
                }
                $sessao->produtos = null;
                $sessao->quantidades = null;
                $sessao->total = null;
                $sessao->ingred = null;
                $email = $dadosContato[0]['email'];
                $data = '<html><body><table>
					<tr><td>Online Thru informa: Pedido recebido, valor R$ ' . number_format($pedido['valor'] / 100, 2, ',', '.') . '</td></tr>
					</table></body></html>';
                // Using the ini_set()
                ini_set("SMTP", "localhost");
                ini_set("sendmail_from", "*****@*****.**");
                ini_set("smtp_port", "587");
                $mail = new Zend_Mail('UTF-8', 'ISO-8859-8');
                $mail->setBodyHtml($data)->setFrom('*****@*****.**', 'Online Thru')->addTo($email, 'Online Thru')->setSubject('Online Thru - Pedido')->send();
                $this->view->aviso = "Pedido enviado com sucesso!";
            }
        } else {
            $sessao = new Zend_Session_Namespace('SESSAO_CARRINHO');
            $this->view->produtos = $sessao->produtos;
            if (!isset($sessao->ingred)) {
                $sessao->ingred = array();
            }
            if ($this->_request->isPost()) {
                $sessao->ingred = $this->_request->getPost();
                foreach ($sessao->ingred as $key => $value) {
                    $mystring = $key;
                    $findme = 'q';
                    $pos = strpos($mystring, $findme);
                    if ($pos === false) {
                        $mystring = $key;
                        $find = '-';
                        $posi = strpos($mystring, $find);
                        $chave = substr($key, 0, $posi);
                        $ingr = substr($key, $posi + 1, strlen($key));
                        $sessao->ingredientes[$chave][$ingr] = $value;
                    } else {
                        $key = str_replace('q-', '', $key);
                        $mystring = $key;
                        $find = '-';
                        $posi = strpos($mystring, $find);
                        $chave = substr($key, 0, $posi);
                        $ingr = substr($key, $posi + 1, strlen($key));
                        $sessao->quantidades[$chave][$ingr] = $value;
                    }
                    $idp = $sessao->produtos[$chave]['id_produto'];
                    $ingredModel = new Application_Model_Relacionamentos();
                    $nome_ingred = $ingredModel->fetchAll($ingredModel->select()->from($ingredModel->info(Zend_Db_Table_Abstract::NAME))->columns(array('qtd_padrao'))->where('id_produto = ?', $idp)->where('id_ingrediente = ?', $ingr));
                    if (isset($nome_ingred[0]['qtd_padrao'])) {
                        $padrao[$idp][$ingr] = $nome_ingred[0]['qtd_padrao'];
                    }
                }
            }
            if (isset($sessao->produtos) && sizeof($sessao->produtos) > 0) {
                if (isset($padrao)) {
                    $this->view->padrao = $padrao;
                }
                if (isset($sessao->quantidades)) {
                    $this->view->quantidades = $sessao->quantidades;
                }
                if (isset($sessao->ingredientes)) {
                    $this->view->ingredientes = $sessao->ingredientes;
                }
                if (isset($sessao->ingred)) {
                    $this->view->data = $sessao->ingred;
                }
            }
        }
    }