Exemplo n.º 1
0
 public function ChangePasswd()
 {
     $pass_result = $this->model->CheckEmail();
     $loaction = UR_MP;
     // check if logined go dashoard or not go back or default login page and show message
     switch ($pass_result[0]) {
         // login ssuccess
         case 1:
             TMail::SendMail($_POST['manager_email'], _lg("Remenber password"), _lg("Hi dear %s <br> Your new password is " . $pass_result['passwd']), array($_POST['manager_username']));
             if (!_DEVELOPER_) {
                 RedirectNotification($loaction . 'Access/Forget', 'Password sent, please check your mail.', NF_INFO);
             } else {
                 //                    die('zz');
                 RedirectNotification($loaction . 'Access/Forget', 'Password sent, please check your mail. [dev] Password is: %s', NF_INFO, array($pass_result['passwd']));
             }
             break;
             // login failed
         // login failed
         case 2:
             RedirectNotification($loaction . 'Access/Forget', 'Send new password failed: Username or email is incorrect.', NI_ERROR);
             break;
             // try failed tried more than max
         // try failed tried more than max
         case 3:
             $args = array($login_result['max'], $login_result['time']);
             RedirectNotification($loaction . 'Access/Forget', 'You have used up your failed login quota (%d)! Please wait %d minutes before trying again.', NI_ERROR, $args);
             break;
         default:
             if (_DBG_) {
                 echo 'unknow request';
             }
             break;
             return false;
     }
 }
Exemplo n.º 2
0
 function sendMailToUser($subject, $body, $user, $content, $conf, $type)
 {
     $config = JFactory::getConfig();
     $from = JOOMLA_J3 ? $config->get('mailfrom') : $config->getValue('config.mailfrom');
     $fromname = JOOMLA_J3 ? $config->get('fromname') : $config->getValue('config.fromname');
     $sitename = JOOMLA_J3 ? $config->get('sitename') : $config->getValue('config.sitename');
     $content = $this->getContent($content->id, false);
     $this->prepareMail($subject, $body, $user, $content, $conf, "user", $type);
     if ($user->email == '') {
         $mail = $content->email;
     } else {
         $mail = $user->email;
     }
     if ($mail != '') {
         if (!TMail::sendMail($from, $fromname, $mail, $subject, $body, 1)) {
             $this->setError(JText::_('ADSMANAGER_ERROR_SENDING_MAIL'));
             return false;
         }
     }
     return true;
 }
