예제 #1
0
 public function customIndex($parameters)
 {
     $parameters['accounts'] = EmailAccount::all();
     $parameters['profiles'] = Profile::all();
     $parameters['notificationsAccount'] = Preference::getValue('octopusNotificationsAccount', 8);
     $parameters['managerProfile'] = Preference::getValue('octopusManagerProfile', 8);
     return $parameters;
 }
예제 #2
0
 public function customIndex($parameters)
 {
     $parameters['states'] = State::all();
     $parameters['defaultState'] = Preference::getValue('formsDefaultState', 4);
     $parameters['accounts'] = EmailAccount::all();
     $parameters['notificationsAccount'] = Preference::getValue('formsNotificationsAccount', 4);
     return $parameters;
 }
예제 #3
0
 public function customIndex($parameters)
 {
     $parameters['profiles'] = Profile::all();
     $parameters['billingProfile'] = Preference::getValue('projectsBillingProfile', 6);
     $parameters['accounts'] = EmailAccount::all();
     $parameters['notificationsAccount'] = Preference::getValue('projectsNotificationsAccount', 6);
     $parameters['hourPrice'] = Preference::getValue('projectsHourPrice', 6);
     return $parameters;
 }
예제 #4
0
 public function editCustomRecord($parameters)
 {
     $parameters['emailAccounts'] = EmailAccount::all();
     $parameters['templates'] = EmailTemplate::all();
     $parameters['themes'] = ComunikLibrary::getThemes();
     $parameters['emlHeaders'] = ComunikLibrary::getEmlHeaders();
     $parameters['groups'] = Group::all();
     $parameters['selectGroups'] = $parameters['object']->getGroups;
     $parameters['countries'] = Contact::getCountriesContacts(['lang' => auth('pulsar')->user()->lang_id_010]);
     $parameters['selectCountries'] = $parameters['object']->getCountries;
     // statistics
     $parameters['queueMailings'] = EmailSendQueue::where('campaign_id_047', $parameters['id'])->count();
     $parameters['sentMailings'] = EmailSendHistory::where('campaign_id_048', $parameters['id'])->count();
     $parameters['noSentMailings'] = EmailSendQueue::where('campaign_id_047', $parameters['id'])->where('status_id_047', 0)->count();
     $parameters['uniqueViewMailings'] = EmailSendHistory::where('campaign_id_048', $parameters['id'])->where('viewed_048', '>', 0)->count();
     $parameters['effectiveness'] = $parameters['uniqueViewMailings'] > 0 ? round($parameters['uniqueViewMailings'] / $parameters['sentMailings'] * 100, 2) : 0;
     return $parameters;
 }
예제 #5
0
 public function updateCustomRecord($parameters)
 {
     $account = ['name_013' => $this->request->input('name'), 'email_013' => $this->request->input('email'), 'reply_to_013' => empty($this->request->input('replyTo')) ? null : $this->request->input('replyTo'), 'outgoing_server_013' => $this->request->input('outgoingServer'), 'outgoing_user_013' => $this->request->input('outgoingUser'), 'outgoing_secure_013' => $this->request->input('outgoingSecure'), 'outgoing_port_013' => $this->request->input('outgoingPort'), 'incoming_type_013' => $this->request->input('incomingType'), 'incoming_server_013' => $this->request->input('incomingServer'), 'incoming_user_013' => $this->request->input('incomingUser'), 'incoming_secure_013' => $this->request->input('incomingSecure'), 'incoming_port_013' => $this->request->input('incomingPort')];
     // Get object to read password to check account
     if ($parameters['specialRules']['outgoingPassRule'] || $parameters['specialRules']['incomingPassRule']) {
         $oldAccount = EmailAccount::find($this->request->input('id'));
     }
     if (!$parameters['specialRules']['outgoingPassRule']) {
         $account['outgoing_pass_013'] = Crypt::encrypt($this->request->input('outgoingPass'));
     } else {
         $account['outgoing_pass_013'] = $oldAccount->outgoing_pass_013;
     }
     if (!$parameters['specialRules']['incomingPassRule']) {
         $account['incoming_pass_013'] = Crypt::encrypt($this->request->input('incomingPass'));
     } else {
         $account['incoming_pass_013'] = $oldAccount->incoming_pass_013;
     }
     $response = EmailServices::testEmailAccount($account);
     if ($response === true) {
         EmailAccount::where('id_013', $this->request->input('id'))->update($account);
     } else {
         return redirect()->route('edit' . ucfirst($this->routeSuffix), $parameters['urlParameters'])->withErrors($response)->withInput();
     }
 }
