Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 public static function getMailings($take, $skip)
 {
     $now = date('U');
     // fecha que hasta pasada la misma no se podría enviar emails
     $limitDate = $now - Preference::getValue('emailServiceIntervalShipping', 5)->value_018 * 24 * 60 * 60;
     return EmailSendQueue::builder()->select('id_047', 'campaign_id_047', 'contact_id_047', 'sorting_047', 'create_047', 'reply_to_013', 'email_041', 'header_044', 'body_044', 'footer_044', 'text_044', 'subject_044', 'id_041', 'company_041', 'name_041', 'surname_041', 'birth_date_041', 'id_044', 'outgoing_server_013', 'outgoing_port_013', 'email_013', 'name_013', 'outgoing_secure_013', 'outgoing_user_013', 'outgoing_pass_013')->join('001_013_email_account', '005_044_email_campaign.email_account_id_044', '=', '001_013_email_account.id_013')->where('status_id_047', '=', 0)->whereNotIn('contact_id_047', function ($query) use($limitDate) {
         $query->select('contact_id_048')->from('005_048_email_send_history')->where('sent_048', '>', $limitDate)->get();
     })->groupBy('contact_id_047', 'id_047', 'campaign_id_047', 'sorting_047', 'create_047', 'reply_to_013', 'email_041', 'header_044', 'body_044', 'footer_044', 'text_044', 'subject_044', 'id_041', 'company_041', 'name_041', 'surname_041', 'birth_date_041', 'id_044', 'outgoing_server_013', 'outgoing_port_013', 'email_013', 'name_013', 'outgoing_secure_013', 'outgoing_user_013', 'outgoing_pass_013')->take($take)->skip($skip)->orderBy('sorting_047', 'asc')->get();
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 public static function checkVouchersToCreate()
 {
     $voucherTasks = VoucherTask::builder()->get();
     if (count($voucherTasks) > 0) {
         // block enter to routine just finish this loop
         $bookingVouchersBulkCreate = Preference::getValue('bookingVouchersBulkCreate', 11, '0');
         // Comprobación para casos de errores o caídas del servidor, y no dejen bloquedo el envío de emails a la cola de proceso
         // si en 10 minutos no se ha liberado la variable, damos por hecho que se ha bloqueado y la liberamos
         $update = \DateTime::createFromFormat('Y-m-d H:i:s', $bookingVouchersBulkCreate->updated_at);
         if ($bookingVouchersBulkCreate->value_018 == '1' && date('U') - $update->getTimestamp() > 600) {
             Preference::setValue('emailServiceSendingEmailsToQueue', 11, '0');
         }
         // en el caso que el estado de envio esté activo, eso siginifica que hay una petición trabajando y enviando
         // a la tabla de cola de envíos los contactos, cuando termine de hacerlo cambiaremos el estado de envío de emails
         // para poder aceptar más peticiones, de esa manera nos aseguramos que no hayan
         // varias peticiones concurrentes insertando mails.
         if ($bookingVouchersBulkCreate->value_018 == '1') {
             exit;
         } else {
             Preference::setValue('bookingVouchersBulkCreate', 11, '1');
         }
         $limitVouchers = (int) Preference::getValue('bookingNVouchersToCreate', 11)->value_018;
         $voucherTask = $voucherTasks->first();
         // set limit to create vouchers
         if ($voucherTask->vouchers_to_create_227 <= $limitVouchers) {
             $limit = $voucherTask->vouchers_to_create_227;
         } else {
             $limit = $limitVouchers;
         }
         $voucher = Voucher::builder()->find($voucherTask->voucher_id_227);
         $vouchers = [];
         for ($i = 0; $i < $limit; $i++) {
             $vouchers[] = ['date_226' => $voucher->date_226, 'date_text_226' => $voucher->date_text_226, 'code_prefix_226' => $voucher->code_prefix_226, 'campaign_id_226' => $voucher->campaign_id_226, 'customer_id_226' => $voucher->customer_id_226, 'customer_name_226' => $voucher->customer_name_226, 'bearer_226' => $voucher->bearer_226, 'invoice_id_226' => $voucher->invoice_id_226, 'invoice_code_226' => $voucher->invoice_code_226, 'invoice_customer_id_226' => $voucher->invoice_customer_id_226, 'invoice_customer_name_226' => $voucher->invoice_customer_name_226, 'product_id_226' => $voucher->product_id_226, 'name_226' => $voucher->name_226, 'description_226' => $voucher->description_226, 'price_226' => $voucher->price_226, 'expire_date_226' => $voucher->expire_date_226, 'expire_date_text_226' => $voucher->expire_date_text_226, 'active_226' => $voucher->active_226];
         }
         // insert n vouchers
         Voucher::insert($vouchers);
         if ($voucherTask->vouchers_to_create_227 <= $limitVouchers) {
             // get user to send email
             $user = $voucherTask->getUser;
             // destroy task
             VoucherTask::destroy($voucherTask->id_227);
             // send email to user
             $dataMessage = ['emailTo' => $user->email_010, 'nameTo' => $user->name_010 . ' ' . $user->surname_010, 'subject' => trans('booking::pulsar.bulk_vouchers_create', ['totalVouchers' => $voucherTask->total_vouchers_227, 'id' => $voucherTask->id_227]), 'totalVouchers' => $voucherTask->total_vouchers_227, 'voucher' => $voucher];
             Mail::send('booking::emails.bulk_vouchers_notification', $dataMessage, function ($m) use($dataMessage) {
                 $m->to($dataMessage['emailTo'], $dataMessage['nameTo'])->subject($dataMessage['subject']);
             });
         } else {
             VoucherTask::where('id_227', $voucherTask->id_227)->update(['vouchers_to_create_227' => $voucherTask->vouchers_to_create_227 - $limit]);
         }
         // unblock loop
         Preference::setValue('bookingVouchersBulkCreate', 11, '0');
     }
 }
Ejemplo n.º 6
0
 public function customIndex($parameters)
 {
     $parameters['intervalsShipping'] = [];
     for ($i = 0; $i < 121; $i++) {
         $parameters['intervalsShipping'][] = (object) ['id' => $i, 'name' => str_pad($i, 2, '0', STR_PAD_LEFT)];
     }
     $parameters['intervalShipping'] = Preference::getValue('emailServiceIntervalShipping', 5);
     $parameters['groups'] = Group::all();
     $parameters['testGroup'] = Preference::getValue('emailServiceTestGroup', 5);
     $parameters['intervalsProcess'] = [(object) ['id' => 100, 'name' => 100], (object) ['id' => 500, 'name' => 500], (object) ['id' => 1000, 'name' => 1000], (object) ['id' => 5000, 'name' => 5000], (object) ['id' => 10000, 'name' => 10000], (object) ['id' => 20000, 'name' => 20000], (object) ['id' => 30000, 'name' => 30000], (object) ['id' => 40000, 'name' => 40000], (object) ['id' => 50000, 'name' => 50000]];
     $parameters['intervalProcess'] = Preference::getValue('emailServiceIntervalProcess', 5);
     return $parameters;
 }
Ejemplo n.º 7
0
 public function invoiceRecord()
 {
     // get parameters from url route
     $parameters = $this->request->route()->parameters();
     // get billing object
     $billing = Billing::builder()->find($parameters['id']);
     if (empty($billing->price_091)) {
         $price = (double) Preference::getValue('projectsHourPrice', 6)->value_018 * $billing->hours_091;
     } else {
         $price = $billing->price_091;
     }
     $history = History::create(['user_id_093' => $billing->user_id_091, 'user_name_093' => $billing->user_name_091, 'type_id_093' => $billing->type_id_091, 'project_id_093' => null, 'customer_id_093' => $billing->customer_id_091, 'customer_name_093' => $billing->customer_name_091, 'title_093' => $billing->title_091, 'description_093' => $billing->description_091, 'price_093' => $price, 'request_date_093' => $billing->request_date_091, 'request_date_text_093' => $billing->request_date_text_091, 'end_date_093' => $billing->end_date_091, 'end_date_text_093' => $billing->end_date_text_091, 'hours_093' => $billing->hours_091]);
     // create invoiced from todo_
     Invoiced::create(['date_094' => date('U'), 'date_text_094' => date(config('pulsar.datePattern')), 'customer_id_094' => $billing->customer_id_091, 'customer_name_094' => $billing->customer_name_091, 'type_id_094' => $billing->type_id_091, 'project_id_094' => null, 'history_id_094' => $history->id_093, 'price_094' => $price]);
     // destroy billing
     Billing::destroy($billing->id_092);
     // destroy todo_ from user section
     Todo::destroy($billing->todo_id_092);
     return redirect()->route('projectsBilling', ['offset' => $parameters['offset']])->with(['msg' => 1, 'txtMsg' => trans('projects::pulsar.message_successfully_invoiced')]);
 }
Ejemplo n.º 8
0
 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')]);
     }
 }