Exemplo n.º 3
0
 function sendmessage()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $contentid = JRequest::getInt('contentid', 0);
     $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models');
     $contentmodel = $this->getModel("content");
     $content = $contentmodel->getContent($contentid);
     $configurationmodel = $this->getModel("configuration");
     $conf = $configurationmodel->getConfiguration();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     try {
         $results = $dispatcher->trigger('ADSonMessageBeforeSend', array());
     } catch (Exception $e) {
         $errorMsg = $e->getMessage();
         $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=message&contentid=' . $contentid), $errorMsg, 'message');
     }
     $config = JFactory::getConfig();
     $from = JOOMLA_J3 ? $config->get('mailfrom') : $config->getValue('config.mailfrom');
     $fromname = JOOMLA_J3 ? $config->get('fromname') : $config->getValue('config.fromname');
     if (isset($content)) {
         $name = JRequest::getVar('name', "");
         $email = JRequest::getVar('email', "");
         jimport('joomla.mail.helper');
         if (!JMailHelper::isEmailAddress($email)) {
             $this->setError(JText::_('INVALID_EMAIL_ADDRESS'));
             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), 'INVALID_EMAIL_ADDRESS', 'message');
         }
         $subject = JRequest::getVar('title', "");
         $body = JRequest::getVar('body', "");
         $body = str_replace(array("\r\n", "\n", "\r"), "<br />", $body);
         $files = array();
         for ($i = 0; $i < $conf->number_allow_attachement; $i++) {
             $file = JRequest::getVar('attach_file' . $i, null, 'FILES');
             if ($file != null && is_uploaded_file($file['tmp_name'])) {
                 $tempPath = $config->get('tmp_path');
                 move_uploaded_file($file['tmp_name'], $tempPath . '/' . basename($file['name']));
                 $files[] = $tempPath . '/' . basename($file['name']);
             }
         }
         if (empty($files)) {
             $files = null;
         }
         if ($files != null) {
             //TODO manage replyto, the problem is that replyto doesn't replace sender
             if (!TMail::sendMail($email, $name, $content->email, $subject, $body, 1, NULL, NULL, $files)) {
                 $this->setError(JText::_('ADSMANAGER_ERROR_SENDING_MAIL'));
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), JText::_('ADSMANAGER_ERROR_SENDING_MAIL'), 'message');
             }
             //Uncomment if you want a copy of all email send between users
             if (isset($conf->copy_to_admin) && $conf->copy_to_admin == 1) {
                 $mailcontent = "Sender: {$name} - {$email}<br/>";
                 $mailcontent .= "Ad Owner: {$content->email} (userid={$content->userid})<br/>";
                 $mailcontent .= "Ad id: {$content->id}<br/>";
                 $mailcontent .= "Ad title: {$content->ad_headline}<br/>";
                 $mailcontent .= "Message: {$body}";
                 if (!TMail::sendMail($from, $fromname, $from, $subject, $mailcontent, 1, NULL, NULL, $filename)) {
                     $this->setError(JText::_('ADSMANAGER_ERROR_SENDING_MAIL'));
                     $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), JText::_('ADSMANAGER_ERROR_SENDING_MAIL'), 'message');
                 }
             }
             foreach ($files as $file) {
                 unlink($tempPath . '/' . basename($file['name']));
             }
         } else {
             if (!TMail::sendMail($email, $name, $content->email, $subject, $body, 1)) {
                 $this->setError(JText::_('ADSMANAGER_ERROR_SENDING_MAIL'));
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), JText::_('ADSMANAGER_ERROR_SENDING_MAIL'), 'message');
             }
             $mailcontent = "Sender: {$name} - {$email}<br/>";
             $mailcontent .= "Ad Owner: {$content->email} (userid={$content->userid})<br/>";
             $mailcontent .= "Ad id: {$content->id}<br/>";
             $mailcontent .= "Ad title: {$content->ad_headline}<br/>";
             $mailcontent .= "Message: {$body}";
             //Uncomment if you want a copy of all email send between users
             if (isset($conf->copy_to_admin) && $conf->copy_to_admin == 1) {
                 if (!TMail::sendMail($from, $fromname, $from, $subject, $body, 1)) {
                     $this->setError(JText::_('ADSMANAGER_ERROR_SENDING_MAIL'));
                     $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), JText::_('ADSMANAGER_ERROR_SENDING_MAIL'), 'message');
                 }
             }
         }
     }
     $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=details&catid=' . $content->catid . '&id=' . $contentid), JText::_('ADSMANAGER_EMAIL_SENT'), 'message');
 }
Exemplo n.º 4
0
     $doc = new RReporte();
     $doc->setCubiculo($_POST['cubiculo']);
     $doc->setDoctor($_POST['usuario']);
     $doc->setConsultorio($_POST['consultorio']);
     $doc->setTurno($_POST['turno']);
     $doc->setMes($_POST['mes']);
     $doc->setAnio($_POST['anio']);
     $documento = $doc->output();
     if ($documento == '') {
         $result = array("doc" => "", "band" => false);
     } else {
         if ($_POST['enviar'] == 'no') {
             $result = array("doc" => $documento, "band" => true);
         } else {
             global $sesion;
             $email = new TMail();
             $consultorio = new TConsultorio($_POST['consultorio']);
             $email->setTema("Reporte " . utf8_decode($consultorio->getClave() . " " . $consultorio->getNombre()));
             $email->setDestino($consultorio->supervisor->getEmail(), utf8_decode($consultorio->supervisor->getNombreCompleto()));
             $doctor = new TDoctor($_POST['usuario'] == '' ? $sesion['usuario'] : $_POST['usuario']);
             $datos = array();
             $datos['nombreCompleto'] = $consultorio->supervisor->getNombreCompleto();
             $datos['nombreDoctor'] = $doctor->getNombreCompleto();
             $email->setBodyHTML(utf8_decode($email->construyeMail(file_get_contents("repositorio/mail/reporteDoctor.txt"), $datos)));
             $email->adjuntar($documento);
             $result = array("doc" => $documento, "band" => $email->send(), "emailSupervisor" => $consultorio->supervisor->getEmail());
         }
     }
     print json_encode($result);
     break;
 case 'generalExcel2':