예제 #6
0
파일: Cron.php 프로젝트: syscover/forms
 public static function checkMessageToSend()
 {
     $notificationsAccount = Preference::getValue('formsNotificationsAccount', 4);
     $emailAccount = EmailAccount::find($notificationsAccount->value_018);
     if ($emailAccount == null) {
         return null;
     }
     $messages = Message::where('dispatched_405', false)->get();
     config(['mail.host' => $emailAccount->outgoing_server_013]);
     config(['mail.port' => $emailAccount->outgoing_port_013]);
     config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
     config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
     config(['mail.username' => $emailAccount->outgoing_user_013]);
     config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
     foreach ($messages as $message) {
         Mail::send(['html' => $message->template_405, 'text' => $message->text_template_405], ['dataMessage' => $message, 'dataTextMessage' => json_decode($message->data_message_405), 'data' => json_decode($message->data_405)], function ($m) use($emailAccount, $message) {
             $m->to($message->email_405, $message->name_405)->subject(trans($message->subject_405) . ' ' . json_decode($message->data_message_405)->name_form_405 . ' ( ID. ' . json_decode($message->data_405)->id_403 . (isset(json_decode($message->data_405)->email_403) && isset(json_decode($message->data_405)->email_403) != '' ? ' - ' . json_decode($message->data_405)->email_403 : null) . ' )');
             if ($emailAccount->reply_to_013 != null) {
                 $m->replyTo($emailAccount->reply_to_013);
             }
         });
         Message::where('id_405', $message->id_405)->update(['dispatched_405' => true, 'send_date_405' => date('U')]);
     }
 }
예제 #7
0
 private function sendRequestEmail($id, $action)
 {
     $octopusRequest = OctopusRequest::builder()->find($id);
     // get notification account
     $notificationsAccount = Preference::getValue('octopusNotificationsAccount', 8);
     $managerProfile = Preference::getValue('octopusManagerProfile', 8);
     $emailAccount = EmailAccount::find($notificationsAccount->value_018);
     $managers = User::builder()->where('profile_id_010', $managerProfile->value_018)->where('access_010', true)->get();
     if ($emailAccount == null) {
         return null;
     }
     config(['mail.host' => $emailAccount->outgoing_server_013]);
     config(['mail.port' => $emailAccount->outgoing_port_013]);
     config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
     config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
     config(['mail.username' => $emailAccount->outgoing_user_013]);
     config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
     $supervisor = User::builder()->find((int) $this->request->input('supervisor'));
     $shop = Shop::builder()->find($octopusRequest->shop_id_078);
     // send email to supervisor
     $dataMessage = ['emailTo' => $supervisor->email_010, 'nameTo' => $supervisor->name_010 . ' ' . $supervisor->surname_010, 'subject' => trans($action == 'update' ? 'octopus::pulsar.request_subject_update' : 'octopus::pulsar.request_subject_create', ['id' => $octopusRequest->id_078, 'name' => $supervisor->name_010, 'surname' => $supervisor->surname_010]), 'octopusRequest' => $octopusRequest, 'supervisor' => $supervisor, 'shop' => $shop, 'actions' => 'supervisor_request_actions_notification'];
     Mail::send('octopus::emails.request_notification', $dataMessage, function ($m) use($dataMessage) {
         $m->to($dataMessage['emailTo'], $dataMessage['nameTo'])->subject($dataMessage['subject']);
     });
     // send email to manager
     $dataMessage['actions'] = 'manager_request_actions_notification';
     Mail::send('octopus::emails.request_notification', $dataMessage, function ($m) use($dataMessage, $managers) {
         $m->subject($dataMessage['subject']);
         foreach ($managers as $manager) {
             $m->to($manager->email_010, $manager->name_010 . ' ' . $manager->surname_010);
         }
     });
 }
