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;
 }
 public function run()
 {
     State::insert([['id_400' => '1', 'name_400' => 'Unmanaged', 'color_400' => '#ff0000'], ['id_400' => '2', 'name_400' => 'Managed', 'color_400' => '#53d450']]);
 }
Beispiel #3
0
 public function updateCustomRecord($parameters)
 {
     State::where('id_400', $parameters['id'])->update(['name_400' => $this->request->input('name'), 'color_400' => $this->request->input('color')]);
 }
Beispiel #4
0
 /**
  *  Change state record
  *
  * @access	public
  * @return  json
  */
 public function jsonSetStateRecordForm()
 {
     $record = Record::find($this->request->input('record'));
     $record->data_403 = json_decode($record->data_403);
     $form = $record->getForm;
     $oldState = $record->getState;
     $state = State::find($this->request->input('value'));
     $names = [];
     $usersEmails = [];
     Record::where('id_403', $this->request->input('record'))->update(['state_id_403' => $this->request->input('value')]);
     // check new recipients
     Miscellaneous::checkRecipients($record, $form);
     // get recipients emails to compare with new user email
     $recipients = Recipient::where('record_id_406', $this->request->input('record'))->where('states_406', true)->get();
     // set recipients
     foreach ($recipients as $recipient) {
         $names[] = $recipient->name_406;
         $usersEmails[] = $recipient->email_406;
     }
     // get users with the emails recipients
     $users = User::whereIn('email_010', $usersEmails)->get();
     foreach ($recipients as $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' => 'state', '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_change_state', '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.state', 'text_template_405' => 'forms::emails.text_state', 'data_message_405' => json_encode(['name_form_405' => $form->name_401, 'name_old_state_405' => $oldState->name_400, 'color_old_state_405' => $oldState->color_400, '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($record->toArray())];
     }
     if (count($messages) > 0) {
         Message::insert($messages);
     }
     $response = ['success' => true, 'record' => $this->request->input('record'), 'value' => $this->request->input('value')];
     return response()->json($response);
 }