Exemplo n.º 5
0
     }
     echo json_encode($datos);
     break;
 case 'pdf':
     require_once getcwd() . "/repositorio/pdf/cotizacion.php";
     $obj = new RCotizacion($_GET['id']);
     $obj->generar();
     $documento = $obj->Output();
     if ($documento == '') {
         $result = array("doc" => "", "band" => false);
     } else {
         if ($_GET['email'] == 'no') {
             $result = array("band" => true, "documento" => $obj->Output());
         } else {
             global $sesion;
             $email = new TMail();
             $cotizacion = new TCotizacion($_GET['id']);
             $email->setTema("Su cotización");
             $email->setDestino($cotizacion->cliente->getEmail(), utf8_decode($cotizacion->cliente->getNombre()));
             $datos = array();
             $datos['nombreCompleto'] = $cotizacion->cliente->getNombre();
             $datos['ligaActualizacionDatosCliente'] = $ini["sistema"]["url"] . "?mod=clienteDatos&data=" . base64_encode($cotizacion->cliente->getId());
             $email->setBodyHTML(utf8_decode($email->construyeMail(file_get_contents("repositorio/mail/cotizacion.txt"), $datos)));
             $email->adjuntar($documento);
             $result = array("doc" => $documento, "band" => $email->send(), "email" => $cotizacion->cliente->getEmail());
         }
     }
     print json_encode($result);
     break;
 case 'autocompleteRopa':
     $db = TBase::conectaDB();