예제 #8
0
 private function sendOrderEmail($id, $action)
 {
     // send email confirmation
     $order = Order::builder()->find($id);
     $laboratory = Laboratory::builder()->where('favorite_073', true)->get()->first();
     // get notification account
     $notificationsAccount = Preference::getValue('octopusNotificationsAccount', 8);
     $emailAccount = EmailAccount::find($notificationsAccount->value_018);
     if ($emailAccount == null) {
         return null;
     }
     config(['mail.host' => $emailAccount->outgoing_server_013]);
     config(['mail.port' => $emailAccount->outgoing_port_013]);
     config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
     config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
     config(['mail.username' => $emailAccount->outgoing_user_013]);
     config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
     $supervisor = User::builder()->find($order->supervisor_id_079);
     $shop = Shop::builder()->find($order->shop_id_079);
     // send email to laboratory
     $dataMessage = ['emailTo' => $laboratory->email_073, 'nameTo' => $laboratory->company_name_073, 'subject' => trans($action == 'update' ? 'octopus::pulsar.order_subject_update' : 'octopus::pulsar.order_subject_create', ['id' => $order->id_079, 'name' => $supervisor->name_010, 'surname' => $supervisor->surname_010]), 'order' => $order, 'supervisor' => $supervisor, 'shop' => $shop, 'key' => Crypt::encrypt($order->id_079), 'actions' => 'laboratory_order_actions_notification'];
     Mail::send('octopus::emails.order_notification', $dataMessage, function ($m) use($dataMessage) {
         $m->to($dataMessage['emailTo'], $dataMessage['nameTo'])->subject($dataMessage['subject']);
     });
 }
예제 #9
0
파일: Cron.php 프로젝트: syscover/comunik
 /**
  * Recursive function
  *
  * @param \Syscover\Pulsar\Libraries\ImapServices   $imapService
  * @param \Syscover\Pulsar\Models\EmailAccount      $account
  * @param \Illuminate\Support\Collection            $patterns
  * @param integer                                   $position
  */
 public static function checkBouncedMessagesFromAccount($imapService, $account, $patterns, $position)
 {
     $nEmailsToChecck = 25;
     // Solicitamos los 10 anteriores mensajes a comprobar desde la última posición comnprobada
     $messages = $imapService->getServer()->getMessages($nEmailsToChecck, $position);
     $findLastCheckUid = false;
     foreach ($messages as $key => $message) {
         // comprobamos si el mensaje coincide con algún patron
         $response = ComunikLibrary::checkEmailPattern($message, $patterns);
         if ($response['success']) {
             if (count($response['contacts']) > 0) {
                 // Obtenemos el primer contacto del email que ha coincidido con el patrón
                 $contact = $response['contacts']->first();
             } else {
                 $contact = false;
             }
             // Acciones a realizar
             // 1 = nada
             // 2 = borrar contacto y mensaje
             // 3 = unsuscribe y borrar mensaje
             // 4 = borrar contacto
             // 5 = ususcribe contacto
             // 6 = borrar mensaje
             if ($contact != false && ($response['pattern']->action_049 == 2 || $response['pattern']->action_049 == 4)) {
                 // borrar contacto
                 Contact::where('id_041', $contact->id_041)->delete();
             }
             if ($contact != false && ($response['pattern']->action_049 == 3 || $response['pattern']->action_049 == 5)) {
                 // unsuscribe contacto
                 Contact::where('id_041', $contact->id_041)->update(['unsubscribe_email_041' => true]);
             }
             if ($response['pattern']->action_049 == 2 || $response['pattern']->action_049 == 3 || $response['pattern']->action_049 == 6) {
                 // borrar mensaje
                 $message->delete();
                 // retrasamos medio segundo la ejecución para no saturar el servidor IMAP de peticiones
                 usleep(500000);
             }
         }
         // si es la última interacción
         if ($key === count($messages) - 1) {
             // purge all delete messages
             $imapService->getServer()->expunge();
             // actualizamos el último UID comprobado
             EmailAccount::where('id_013', $account->id_013)->update(['last_check_uid_013' => $message->getUid()]);
         }
     }
 }
