コード例 #1
0
 public function showCustomRecord($parameters)
 {
     // todo: cambiar por listado de programadores
     $users = User::builder()->get();
     $parameters['users'] = $users->map(function ($user, $key) {
         $user->name = $user->name_010 . ' ' . $user->surname_010;
         return $user;
     });
     $parameters['afterButtonFooter'] = '<a id="invoiceButton" class="btn btn-danger margin-l10 delete-lang-record" href="' . route('invoiceProjectsBilling', ['id' => $parameters['id'], 'offset' => $parameters['offset']]) . '">' . trans('projects::pulsar.invoice_todo') . '</a>';
     return $parameters;
 }
コード例 #2
0
ファイル: CommentController.php プロジェクト: syscover/forms
 public function storeCustomRecord($parameters)
 {
     $record = Record::find($this->request->input('ref'));
     $record->data_403 = json_decode($record->data_403);
     $form = $record->getForm;
     $state = $record->getState;
     $names = [];
     $usersEmails = [];
     $messages = [];
     $comment = Comment::create(['record_id_404' => $this->request->input('ref'), 'user_id_404' => auth('pulsar')->user()->id_010, 'date_404' => date('U'), 'subject_404' => $this->request->input('subject'), 'comment_404' => $this->request->input('comment')]);
     // check new recipients
     Miscellaneous::checkRecipients($record, $form);
     // get recipient emails to compare with new user email
     $recipients = Recipient::where('record_id_406', $this->request->input('ref'))->where('comments_406', true)->get();
     // set recipients
     foreach ($recipients as $recipient) {
         if ($recipient->email_406 != auth('pulsar')->user()->email_010) {
             $names[] = $recipient->name_406;
             $usersEmails[] = $recipient->email_406;
         }
     }
     // get users with the emails recipients
     $users = User::whereIn('email_010', $usersEmails)->get();
     $matchAuthor = false;
     foreach ($recipients as $recipient) {
         if ($recipient->email_406 == auth('pulsar')->user()->email_010) {
             $matchAuthor = true;
         } else {
             // send to all recipients less Author recipient
             // get user and permissions
             $matchUser = null;
             foreach ($users as $user) {
                 if ($user->email_010 == $recipient->email_406) {
                     $matchUser = $user;
                     break;
                 }
             }
             if ($matchUser != null) {
                 $userAcl = AclLibrary::getProfileAcl($matchUser->profile_id_010);
             }
             $messages[] = ['type_id_405' => 'comment', 'record_id_405' => $record->id_403, 'date_405' => date('U'), 'recipient_id_405' => $recipient->id_406, 'forward_405' => $recipient->forward_406, 'subject_405' => 'forms::pulsar.subject_comment', 'name_405' => $recipient->name_406, 'email_405' => $recipient->email_406, 'form_id_405' => $form->id_401, 'user_id_405' => $matchUser == null ? null : $matchUser->id_010, 'template_405' => 'forms::emails.comment', 'text_template_405' => 'forms::emails.text_comment', 'data_message_405' => json_encode(['name_form_405' => $form->name_401, 'author_comment_405' => auth('pulsar')->user()->name_010 . ' ' . auth('pulsar')->user()->surname_010, 'date_comment_405' => date(config('pulsar.datePattern')), 'subject_comment_405' => $comment->subject_404, 'comment_405' => $comment->comment_404, 'name_state_405' => $state->name_400, 'color_state_405' => $state->color_400, 'names_405' => implode(", ", $names), 'permission_state_405' => $matchUser == null ? false : $userAcl->allows('forms-record', 'edit', $matchUser->profile_id_010), 'permission_comment_405' => $matchUser == null ? false : $userAcl->allows('forms-comment', 'create', $matchUser->profile_id_010), 'permission_forward_405' => $matchUser == null ? false : $userAcl->allows('forms-form', 'edit', $matchUser->profile_id_010), 'permission_record_405' => $matchUser == null ? false : $userAcl->allows('forms-record', 'show', $matchUser->profile_id_010)]), 'data_405' => json_encode($record->toArray())];
         }
     }
     if (!$matchAuthor) {
         // Include Author to recipients but not forward
         Recipient::create(['record_id_406' => $record->id_403, 'forward_406' => false, 'name_406' => auth('pulsar')->user()->name_010 . ' ' . auth('pulsar')->user()->surname_010, 'email_406' => auth('pulsar')->user()->email_010, 'comments_406' => true, 'states_406' => true]);
     }
     if (count($messages) > 0) {
         Message::insert($messages);
     }
     $parameters['redirectParentJs'] = true;
     return $parameters;
 }
コード例 #3
0
ファイル: UserController.php プロジェクト: syscover/pulsar
 public function updateCustomRecord($parameters)
 {
     $user = ['name_010' => $this->request->input('name'), 'surname_010' => $this->request->input('surname'), 'email_010' => $this->request->input('email'), 'lang_id_010' => $this->request->input('lang'), 'access_010' => $this->request->input('access', 0), 'profile_id_010' => $this->request->input('profile'), 'user_010' => $this->request->input('user')];
     if ($parameters['specialRules']['emailRule']) {
         $user['email_010'] = $this->request->input('email');
     }
     if ($parameters['specialRules']['userRule']) {
         $user['user_010'] = $this->request->input('user');
     }
     if (!$parameters['specialRules']['passRule']) {
         $user['password_010'] = Hash::make($this->request->input('password'));
     }
     User::where('id_010', $parameters['id'])->update($user);
 }
コード例 #4
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);
         }
     });
 }
コード例 #5
0
ファイル: OrderController.php プロジェクト: syscover/octopus
 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']);
     });
 }
コード例 #6
0
 public function run()
 {
     User::insert([['id_010' => 1, 'name_010' => 'Pulsar', 'surname_010' => 'Pulsar', 'lang_id_010' => 'en', 'email_010' => '*****@*****.**', 'profile_id_010' => '1', 'access_010' => '1', 'user_010' => '*****@*****.**', 'password_010' => '$2y$10$3eFZAd31wPmg2mMZB/CZ4.CkcZKY9xr7A3Z9ou6mp7OkSIc3Qo.yW', 'remember_token_010' => null, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")]]);
 }
コード例 #7
0
ファイル: RecordController.php プロジェクト: syscover/forms
 /**
  *  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'));
     }
 }
コード例 #8
0
 public function editCustomRecord($parameters)
 {
     // get resourse to know if set user, depend of view, todos or user todos
     $actions = $this->request->route()->getAction();
     $parameters['resource'] = $actions['resource'];
     if ($parameters['object']->type_id_093 == 2) {
         $response = FacturaDirecta::getClient($parameters['object']->customer_id_093);
         $collection = collect();
         // check that response does not contain httpStatus 404
         if (!isset($response['httpStatus'])) {
             // set id like integer, to compare in select
             $response['id'] = (int) $response['id'];
             $parameters['customers'] = $collection->push(Miscellaneous::arrayToObject($response));
         }
     }
     // types
     $parameters['types'] = array_map(function ($object) {
         $object->name = trans_choice($object->name, 1);
         return $object;
     }, config('projects.types'));
     // projects
     $parameters['projects'] = Project::builder()->where('end_date_090', '>', date('U'))->orWhereNull('end_date_090')->get();
     // todo: cambiar por listado de programadores
     $users = User::builder()->get();
     $parameters['users'] = $users->map(function ($user, $key) {
         $user->name = $user->name_010 . ' ' . $user->surname_010;
         return $user;
     });
     return $parameters;
 }
コード例 #9
0
ファイル: TodoController.php プロジェクト: syscover/projects
 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);
                 }
             });
         }
     }
 }