Exemplo n.º 6
0
 /**
  * method onSave()
  * Executed whenever the user clicks at the save button
  */
 function onSave()
 {
     try {
         // open a transaction with database 'changeman'
         TTransaction::open('changeman');
         // get the form data into an active record Note
         $object = $this->form->getData('Note');
         $logged = Member::newFromLogin(TSession::getValue('login'));
         $object->id_user = $logged->id;
         $object->register_date = date('Y-m-d');
         $object->register_time = date('H:i');
         // form validation
         $this->form->validate();
         // stores the object
         $object->store();
         $issue = new Issue($object->id_issue);
         $project = new Project($issue->id_project);
         $member = new Member($issue->id_user);
         // who has opened the issue
         // read email configuration file
         $ini = parse_ini_file('app/config/email.ini');
         $members = $project->getMembers(array('MEMBER', 'MANAGER'));
         $members = array_merge($members, array($member));
         // merge the logged user
         $mail_template = file_get_contents('app/resources/note.html');
         $mail_template = str_replace('{DESCRIPTION}', $issue->description, $mail_template);
         $mail_template = str_replace('{OPENER}', $member->name . ' ' . $issue->register_date . ' ' . $issue->issue_time, $mail_template);
         $mail_template = str_replace('{NOTE}', $object->note, $mail_template);
         $mail_template = str_replace('{MEMBER}', $logged->name . ' ' . $object->register_date . ' ' . $object->register_time, $mail_template);
         $mail = new TMail();
         $mail->setFrom($ini['from'], $ini['name']);
         $mail->setSubject(_t('Note') . ' #' . $issue->id . ': ' . $issue->title);
         $mail->setHtmlBody($mail_template);
         foreach ($members as $member) {
             $emails = explode(',', $member->email);
             foreach ($emails as $email) {
                 $mail->addAddress(trim($email), $member->name);
                 // echo "{$email}, {$member-> name} <br>";
             }
         }
         $mail->SetUseSmtp();
         $mail->SetSmtpHost($ini['host'], $ini['port']);
         $mail->SetSmtpUser($ini['user'], $ini['pass']);
         $mail->setReplyTo($ini['repl']);
         $mail->send();
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
         // shows the success message
         new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
         // reload the listing
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
Exemplo n.º 7
0
 /**
  * method onSave()
  * Executed whenever the user clicks at the save button
  */
 function onSave()
 {
     try {
         // open a transaction with database 'changeman'
         TTransaction::open('changeman');
         // get the form data into an active record Release
         $object = $this->form->getData('Release');
         $sendmail = $object->sendmail == 'Y';
         unset($object->sendmail);
         // form validation
         $this->form->validate();
         // stores the object
         $object->store();
         if ($sendmail) {
             // read email configuration file
             $ini = parse_ini_file('app/config/email.ini');
             $project = new Project($object->id_project);
             $members = $project->getMembers();
             foreach ($members as $member) {
                 $emails = explode(',', $member->email);
                 foreach ($emails as $email) {
                     $mail = new TMail();
                     $mail->setFrom($ini['from'], $ini['name']);
                     $mail->setSubject(_t('Release') . ': ' . $object->name);
                     $mail->setHtmlBody($object->description);
                     $mail->addAddress(trim($email), $member->name);
                     $mail->SetUseSmtp();
                     $mail->SetSmtpHost($ini['host'], $ini['port']);
                     $mail->SetSmtpUser($ini['user'], $ini['pass']);
                     $mail->setReplyTo($ini['repl']);
                     $mail->send();
                     echo "{$email}, {$member->name}<br>";
                 }
             }
         }
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
         // shows the success message
         new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
         // reload the listing
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
Exemplo n.º 8
0
 public function onEnviaEmail()
 {
     try {
         TTransaction::open('atividade');
         $object = $this->form->getData('Ticket');
         $vars['tipo_origens'] = $object->tipo_origens;
         $vars['codigo_cadastro_origem'] = $object->codigo_cadastro_origem;
         $vars['solicitante_id'] = $object->solicitante_id;
         $this->onChangeOrigem($vars);
         $this->onChangeTipoOrigem($vars);
         $this->onSetarValoresCombo($vars);
         $status = $object->status_ticket->nome;
         $solicitante = new Pessoa($object->solicitante_id);
         $cliente = $solicitante->pessoa_nome;
         $email1 = $solicitante->email1;
         $empresa = $solicitante->origem_nome;
         $responsavel = new Pessoa($object->responsavel_id);
         $colaborador = $responsavel->pessoa_nome;
         $email2 = $responsavel->email1;
         $table = new TTable();
         $table->border = 0;
         $table1 = new TTable();
         $table1->border = 1;
         $table2 = new TTable();
         $table2->border = 1;
         $table3 = new TTable();
         $table3->border = 1;
         $table4 = new TTable();
         $table4->border = 1;
         $imagem = new TImage('app/images/tecbiz.jpg');
         $imagem->height = 63;
         $imagem->width = 96;
         $row = $table->addRow();
         $cell = $row->addCell($imagem);
         $cell->style = 'width: 100px;';
         $cell = $row->addCell("Prezado <br /> {$cliente} do(a) {$empresa} <br /> Foi registrado um ticket com sua solicitação conforme os dados a seguir:");
         $cell->style = 'width: 700px;';
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Inicial:</b></u></span>');
         $row = $table1->addRow();
         $cell = $row->addCell('<b>No. Ticket:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->id);
         $cell->style = 'width: 600px;';
         $row = $table1->addRow();
         $row->addCell('<b>Título Ticket:</b>');
         $row->addCell($object->titulo);
         $row = $table1->addRow();
         $row->addCell('<b>Data/Hora:</b>');
         $row->addCell(date('d/m/Y H:i'));
         $row = $table1->addRow();
         $row->addCell('<b>Status:</b>');
         $row->addCell($status);
         $row = $table1->addRow();
         $row->addCell('<b>Solicitante:</b>');
         $row->addCell($cliente);
         $row = $table1->addRow();
         $row->addCell('<b>Colaborador TecBiz:</b>');
         $row->addCell($colaborador);
         $row = $table->addRow();
         $cell = $row->addCell($table1);
         $cell->colspan = 2;
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Solicitação:</b></u></span>');
         $row = $table2->addRow();
         $cell = $row->addCell('<b>Descrição:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->solicitacao_descricao);
         $cell->style = 'width: 520px;';
         $cell = $row->addCell($object->data_cadastro);
         $cell->style = 'width: 80px;';
         $row = $table->addRow();
         $cell = $row->addCell($table2);
         $cell->colspan = 2;
         $row = $table->addRow();
         $row->addCell('<span style="color: DarkOliveGreen;"><b><u>Orçamento:</b></u></span>');
         $row = $table3->addRow();
         $cell = $row->addCell('<b>Horas orçadas:</b>');
         $cell->style = 'width: 200px;';
         $cell = $row->addCell($object->orcamento_horas);
         $cell->style = 'width: 600px;';
         $row = $table3->addRow();
         $row->addCell('<b>Valor Hora:</b>');
         $row->addCell('R$ ' . $object->orcamento_valor_hora);
         $row = $table3->addRow();
         $row->addCell('<b>Valor Total:</b>');
         $row->addCell('R$ ' . $object->valor_total);
         $row = $table3->addRow();
         $row->addCell('<b>Forma de pagamento:</b>');
         $row->addCell($object->forma_pagamento);
         $row = $table3->addRow();
         $row = $table->addRow();
         $cell = $row->addCell($table3);
         $cell->colspan = 2;
         $row = $table4->addRow();
         $cell = $row->addCell('<span style="color: red;"><b>Importante:</b></span> Para dar seguimento a esta solicitação será necessário a aprovação da descrição e orçamento deste Ticket');
         $cell->style = 'width: 800px;';
         $row = $table->addRow();
         $cell = $row->addCell($table4);
         $cell->colspan = 2;
         TTransaction::close();
         $ini = parse_ini_file('app/config/email.ini');
         $mail = new TMail();
         $mail->setFrom($ini['from'], $ini['name']);
         $mail->setSubject('TecBiz criou um ticket para voce');
         $mail->setHtmlBody($table);
         $mail->addAddress($email1);
         $mail->addCC($email2);
         $mail->addBCC('*****@*****.**');
         // Se tiver anexo
         if (isset($target_file)) {
             $mail->addAttach($target_file);
         }
         $mail->SetUseSmtp();
         $mail->SetSmtpHost($ini['host'], $ini['port']);
         $mail->SetSmtpUser($ini['user'], $ini['pass']);
         $mail->setReplyTo($ini['repl']);
         $mail->send();
         new TMessage('info', 'Email enviado com sucesso');
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
     $this->form->setData($object);
 }
Exemplo n.º 9
0
 /**
  * method onSave()
  * Executed whenever the user clicks at the save button
  */
 function onSave()
 {
     try {
         // open a transaction with database 'changeman'
         TTransaction::open('changeman');
         // get the form data into an active record Issue
         $object = $this->form->getData('Issue');
         $member = Member::newFromLogin(TSession::getValue('login'));
         // standard values
         $object->id_user = $member->id;
         $object->id_status = 1;
         // NEW
         // form validation
         $this->form->validate();
         // stores the object
         $object->store();
         // have attachments
         if ($object->file) {
             $target_folder = 'attach/' . $object->id;
             $target_file = $target_folder . '/' . $object->file;
             @mkdir($target_folder);
             rename('tmp/' . $object->file, $target_file);
         }
         $project = new Project($object->id_project);
         // read email configuration file
         $ini = parse_ini_file('app/config/email.ini');
         $members = $project->getMembers(array('MEMBER', 'MANAGER'));
         $members = array_merge($members, array($member));
         // merge the logged user
         $mail_template = file_get_contents('app/resources/ticket_open.html');
         $mail_template = str_replace('{DESCRIPTION}', $object->description, $mail_template);
         $mail_template = str_replace('{OPENER}', $member->name . ' ' . $object->register_date . ' ' . $object->issue_time, $mail_template);
         $mail = new TMail();
         $mail->setFrom($ini['from'], $ini['name']);
         $mail->setSubject(_t('Issue') . ' #' . $object->id . ': ' . $object->title . ' (' . $object->status . ')');
         $mail->setHtmlBody($mail_template);
         foreach ($members as $member) {
             $emails = explode(',', $member->email);
             foreach ($emails as $email) {
                 $mail->addAddress(trim($email), $member->name);
                 // echo "{$email}, {$member-> name} <br>";
             }
         }
         if (isset($target_file)) {
             $mail->addAttach($target_file);
         }
         $mail->SetUseSmtp();
         $mail->SetSmtpHost($ini['host'], $ini['port']);
         $mail->SetSmtpUser($ini['user'], $ini['pass']);
         $mail->setReplyTo($ini['repl']);
         $mail->send();
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
         // shows the success message
         new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
         // reload the listing
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage() . '<br>' . _t('Try again'));
         // undo all pending operations
         TTransaction::rollback();
     }
 }
Exemplo n.º 10
0
             $datos['Fecha'] = $reporte->getFecha();
             $datos['Direccion'] = $reporte->getDireccion();
             $datos['comentario1'] = $reporte->getCampo1();
             $datos['comentario2'] = $reporte->getCampo2();
             $datos['comentario3'] = $reporte->getCampo3();
             $email->setBodyHTML(utf8_decode($email->construyeMail(file_get_contents("repositorio/mail/ubicacion.txt"), $datos)));
             $email->adjuntar($img);
             $email->send();
             $rs->moveNext();
         }
         $result = array("doc" => $documento, "band" => true);
         echo json_encode($result);
         break;
     case 'solicitarUbicacionMail':
         $db = TBase::conectaDB();
         $email = new TMail();
         $usuario = new TUsuario($_GET['user']);
         $origen = new TUsuario($_GET['solicita']);
         $datos = json_decode(file_get_contents("data.json"));
         foreach ($datos as $key => $val) {
             $config[$key] = $val;
         }
         $email->setTema(utf8_decode("Solicitud de ubicación"));
         $email->setDestino($usuario->getEmail(), utf8_decode($usuario->getNombre()));
         $datos = array();
         $datos['nombreCompleto'] = $usuario->getNombre();
         $datos['direccionReportar'] = $config['web'] . "/?mod=reportarUbicacion&usuario=" . base64_encode($usuario->getId()) . "&solicita=" . base64_encode($origen->getId());
         $email->setBodyHTML(utf8_decode($email->construyeMail(file_get_contents("repositorio/mail/ubicar.txt"), $datos)));
         echo json_encode(array("band" => $email->send()));
         break;
 }