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();
     }
 }
示例#2
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')]);
     }
 }
示例#3
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);
         }
     });
 }
示例#4
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']);
     });
 }
示例#5
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);
                 }
             });
         }
     }
 }