OC v3.х Конструктор форм обратной связи

  • Автор темы Автор темы Astronaut
  • Дата начала Дата начала

Astronaut

Разрушитель (V)
Сообщения
431
Реакции
167
Баллы
861
Возможно уже есть. Не нашел
Перебрал несколько конструкторов. Этот модуль самый приличный, простой и рабочий

Возможные типы полей
  • Список
  • Переключатель
  • Флажок
  • Текст
  • Текстовая область
  • Файл
  • Дата
  • Время
  • Дата & Время
Гибкая настройка внешнего вида формы
  • Возможен вывод в модальном окне или в схемах/макетах сайта
  • Выбор количества колонок (1 - 4)
  • Установка любого плейсхолдера для полей
  • Установка заголовков кнопки отправки, формы, полей
  • И многое другое
Возможности модуля
  • Создавать формы с произвольными полями
  • Отправлять данные формы на один или несколько почтовых адресов
  • При отправке данных форм указывается страница, с которой была отправка
  • Перенаправлять пользователя на любую страницу после отправки или не перенаправлять. Решать Вам
  • Произвольное время ожидания перед закрытием окна (в случае использования всплывающего окна)
  • Использование Google reCaptcha (только для версий cms 2.1, 2.2, 2.3)
  • Проверка заполненности полей с помощью regEx
Screenshot_2.png



Скрытое содержимое. Вам нужно войти или зарегистрироваться.
 
Странно, то есть разрабы придумали reCaptcha (только для версий cms 2.1, 2.2, 2.3), а для тройки терпеть спам? А в модуле есть возможность вывода в шаблоне?
 
А для версий cms 2.3 есть данный модуль ?
 
Привет всем. Нужна доработка этого модуля
Надо при формировании заявки что бы модуль формировал файл JSON из собранных данных и отправлял его по указанному адресу
в форме будут текстовые данные фио, адрес, телефон и прочее. И будут прикреплены сканы/фото, которые надо тоже кодировать передавать в этом json
Напишите в личку кто может


зы разобрался. может кому пригодится
при изменении остается отправка письма и всех вложений и + добавляется формирование файла json в кодировке base64 в папке upload/1C_upload
Зачем ? для приема этого файла в 1С или в другой программе и автоматического создания карточки клиента или любого другого документа уже с данными которые можно добавить из любых созданных полей и прикрепить файлы/сканы

public function mail() {
$this->load->language('extension/module/form2304');
$this->load->model('setting/module');
$settings = $this->model_setting_module->getModule($this->request->post['code']);

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate($settings)) {
$recivers = explode(',', $settings['recivers']);

$this->load->model('account/custom_field');
$custom_fields = $this->getCustomFields($settings);

$text = '';
$attachments = [];
$json_data = []; // Массив для данных, которые попадут в JSON

foreach ($custom_fields as $custom_field) {
if (!empty($this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']])) {
$text .= $custom_field['name'] . ": ";

if ($custom_field['type'] == 'select') {
foreach ($custom_field['custom_field_value'] as $custom_field_value) {
if ($custom_field_value['custom_field_value_id'] == $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']]) {
$text .= $custom_field_value['name'] . "\n";
}
}
}

if ($custom_field['type'] == 'radio') {
foreach ($custom_field['custom_field_value'] as $custom_field_value) {
if ($custom_field_value['custom_field_value_id'] == $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']]) {
$text .= $custom_field_value['name'] . "\n";
}
}
}

$cb_text = '';
if ($custom_field['type'] == 'checkbox') {
foreach ($custom_field['custom_field_value'] as $custom_field_value) {
if (in_array($custom_field_value['custom_field_value_id'], $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']])) {
$cb_text .= ($cb_text == '' ? '' : '; ') . $custom_field_value['name'];
}
}
}
$text .= ($cb_text == '' ? '' : $cb_text . "\n");

if ($custom_field['type'] == 'text') {
$text .= $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']] . "\n";
}

if ($custom_field['type'] == 'textarea') {
$text .= $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']] . "\n";
}

if ($custom_field['type'] == 'file') {
$this->load->model('tool/upload');
$upload_info = $this->model_tool_upload->getUploadByCode($this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']]);

if (file_exists(DIR_UPLOAD . $upload_info['filename'])) {
// Формируем новое имя файла по шаблону: исходное_имя.md5_хеш
$file_hash = md5_file(DIR_UPLOAD . $upload_info['filename']);
$new_filename = $upload_info['name'] . '.' . $file_hash;

// Переименовываем файл
rename(DIR_UPLOAD . $upload_info['filename'], DIR_UPLOAD . $new_filename);

// Сохраняем путь к файлу для вложения в письмо
$attachments[] = DIR_UPLOAD . $new_filename;

// Добавляем информацию о файле в текст письма
$text .= $new_filename . "\n";

// Сохраняем данные о файле для JSON
$json_data['files'][] = [
'original_name' => $upload_info['name'],
'stored_name' => $new_filename,
'path' => DIR_UPLOAD . $new_filename,
'size' => filesize(DIR_UPLOAD . $new_filename),
'mime' => mime_content_type(DIR_UPLOAD . $new_filename)
];
}
}

if ($custom_field['type'] == 'date') {
$text .= $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']] . "\n";
}

if ($custom_field['type'] == 'time') {
$text .= $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']] . "\n";
}

if ($custom_field['type'] == 'datetime') {
$text .= $this->request->post['custom_field'][$this->request->post['code']][$custom_field['custom_field_id']] . "\n";
}

$text .= "\n";
}
}

$text .= $this->language->get('post_page') . ": " . htmlspecialchars_decode($this->request->post['post_page']);

// Добавляем общие данные в JSON
$json_data['post_page'] = $this->request->post['post_page'];
$json_data['timestamp'] = date('Y-m-d H:i:s');

// Сохраняем JSON-файл
$json_filename = 'form_submission_' . time() . '_' . md5(serialize($json_data)) . '.json';
file_put_contents(DIR_STORAGE . 'json/' . $json_filename, json_encode($json_data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));

foreach ($recivers as $reciver) {
if ($reciver == '') {
continue;
}

$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');

$mail->setTo($reciver);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject(html_entity_decode($settings['name'], ENT_QUOTES, 'UTF-8'));
$mail->setText($text);

foreach ($attachments as $attach) {
$mail->addAttachment($attach);
}

$mail->send();
}

$json['success']['message'] = $settings['message'];
if ($settings['redirect']) {
$json['success']['redirect'] = $settings['redirect'];
}

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
} else {
$json['error'] = $this->error;
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
} // закрывающая скобка метода mail()
 
Последнее редактирование:
Назад
Верх