function formgenerate() { //генерируем форму $page =& Registry::get('TPage'); $form = new TForm(array('action' => $page->content['href']), $this); $form->form_name = 'guestbook'; $form->elements = array('name' => array('name' => 'name', 'type' => 'text', 'req' => 1, 'atrib' => 'style="width: 100%; height: 20px;"'), 'message' => array('name' => 'message', 'type' => 'textarea', 'req' => 1, 'atrib' => 'style="width: 100%; height: 120px;"')); $fdata = $form->generate(); /* if (isset($_GET['ok'])||isset($_GET['fail'])) { $fdata['form']['result'] = isset($_GET['ok']) ? 'Успешно отправлено.' : (isset($_GET['fail']) ? 'Ошибка отправки.' : ''); $fdata['form']['show_result'] = 1; } */ /** * @var TRusoft_View $view */ $view =& Registry::get('TRusoft_View'); $view->assign(array('fdata' => $fdata)); $this->form = $view->render('form.html'); }
/** * Калькулятор примерной стоимости квартиры */ function showCalculator(&$params) { $house_type = sql_getRows('SELECT id, name FROM obj_housetypes WHERE 1 ORDER BY id, name ASC', true); $house_type['0'] = 'не выбрано'; $rooms = array('0' => 'не выбрано', '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => '5 и более'); $distance = array('0' => 'не выбрано', '1' => 'До 5 минут пешком', '2' => '5-10 минут пешком', '3' => '10-15 минут пешком', '4' => 'Более 15 минут пешком', '5' => 'До 5 минут транспортом', '6' => '5-10 минут транспортом', '7' => '10-15 минут транспортом и далее'); $storeys_number = array('0' => 'не выбрано', '1' => 'до 9 этажа', '2' => 'от 10 до 22 этажа', '3' => 'более 22'); $ret = array(); $page =& Registry::get('TPage'); $metro = sql_getRows('SELECT id, name FROM obj_locat_metrostations WHERE 1 ORDER BY id, name ASC', true); // $metro[0] = 'не выбрано'; //Читаем файл настроек chdir("./configs"); $filename = "settings.txt"; $handle = fopen($filename, 'r'); $contents = fread($handle, filesize($filename)); fclose($handle); chdir("../"); $settings = explode("##", $contents); //Массив обязательных полей $required = unserialize($settings[0]); $percent = unserialize($settings[1]); $form = new TForm(null, $this); $form->form_name = 'сalculator'; $form->elements = array('metro_id' => array('name' => 'metro_id', 'type' => 'select', 'options' => $metro, 'text' => 'Метро', 'req' => isset($required[1]) ? 1 : 0, 'atrib' => 'style="width: 100%"'), 'house_type' => array('name' => 'house_type', 'type' => 'select', 'options' => $house_type, 'text' => 'Тип дома', 'req' => isset($required[2]) ? 1 : 0, 'atrib' => 'style="width: 100%"'), 'rooms' => array('name' => 'rooms', 'type' => 'select', 'options' => $rooms, 'text' => 'Количество комнат', 'req' => isset($required[3]) ? 1 : 0, 'atrib' => 'style="width: 100%"'), 'storey' => array('name' => 'storey', 'type' => 'radio', 'text' => 'Этаж квартиры', 'options' => array('0' => 'Любой', '1' => 'Не крайний', '2' => 'Крайний'), 'value' => 0, 'req' => isset($required[4]) ? 1 : 0, 'onerror' => '{#msg_err_invalid_phone#}'), 'storeys_number' => array('name' => 'storeys_number', 'type' => 'select', 'options' => $storeys_number, 'text' => 'Этажность', 'req' => isset($required[5]) ? 1 : 0, 'atrib' => 'style="width: 100%"'), 'distance' => array('name' => 'distance', 'type' => 'select', 'options' => $distance, 'text' => 'Расстояние от метро', 'req' => isset($required[6]) ? 1 : 0, 'atrib' => 'style="width: 100%"'), 'total_area' => array('name' => 'total_area', 'type' => 'text', 'text' => 'Общая площадь кв.м.', 'req' => isset($required[7]) ? 1 : 0, 'onerror' => '{#msg_err_invalid_phone#}', 'atrib' => 'style="width: 100%" class="input_text"'), array('name' => 'button1', 'type' => 'submit', 'value' => $page->tpl->get_config_vars("calculate"), 'group' => 'system', 'atrib' => 'class="Button"'), array('name' => 'button2', 'type' => 'reset', 'value' => $page->tpl->get_config_vars("reset"), 'group' => 'system', 'atrib' => 'class="Button"')); $fdata = $form->generate(); $fdata['form']['action'] = $page->content['href'] . "#report"; $fdata['form']['width'] = '80%'; if (empty($fdata['form']['errors']) && isset($_POST['fld'])) { $fdata['form']['report'] = $this->calculate($percent); } $ret['fdata'] = $fdata; return $ret; }
/** * Шаг 1 - Спрашиваем способ пополнения счета и на какую сумму * * @param array $params * @return string */ function newBill_step1($params) { $page =& Registry::get('TPage'); $page->content['elem_text']['text'] = $page->tpl->get_config_vars('cabinet_createbill_step1'); $form = new TForm(null, $this); $form->form_name = 'cabinet'; $elements = array('method' => array('name' => 'method', 'type' => 'select', 'options' => $this->bill_methods, 'value' => 'Bank', 'group' => 'options'), 'client_type' => array('name' => 'client_type', 'type' => 'radio', 'display' => 'inline', 'options' => $this->client_types, 'value' => 'fiz', 'group' => 'options', 'atrib' => 'onclick="changeClientType(this.value)"'), 'sum' => array('name' => 'sum', 'type' => 'text', 'group' => 'options', 'req' => 1)); $auth_obj =& Registry::get('TUserAuth'); $client = $auth_obj->getCurrentUserData(); $client['email'] = $client['comp_email'] = $client['login']; if (!empty($client['bill_fio'])) { // Специальное ФИО для счетов $client['fio2'] = $client['fio'] = $client['bill_fio']; } else { $client['fio2'] = $client['fio'] = ''; } if (!empty($client['bill_phone'])) { // Специальный телефон для счетов $client['phone'] = $client['bill_phone']; } if (!empty($client['bill_comp_name'])) { // Специальная компания для счетов $client['comp_name'] = $client['bill_comp_name']; } foreach ($this->fields as $client_type => $fields) { foreach ($fields as $field) { $elements[$field] = array('name' => $field, 'type' => 'text', 'value' => isset($_POST['fld'][$field]) ? str_replace('"', '"', $_POST['fld'][$field]) : str_replace('"', '"', $client[$field]), 'group' => 'options_' . $client_type, 'req' => $client_type == 'fiz' ? 1 : (!in_array($field, array('fio2', 'comp_name', 'comp_kpp', 'comp_paddr', 'comp_phone', 'comp_fax')) ? 1 : 0), 'atrib' => 'style="width: 300px"'); } } $elements['button'] = array('name' => 'button', 'type' => 'submit', 'value' => 'Далее', 'group' => 'system'); $elements['act'] = array('name' => 'act', 'type' => 'hidden', 'group' => 'system', 'value' => 'step1'); $form->elements = $elements; $form->action = '/cabinet/bills/new_bill'; $client_type = isset($_POST['fld']['client_type']) ? is_array($_POST['fld']['client_type']) ? current($_POST['fld']['client_type']) : $_POST['fld']['client_type'] : 'fiz'; if (isset($_POST['fld'])) { foreach ($this->fields[$client_type == 'fiz' ? 'jur' : 'fiz'] as $field) { $form->elements[$field]['req'] = 0; } } $fdata = $form->generate(); $fdata['form']['width'] = '545'; $fdata['form']['script'] = "\n\t\t{literal}\n\t\t<script type='text/javascript'>\n\t\twindow.onload = function () {\n \t\tvar radios = document.forms['cabinet'].elements['fld[client_type][]'];\n \t\tfor (var i=0; i < radios.length; i++) {\n if (radios[i].checked) {\n changeClientType(radios[i].value);\n break;\n }\n \t\t}\n }\n\t\t</script>\n\t\t{/literal}\n\t\t"; if (isset($_POST['fld']) && empty($fdata['form']['errors'])) { $params['act'] = 'step3'; return $this->newBill_step3($params); } $page->tpl->assign(array('fdata' => $fdata)); $ret = $page->tpl->fetch('form.html'); return $ret; }
/** * Форма заявки * * @param array $info * @param bool $free * @return array */ function showOrder(&$info, $free = false) { global $settings; if (isset($_GET['a'])) { return $this->captcha(); } $ret = array(); $page =& Registry::get('TPage'); $form = new TForm(null, $this); $form->form_name = 'content'; $form->elements = array('name' => array('name' => 'name', 'type' => 'text', 'req' => 1, 'atrib' => 'class="text"'), 'contacts' => array('name' => 'contacts', 'type' => 'textarea', 'req' => 1, 'atrib' => 'style="height: 50px;" class="text"'), 'message' => array('name' => 'message', 'type' => 'textarea', 'text' => 'Дополнительная информация', 'req' => 0, 'atrib' => 'style="height: 120px;" class="text"'), 'captcha' => array('name' => 'captcha', 'type' => 'html', 'req' => 1, 'value' => ' <div class="floatLeft"> <label>{#content_fld_captcha#}<span>*</span>:</label> <input type="text" name="fld[captcha]" class="text" /><br /> <img src="' . $page->content['href'] . '?a=captcha" align="middle" title="Щелкните на картинце, чтобы загрузить другой код" onclick="document.getElementById(\'captcha\').src=\'' . $page->content['href'] . '?a=captcha&\'+1000*Math.random()" id="captcha"> </div>'), 'flat_id' => array('name' => 'flat_id', 'type' => 'hidden'), array('name' => 'button1', 'type' => 'html', 'value' => '<a class="button big left" href="javascript:void(0);" onclick="document.getElementById(\'addOrg\').submit(); return false;"><span>' . $page->tpl->get_config_vars("send") . '</span></a>', 'group' => 'system')); $fdata = $form->generate(); $path = $this->getPathToObject($info['id']) . '/object/' . $info['id'] . ($free ? '/free/' : '/order/'); $fdata['form']['action'] = $path; $fdata['form']['width'] = '80%'; $fdata['form']['id'] = "addOrg"; if (empty($fdata['form']['errors']) && isset($_POST['fld'])) { $keystring = $_SESSION['captcha_keystring']; unset($_SESSION['captcha_keystring']); if (!empty($_POST['fld']['captcha']) && (empty($keystring) || $_POST['fld']['captcha'] !== $keystring)) { $fdata['form']['result'] = 'msg_captcha_error'; // Ошибка при вводе проверочной комбинации } else { $name = e(h($_POST['fld']['name'])); $contacts = e(h($_POST['fld']['contacts'])); $message = e(h($_POST['fld']['message'])); $flat_id = isset($_POST['fld']['flat_id']) ? $_POST['fld']['flat_id'] : 0; // Сохраняем в БД $data = array('object_id' => $info['id'], 'flat_id' => $flat_id, 'date' => date('Y-m-d H:i:s'), 'name' => $name, 'contacts' => $contacts, 'info' => $message); sql_insert('orders', $data); // Отправка письма $mail =& new PHPMailer(); $admin_email = $page->tpl->get_config_vars('order_email'); $emails = explode(',', $admin_email); foreach ($emails as $k => $v) { $emails[$k] = trim($v); } $mail->From = $emails[0]; $mail->Sender = $emails[0]; $mail->Mailer = 'mail'; $mail->Subject = 'Заявка на просмотр объекта № ' . $info['lot_id']; $body = $text_body = ''; $body .= 'ФИО: ' . $name . '<br>'; $body .= 'Контакты: ' . nl2br($contacts) . '<br>'; $body .= 'Дополнительная информация: ' . nl2br($message) . '<br>'; $body .= '___________________________________________' . '<br>'; // Здесь полная информация об объекте $body .= 'Дата размещения объекта в базе: ' . $info['create_time'] . '<br>'; $body .= 'Регион: ' . ($info['moscow'] ? 'Москва' : 'Московская область') . '<br>'; $body .= 'Адрес: ' . $info['address'] . '<br>'; $body .= 'Квартира: ' . $settings['market'][$info['market']] . '<br>'; $body .= 'Цена всего (руб.): ' . $info['price_rub'] . '<br>'; $body .= 'Цена всего (у.е.): ' . $info['price_dollar'] . '<br>'; $body .= 'Количество комнат: ' . $info['room'] . '<br>'; $body .= 'Этаж: ' . $info['storey'] . '<br>'; $body .= 'Всего этажей: ' . $info['storeys_number'] . '<br>'; $body .= 'Тип здания: ' . sql_getValue('SELECT name FROM obj_housetypes WHERE id=' . $info['house_type']) . '<br>'; $body .= 'Общая площадь: ' . $info['total_area'] . '<br>'; $body .= 'Жилая площадь: ' . $info['living_area'] . '<br>'; $body .= 'Площадь кухни: ' . $info['kitchen_area'] . '<br>'; $body .= 'Вид и качество ремонта: ' . $info['remont'] . '<br>'; $body .= 'Телефон: ' . ($info['phone'] ? 'есть' : 'нет') . '<br>'; $body .= 'Санузел: ' . $settings['lavatory_types'][$info['lavatory']] . '<br>'; $body .= 'Балкон: ' . sql_getValue('SELECT name FROM obj_balcony WHERE id=' . $info['balcony']) . '<br>'; $body .= 'Окна: ' . $info['windows'] . '<br>'; $body .= 'Кто зарегистрирован: ' . $info['registration'] . '<br>'; $body .= 'Правоустанавливающие документы: ' . $info['documents'] . '<br>'; $body .= 'Физическое освобождение: ' . $info['f_release'] . '<br>'; $body .= 'Подробнее: ' . $info['short_description'] . '<br>'; $body .= 'Контактные данные: ' . $info['contact_phone'] . '<br>'; $body .= 'Рассрочка: ' . ($info['credit'] ? "да" : "нет") . '<br>'; $body .= 'Аванс: ' . ($info['avance'] ? "да" : "нет") . '<br>'; $body .= 'Ипотека: ' . ($info['ipoteka'] ? "да" : "нет") . '<br>'; $body .= 'Продано: ' . ($info['sell'] ? "да" : "нет") . '<br>'; /* if ($flat_id) { $row = sql_getRow('SELECT * FROM obj_elem_free WHERE id='.$flat_id); $body .= 'Квартира: <br>'; $body .= 'Кол-во комнат: '.$row['room'].'<br>'; $body .= 'Площадь: '.$row['total_area'].'/'.$row['living_area'].'/'.$row['kitchen_area'].'<br>'; $body .= 'Этаж: '.$row['storey'].'<br>'; $body .= 'Секция: '.$row['section'].'<br>'; $body .= 'Цена: '.$row['price'].' ('.$row['price_metr'].')<br>'; } */ $mail->Body = $body; $mail->AltBody = strip_tags(str_replace('<br>', "\r\n", $body)); foreach ($emails as $k => $v) { $mail->AddAddress($v); } $res = $mail->Send(); redirect($path . '?msg=' . ($res ? 'order_message' : 'msg_not_send_email')); } } $page->tpl->assign(array('fdata' => $fdata)); return $page->tpl->fetch('form.html'); }
function getChangePwdForm() { $page =& Registry::get('TPage'); $auth_obj =& Registry::get('TUserAuth'); $post = isset($_POST['fld']) ? $_POST['fld'] : array(); $user_id = $auth_obj->getCurrentUserId(); $profile = $auth_obj->getCurrentUserData(); $form = new TForm(null, $this); $form->form_name = 'registration'; $form->elements = array('password' => array('name' => 'password', 'type' => 'password', 'req' => 0, 'check' => '=confirm_password', 'onerror' => '{#msg_err_pwd_not_match#}', 'group' => 'private', 'atrib' => 'class="registration"'), 'confirm_password' => array('name' => 'confirm_password', 'type' => 'password', 'req' => 0, 'group' => 'private', 'atrib' => 'class="registration"'), array('name' => 'button1', 'type' => 'submit', 'group' => 'system', 'value' => 'Сохранить')); $fdata = $form->generate(); $fdata['form']['action'] = $page->content['href']; if (!empty($post) && empty($fdata['form']['errors'])) { if (get_magic_quotes_gpc()) { foreach ($post as $key => $value) { if (!is_array($value)) { $post[$key] = stripslashes($value); } } } foreach ($post as $key => $value) { if (!is_array($post[$key])) { $post[$key] = h($post[$key]); } } $str = ""; unset($post['confirm_password']); foreach ($post as $k => $v) { if ($k == 'password' && empty($v)) { continue; } if ($k == 'password') { $v = md5($v); } $str .= ", `" . $k . "`='" . e($v) . "' "; } $sql = "UPDATE auth_users SET " . substr($str, 1) . " WHERE id=" . $user_id; $r = sql_query($sql); if ($r !== true) { sql_query('ROLLBACK'); $msg = 'msg_fail'; } else { sql_query('COMMIT'); $msg = 'msg_update_success'; } redirect('/cabinet/change_password?msg=' . $msg); } $page->tpl->assign(array('fdata' => $fdata)); $ret = $page->tpl->fetch('form.html'); return $ret; }