예제 #10
0
 public function editCustomRecord($parameters)
 {
     $parameters['emails'] = EmailAccount::all();
     $parameters['forwards'] = json_encode($parameters['object']->getForwards);
     return $parameters;
 }
예제 #11
0
 private function endTodo($todo)
 {
     // if has enDate, so user has finished tour todo_
     if ($todo->finished_091) {
         // 1 - project
         if ($todo->type_id_091 == 1) {
             // updates hour projects
             $project = Project::builder()->find($todo->project_id_091);
             Project::where('id_090', $todo->project_id_091)->update(['consumed_hours_090' => $project->consumed_hours_090 + $todo->hours_091, 'total_hours_090' => $project->total_hours_090 - $todo->hours_091]);
             History::create(['user_id_093' => $todo->user_id_091, 'user_name_093' => $todo->user_name_091, 'type_id_093' => $todo->type_id_091, 'project_id_093' => $todo->project_id_091, 'customer_id_093' => $todo->customer_id_091, 'customer_name_093' => $todo->customer_name_091, 'title_093' => $todo->title_091, 'description_093' => $todo->description_091, 'price_093' => $todo->price_091, 'request_date_093' => $todo->request_date_091, 'request_date_text_093' => $todo->request_date_text_091, 'end_date_093' => $todo->end_date_091, 'end_date_text_093' => $todo->end_date_text_091, 'hours_093' => $todo->hours_091]);
             // delete todo_, after register history
             Todo::destroy($todo->id_091);
         } elseif ($todo->type_id_091 == 2) {
             $billing = Billing::create(['todo_id_092' => $todo->id_091, 'user_id_092' => $todo->user_id_091, 'user_name_092' => $todo->user_name_091, 'customer_id_092' => $todo->customer_id_091, 'customer_name_092' => $todo->customer_name_091, 'title_092' => $todo->title_091, 'description_092' => $todo->description_091, 'request_date_092' => $todo->request_date_091, 'request_date_text_092' => $todo->request_date_text_091, 'end_date_092' => $todo->end_date_091, 'end_date_text_092' => $todo->end_date_text_091, 'hours_092' => $todo->hours_091, 'price_092' => $todo->price_091]);
             // envío de notificación
             $notificationsAccount = Preference::getValue('projectsNotificationsAccount', 6);
             $emailAccount = EmailAccount::find($notificationsAccount->value_018);
             if ($emailAccount == null) {
                 return null;
             }
             config(['mail.host' => $emailAccount->outgoing_server_013]);
             config(['mail.port' => $emailAccount->outgoing_port_013]);
             config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
             config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
             config(['mail.username' => $emailAccount->outgoing_user_013]);
             config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
             $users = User::builder()->where('profile_id_010', (int) Preference::getValue('projectsBillingProfile', 6)->value_018)->where('access_010', true)->get();
             $nameTo = '';
             foreach ($users as $key => $user) {
                 $nameTo .= $user->name_010 . ' ' . $user->surname_010;
                 if ($key < count($users) - 1) {
                     $nameTo .= ', ';
                 }
             }
             $dataMessage = ['nameTo' => $nameTo, 'users' => $users, 'subject' => 'Notificación de facturación de tarea', 'billing' => $billing];
             Mail::send('projects::emails.billing_notification', $dataMessage, function ($m) use($dataMessage) {
                 $m->subject($dataMessage['subject']);
                 foreach ($dataMessage['users'] as $user) {
                     $m->to($user->email_010, $user->name_010 . ' ' . $user->surname_010);
                 }
             });
         }
     }
 }