public function forgetPassword($user) { $this->newRow()->setNome($user)->retrieve(); if (!$this->getId(true)->toPhp()) { throw new ZendT_Exception_Alert(_i18n('Usuário "%s" não encontrado!', $user)); } if ($this->getEmail(true)->toPhp()) { throw new ZendT_Exception_Alert(_i18n('Não existe um e-mail configurado para o usuário "%user", entre em contato com o Administrador!', $user)); } $_mail = new ZendT_Mail(); $_mail->addTo($this->getEmail(true)->get(), $this->getDescricao(true)->get()); $_mail->setSubject(_i18n('Recuperação de Senha')); $_mail->setBody(_i18n('Usuário: "%s"<br />Senha: "%s"', $this->getNome()->get(), $this->getSenha()->get())); $_mail->send(); return _i18n('Senha enviada para o e-mail "%s"!', $this->getEmail(true)->get()); }
public function runAction() { $_job = new Profile_Model_Job_Mapper(); $_job->setId($this->getRequest()->getParam('id'))->retrive()->setDhUltExec("SYSDATE")->update(); $_view = new Profile_DataView_Job_Users(); $where = new ZendT_Db_Where(); $where->addFilter('profile_job.id', $this->getRequest()->getParam('id')); $where->addFilter('usuario.email', "", "!NULL"); $data = $_view->recordset($where); while ($row = $data->getRow()) { try { $uri = $row['uri']->get(); if ($uri == '') { $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get()); } $uriOriginal = $uri . '/dynamic/profile/' . $row['id_profile']->get(); $uri .= '/found/profile/' . $row['id_profile']->get() . '/no_location/1?' . $row['uri_token']->get(); $client = new Zend_Http_Client($uri, array('timeout' => '80')); $response = $client->request(); if ($response->getBody() == 'OK') { $mail = new ZendT_Mail(); $mail->addTo($row['email_usuario']->get(), $row['nome_usuario']->get()); $mail->addFrom('*****@*****.**', 'Transportadora Americana'); $mail->setTitle($row['nome']->get()); $mail->setSubject($row['nome']->get()); $comment = $row['observacao']->get(); if (!$comment) { $comment = $row['nome']->get(); } $comment .= '<br><br>Para acessar o relatório clique <a href = "' . str_replace(array('/found/', '/no_location/1'), array('/dynamic/', ''), $uri) . '">aqui</a>'; $mail->setComment($comment); $body = '<br>'; $user = array(); $user['id'] = $row['id_usuario']->get(); $user['role'] = $row['nome_papel']->get(); $listProfile = ZendT_Profile::listProfile($row['objeto']->get(), '', $user); if (count($listProfile) > 0) { $body .= '<style type="text/css">'; $body .= ' <!--'; $body .= ' td {'; $body .= ' font-family: Arial, Helvetica, sans-serif;'; $body .= ' font-size: 12px;'; $body .= ' }'; $body .= ' .TitleTable {'; $body .= ' font-weight: bold;'; $body .= ' border-bottom: 0px;'; $body .= ' }'; $body .= ' .viewTitle {'; $body .= ' background-color: #F9F9F9;'; $body .= ' font-weight: bold;'; $body .= ' }'; $body .= ' .viewTable {'; $body .= ' border:1px solid #CCCCCC;'; $body .= ' }'; $body .= ' -->'; $body .= '</style>'; $body .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" class="viewTable">'; $body .= ' <tr >'; $body .= ' <td class="viewTitle">Visões Disponíveis</td>'; $body .= ' </tr>'; $body .= ' <tr>'; $body .= ' <td>'; $body .= ' <table width="100%" border="0" cellpadding="5" cellspacing="0">'; $body .= ' <tr>'; $body .= ' <td class="TitleTable">Tipo</td>'; $body .= ' <td class="TitleTable">Visão</td>'; $body .= ' <td class="TitleTable">Observação</td>'; $body .= ' </tr>'; foreach ($listProfile as $profile => $detailProfile) { $uri = ZendT_Lib::convertObjectToUri($row['objeto']->get()) . '/found/profile/' . $profile . '?' . $row['uri_token']->get(); $body .= ' <tr>'; $body .= ' <td>' . $detailProfile['tipoDescricao'] . '</td>'; $body .= ' <td><a href = "' . str_replace('/found/', '/dynamic/', $uri) . '">' . $detailProfile['nome'] . '</a></td>'; $body .= ' <td>' . $detailProfile['observacao'] . '</td>'; $body .= ' </tr>'; } $body .= ' </table>'; $body .= ' </td>'; $body .= ' </tr>'; $body .= '</table>'; } $mail->setBody($body); $mail->save(); } } catch (Exception $ex) { $mail = new ZendT_Mail(); /* $mail->addTo("*****@*****.**"); */ $mail->addTo("*****@*****.**"); $mail->addFrom('*****@*****.**', 'Transportadora Americana'); $mail->setTitle('Erro no envio de e-mail pelo agendamento de tarefa'); $mail->setSubject($mail->getTitle()); $comment = $row['nome']->get() . '<br><br>Para acessar o relatório clique <a href = "' . $uriOriginal . '">aqui</a>'; $mail->setComment($comment); $mail->setBody($ex->getMessage()); $mail->save(); /*echo 'Erro'; exit;*/ } } echo 'Processado'; exit; }
public function mailAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $driver = $this->getRequest()->getParam('driver'); $to = $this->getRequest()->getParam('to'); $subject = $this->getRequest()->getParam('subject'); $comment = $this->getRequest()->getParam('comment'); /** * Controle de cache */ $userId = Zend_Auth::getInstance()->getStorage()->read(); if (is_object($userId)) { $userName = $userId->getName(); $userEmail = $userId->getEmail(); $userId = $userId->getId(); } else { $userName = '******'; $userEmail = '*****@*****.**'; $userId = 0; } $idCache = 'profile' . $this->getRequest()->getParam('profile') . 'user' . $userId; $cache = new ZendT_Cache($idCache); $json = new ZendT_Json_Result(); try { if (!$to) { $form = new Profile_Form_ObjectView_Mail(); $params = $this->getRequest()->getParams(); foreach ($params as $name => $value) { if (!in_array($name, array('module', 'controller', 'action'))) { $hidden = new ZendT_Form_Element_Hidden($name); $hidden->setValue($value); $form->addElement($hidden); } } $form->loadElements(); $dataCache = $cache->get(); if ($dataCache) { $form->populate($dataCache); } $form->setAction(ZendT_Url::getUri()); throw new ZendT_Exception_Confirm($form->render()); } else { $data = array(); $data['to'] = $to; $data['subject'] = $subject; $data['comment'] = $comment; $cache->set($data); } $objectName = get_class($this->_mapper); $config = ZendT_Profile::get($objectName, 'C'); if ($config['id']) { $view = new ZendT_Report_View_Dynamic($driver, $this->_mapper, $config); $file = $view->renderFile($subject); $mail = new ZendT_Mail(); $to = str_replace(';', ',', trim($to)); $to = explode(',', $to); foreach ($to as $email) { $mail->addTo($email); } $mail->addFrom($userEmail, $userName); $mail->setTitle($subject); $mail->setSubject($subject); $mail->addAttachment($file->getFilename(), $file->getName(), 'Blob'); $mail->setComment($comment); $mail->setBody(' '); $mail->save(); } $json->setResult(true); } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); }