public function init()
 {
     //$this->setAction('/administrador/confirmarventa');
     $this->clearDecorators();
     $this->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => ''))->addDecorator('Form');
     $this->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'p', 'class' => 'element-group'))));
     $clientes = new Application_Model_DbTable_Usuarios();
     $this->addElement('select', 'cliente', array());
     $this->cliente->addmultiOptions($clientes->select_clientes());
     $this->addElement('text', 'puntos', array('readonly' => 'Readonly'));
     $cliente = $clientes->traerdatosclientes();
     foreach ($cliente as $valor) {
         $id_primer_cliente = $valor->id_usuario;
         break;
     }
     $modeloModel = new Application_Model_DbTable_Usuarios();
     $rowset = $modeloModel->getAsKeyValue($id_primer_cliente);
     $this->puntos->setValue($rowset);
     $descuento = new Zend_form_element_text('descuento');
     $this->addElement($descuento);
     $validatorDigit = new Zend_Validate_Digits();
     $this->descuento->addValidator($validatorDigit);
     $this->descuento->setErrorMessages(array('messages' => 'El campo nombre solo puede contener Numeros'));
     $this->addElement('textarea', 'observacion', array());
     $this->addElement('text', 'mesa', array('required' => true, 'filters' => array('StringToLower')));
     $this->mesa->addValidator($validatorDigit);
     $this->mesa->setErrorMessages(array('messages' => 'El campo nombre solo puede contener Numeros'));
     $this->addElement('submit', 'Agregar', array('ignore' => true, 'decorators' => array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div')))));
 }
 public function envioemailmasivoAction()
 {
     $permiso = Zend_Registry::get('permiso');
     if ($permiso == 1) {
         $form = new Application_Form_Emailmasivo();
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->_getAllParams())) {
                 $html = new Zend_View();
                 $html->setScriptPath(APPLICATION_PATH . '/views/scripts/emails/');
                 $model = new Application_Model_DbTable_Usuarios();
                 $datosusuarios = $model->traerdatosclientes();
                 $asunto = $form->getValue('asunto');
                 $mensaje = $form->getValue('mensaje');
                 $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => '*****@*****.**', 'password' => 'capicuarestobar');
                 $smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
                 $mail = new Zend_Mail('utf-8');
                 $mail->setSubject($asunto);
                 $mail->setFrom('*****@*****.**', 'Administracion Capicua Restobar');
                 $html->assign('mensaje', $mensaje);
                 foreach ($datosusuarios as $subscriber) {
                     $mail->addTo($subscriber->email, $subscriber->nombre);
                 }
                 $bodyText = $html->render('template.phtml');
                 $mail->setBodyHtml($bodyText);
                 $mail->send($smtpConnection);
                 return $this->_redirect('/administrador');
             }
         }
         $this->view->form = $form;
     } else {
         echo '<script type="text/javascript"> 
             alert("Opcion valida solo para SuperAdminstrador "); 
             document.location="/administrador";
         </script> 
         ';
     }
 }