Ejemplo n.º 9
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);
         }
     });
 }
Ejemplo n.º 10
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']);
     });
 }
Ejemplo n.º 11
0
 /**
  *  Función que compruba si hay emails en las cuentas de correo que no hayan sido comprobados
  */
 public static function checkBouncedEmailsAccounts()
 {
     $emailStatusBouncedMessagesFromAccount = Preference::getValue('emailStatusBouncedMessagesFromAccount', 5, '0');
     // Comprobación para casos de errores o caídas del servidor, y no dejen bloquedo la comprobación de emails
     // si en 5 minutos no se ha liberado la variable, damos por hecho que se ha bloqueado y la liberamos
     $update = \DateTime::createFromFormat('Y-m-d H:i:s', $emailStatusBouncedMessagesFromAccount->updated_at);
     if ($emailStatusBouncedMessagesFromAccount->value_018 == '1' && date('U') - $update->getTimestamp() > 300) {
         Preference::setValue('emailStatusBouncedMessagesFromAccount', 5, '0');
     }
     // en el caso que el estado de envio esté activo, eso siginifica que hay una petición trabajando
     // cuando termine de hacerlo cambiaremos el estado de de comprobación de correos
     // para poder aceptar más peticiones, de esa manera nos aseguramos que no hayan
     // varias peticiones concurrentes comprobando mails.
     if ($emailStatusBouncedMessagesFromAccount->value_018 === '1') {
         //            todo, si devuelvo un json, al ejecutar el cron manualmente, no da ningún error, habría que filtrarlo
         //            return response()->json([
         //                'success'   => false,
         //                'message'   => 'at this moment, there is a process running'
         //            ]);
         exit;
     } else {
         Preference::setValue('emailStatusBouncedMessagesFromAccount', 5, '1');
     }
     // una vez comprobado que no hay mas procesos en ejecución, comenzamos a trabajar
     $accounts = EmailAccount::all();
     $patterns = EmailPattern::all();
     foreach ($accounts as $account) {
         $imapService = new ImapServices(['host' => $account->incoming_server_013, 'port' => $account->incoming_port_013, 'user' => $account->incoming_user_013, 'password' => Crypt::decrypt($account->incoming_pass_013), 'ssl' => $account->incoming_secure_013 == 'ssl' ? true : false]);
         // get total messages
         $nEmails = $imapService->getServer()->numMessages();
         // update n emails on account
         EmailAccount::builder()->where('id_013', $account->id_013)->update(['n_emails_013' => $nEmails]);
         // Get the last UID from email account
         if ($nEmails > 0) {
             $lastUidMessage = $imapService->getServer()->getUidByPositon($nEmails);
             // If the UID is grater than last UID manage, has to check account queue
             if ($lastUidMessage > $account->last_check_uid_013) {
                 //obtenemos la posición del siguiente mensaje sin chequear
                 $lastUidCheck = $account->last_check_uid_013;
                 $position = 0;
                 $i = 0;
                 // cuando obtengamos la posición del mensaje, será mayor que 0 y saldrá del bucle
                 // y si hemos hecho tantas o mas comprobaciones como emails hay, salimos del bucle
                 // sentencia para asegurarnos que no entramos en bucle infinito
                 while ($position < 1 && $i < $nEmails) {
                     // intentamos averiguar la posición del siguiente mensaje al último comprobado
                     $lastUidCheck++;
                     // si este UID no existe devolverá posición 0
                     $position = $imapService->getServer()->getPositonByUid($lastUidCheck);
                     // sumamos una vuelta para no entrar en bucle infinito
                     $i++;
                 }
                 // llamamos a la funcion que compruebe los correos es esa cuenta
                 Cron::checkBouncedMessagesFromAccount($imapService, $account, $patterns, $position - 1);
                 // solo comprobamo una cuenta
                 //break;
             }
         }
         // after check bounced messages or if there are not emails, close IMAP connection
         $imapService->getServer()->close();
         // if is the last email account, we freed the proccess
         if ($accounts->last()->id_013 == $account->id_013) {
             Preference::setValue('emailStatusBouncedMessagesFromAccount', 5, '0');
         }
     }
 }
Ejemplo n.º 12
0
 public function customIndex($parameters)
 {
     $parameters['nVouchersToCreate'] = Preference::getValue('bookingNVouchersToCreate', 11);
     return $parameters;
 }
Ejemplo n.º 13
0
 /**
  *  Function to record a data form
  *
  * @access	public
  * @return  json | \Illuminate\Http\RedirectResponse
  */
 public function recordForm()
 {
     $fields = json_decode($this->request->input('_fields'));
     $form = Form::find(Crypt::decrypt($this->request->input('_tokenForm')));
     $forwards = $form->getForwards;
     $recipients = [];
     $names = [];
     $messages = [];
     $recordDate = date('U');
     // test that, there are any form
     if ($form == null) {
         $response = ['success' => false, 'message' => "Form don't exist"];
         return response()->json($response);
     }
     $data = [];
     foreach ($fields->data as $field) {
         $obj = ['type' => $field->type, 'name' => $field->name, 'value' => $this->request->input($field->name)];
         if (isset($field->length)) {
             $obj['length'] = $field->length;
         }
         if (isset($field->label)) {
             $obj['label'] = $field->label;
         }
         $data[] = $obj;
     }
     $defaultState = Preference::getValue('formsDefaultState', 4);
     $dataRecord = ['form_id_403' => $form->id_401, 'date_403' => $recordDate, 'date_text_403' => date(config('pulsar.datePattern'), $recordDate), 'state_id_403' => $defaultState->value_018, 'subject_403' => $this->request->input($fields->subject, null), 'name_403' => $this->request->input($fields->name, null), 'surname_403' => $this->request->input($fields->surname, null), 'company_403' => $this->request->input($fields->company, null), 'email_403' => $this->request->input($fields->email, null), 'data_403' => json_encode($data)];
     $record = Record::create($dataRecord);
     $state = $record->getState;
     // set data with array with decode information to make $dataRecord for message
     $dataRecord['data_403'] = $data;
     // set ID record
     $dataRecord['id_403'] = $record->id_403;
     // set records unopened
     $form->n_unopened_401 = Record::where('form_id_403', $form->id_401)->where('opened_403', false)->count();
     $form->save();
     foreach ($forwards as $forward) {
         // set recipients from forwards to sow in the email message
         $names[] = $forward->name_402;
         $recipients[] = ['record_id_406' => $record->id_403, 'forward_406' => true, 'name_406' => $forward->name_402, 'email_406' => $forward->email_402, 'comments_406' => $forward->comments_402, 'states_406' => $forward->states_402];
     }
     if (count($recipients) > 0) {
         Recipient::insert($recipients);
     }
     // get recipient emails to compare with new user email
     $recipients = $record->getRecipients;
     foreach ($recipients as $recipient) {
         // get user and permissions
         $user = User::where('email_010', $recipient->email_406)->first();
         if ($user != null) {
             $userAcl = AclLibrary::getProfileAcl($user->profile_id_010);
         }
         $messages[] = ['type_id_405' => 'record', 'record_id_405' => $record->id_403, 'date_405' => date('U'), 'recipient_id_405' => $recipient->id_406, 'forward_405' => true, 'subject_405' => 'forms::pulsar.subject_email_record', 'name_405' => $recipient->name_406, 'email_405' => $recipient->email_406, 'form_id_405' => $form->id_401, 'user_id_405' => $user == null ? null : $user->id_010, 'template_405' => 'forms::emails.record', 'text_template_405' => 'forms::emails.text_record', 'data_message_405' => json_encode(['name_form_405' => $form->name_401, 'name_state_405' => $state->name_400, 'color_state_405' => $state->color_400, 'names_405' => implode(", ", $names), 'permission_state_405' => $user == null ? false : $userAcl->allows('forms-record', 'edit', $user->profile_id_010), 'permission_comment_405' => $user == null ? false : $userAcl->allows('forms-comment', 'create', $user->profile_id_010), 'permission_forward_405' => $user == null ? false : $userAcl->allows('forms-form', 'edit', $user->profile_id_010), 'permission_record_405' => $user == null ? false : $userAcl->allows('forms-record', 'show', $user->profile_id_010)]), 'data_405' => json_encode($dataRecord)];
     }
     if (count($messages) > 0) {
         Message::insert($messages);
     }
     if ($this->request->input('_redirectOk') == '') {
         $response = ['success' => true, 'form' => ['date_403' => $recordDate, 'date_text_403' => date(config('pulsar.datePattern'), $recordDate), 'subject_403' => $this->request->input($fields->subject, null), 'state_id_403' => $defaultState->value_018, 'name_403' => $this->request->input($fields->name, null), 'surname_403' => $this->request->input($fields->surname, null), 'company_403' => $this->request->input($fields->company, null), 'email_403' => $this->request->input($fields->email, null), 'data_403' => json_encode($data)]];
         return response()->json($response);
     } else {
         return redirect($this->request->input('_redirectOk'));
     }
 }
Ejemplo n.º 14
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);
                 }
             });
         }
     }
 }