function saveYeuCauBDS() { global $mainframe; $userid = JRequest::getVar('customer', '0', 'POST'); $itemid = JRequest::getVar('item', '0', 'POST'); $email = JRequest::getVar('email', '', 'POST', 'string', JREQUEST_ALLOWRAW); $id = JRequest::getInt('id', ''); $dsat = U_ReModelProperties::getResultByEmai($email); if ($userid == 0 && $itemid != 247) { U_ReModelProperties::saveUser(); $userid = U_ReModelProperties::getIdUserByUserName(JRequest::getVar('username', '', 'POST', 'string')); } $query = str_replace(",", "", JRequest::getVar('sql', '', 'POST', 'string', JREQUEST_ALLOWRAW)); $tienich = JRequest::getVar('tienich', '', 'POST', 'string', JREQUEST_ALLOWRAW); $quanhuyen = JRequest::getVar('quanhuyen', '', 'POST', 'string', JREQUEST_ALLOWRAW); $query = htmlentities($query, ENT_QUOTES, "UTF-8"); $loai_giao_dich_id = JRequest::getVar('loai_giao_dich_id', '0', 'POST'); $loai_bds_id = JRequest::getVar('loai_bds_id', '0', 'POST'); $tinh_thanh_id = JRequest::getVar('tinh_thanh_id', '0', 'POST'); $duong_pho = JRequest::getVar('duong_pho', '0', 'POST'); $du_an_id = JRequest::getVar('du_an_id', '0', 'POST'); $dien_tich_san_tu = JRequest::getInt('dien_tich_san_tu', '0', 'POST'); $dien_tich_san_den = JRequest::getInt('dien_tich_san_den', '0', 'POST'); $dien_tich_su_dung_tu = JRequest::getInt('dien_tich_su_dung_tu', '0', 'POST'); $dien_tich_su_dung_den = JRequest::getInt('dien_tich_su_dung_den', '0', 'POST'); $phong_ngu_tu = JRequest::getInt('phong_ngu_tu', '0', 'POST'); $phong_ngu_den = JRequest::getInt('phong_ngu_den', '0', 'POST'); $phong_tam_tu = JRequest::getInt('phong_tam_tu', '0', 'POST'); $phong_tam_den = JRequest::getInt('phong_tam_den', '0', 'POST'); $muc_gia_tu = str_replace(",", "", JRequest::getVar('muc_gia_tu', '0', 'POST')); $muc_gia_den = str_replace(",", "", JRequest::getVar('muc_gia_den', '0', 'POST')); $so_tang_tu = JRequest::getInt('so_tang_tu', '0', 'POST'); $so_tang_den = JRequest::getInt('so_tang_den', '0', 'POST'); $chinh_chu = str_replace('on', '1', JRequest::getVar('chinh_chu', '0', 'POST')); $speak_english = str_replace('on', '1', JRequest::getVar('speak_english', '0', 'POST')); $nhan_mail = str_replace('on', '1', JRequest::getVar('nhan_mail', '0', 'POST')); $loai_gia_nc = JRequest::getVar('loai_gia_nc', '0', 'POST'); $huong_id = JRequest::getVar('huong_id', '0', 'POST'); $tinh_trang_noi_that = JRequest::getVar('tinh_trang_noi_that', '0', 'POST'); $date = time(); $db =& JFactory::getDBO(); if (JRequest::getVar('username', '', 'method', 'username') != '' && $itemid == 246) { $credentials = array(); $options = null; $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getVar('password', '', 'post', JREQUEST_ALLOWRAW); $mainframe->login($credentials, $options); unset($_SESSION['tmp']); $this->setRedirect('vi?option=com_u_re&view=manage&layout=yeucau&Itemid=242&msg=fail'); } if ($id) { $sql = "UPDATE jos_yeu_cau_bds SET\n\t\t\tquery='{$query}',ngay_dang='{$date}',tien_ich_id='{$tienich}',quan_huyen_id='{$quanhuyen}',loai_giao_dich_id='{$loai_giao_dich_id}',loai_bds_id='{$loai_bds_id}',\n\t\t\ttinh_thanh_id='{$tinh_thanh_id}',duong_pho='{$duong_pho}',du_an_id='{$du_an_id}',dien_tich_su_dung_tu='{$dien_tich_su_dung_tu}',dien_tich_su_dung_den='{$dien_tich_su_dung_den}',\n\t\t\tdien_tich_san_tu='{$dien_tich_san_tu}',dien_tich_san_den='{$dien_tich_san_den}',phong_ngu_tu='{$phong_ngu_tu}',phong_ngu_den='{$phong_ngu_den}',phong_tam_tu='{$phong_tam_tu}',\n\t\t\tphong_tam_den='{$phong_tam_den}',muc_gia_tu='{$muc_gia_tu}',muc_gia_den='{$muc_gia_den}',so_tang_tu='{$so_tang_tu}',so_tang_den='{$so_tang_den}',loai_gia_nc='{$loai_gia_nc}',\n\t\t\thuong_id='{$huong_id}',tinh_trang_noi_that='{$tinh_trang_noi_that}',speak_english='{$speak_english}',chinh_chu='{$chinh_chu}',email='{$email}',nhan_mail='{$nhan_mail}' WHERE email = '{$email}'"; } else { if ($itemid == 247 && $dsat) { $sql = "UPDATE jos_yeu_cau_bds SET\n\t\t\t\tquery='{$query}',ngay_dang='{$date}',tien_ich_id='{$tienich}',quan_huyen_id='{$quanhuyen}',loai_giao_dich_id='{$loai_giao_dich_id}',loai_bds_id='{$loai_bds_id}',\n\t\t\t\ttinh_thanh_id='{$tinh_thanh_id}',duong_pho='{$duong_pho}',du_an_id='{$du_an_id}',dien_tich_su_dung_tu='{$dien_tich_su_dung_tu}',dien_tich_su_dung_den='{$dien_tich_su_dung_den}',\n\t\t\t\tdien_tich_san_tu='{$dien_tich_san_tu}',dien_tich_san_den='{$dien_tich_san_den}',phong_ngu_tu='{$phong_ngu_tu}',phong_ngu_den='{$phong_ngu_den}',phong_tam_tu='{$phong_tam_tu}',\n\t\t\t\tphong_tam_den='{$phong_tam_den}',muc_gia_tu='{$muc_gia_tu}',muc_gia_den='{$muc_gia_den}',so_tang_tu='{$so_tang_tu}',so_tang_den='{$so_tang_den}',loai_gia_nc='{$loai_gia_nc}',\n\t\t\t\thuong_id='{$huong_id}',tinh_trang_noi_that='{$tinh_trang_noi_that}',speak_english='{$speak_english}',chinh_chu='{$chinh_chu}',nhan_mail='{$nhan_mail}' WHERE email = '{$email}'"; } elseif ($itemid == 242 && $dsat) { $sql = "UPDATE jos_yeu_cau_bds SET\n\t\t\t\tquery='{$query}',ngay_dang='{$date}',tien_ich_id='{$tienich}',quan_huyen_id='{$quanhuyen}',loai_giao_dich_id='{$loai_giao_dich_id}',loai_bds_id='{$loai_bds_id}',\n\t\t\t\ttinh_thanh_id='{$tinh_thanh_id}',duong_pho='{$duong_pho}',du_an_id='{$du_an_id}',dien_tich_su_dung_tu='{$dien_tich_su_dung_tu}',dien_tich_su_dung_den='{$dien_tich_su_dung_den}',\n\t\t\t\tdien_tich_san_tu='{$dien_tich_san_tu}',dien_tich_san_den='{$dien_tich_san_den}',phong_ngu_tu='{$phong_ngu_tu}',phong_ngu_den='{$phong_ngu_den}',phong_tam_tu='{$phong_tam_tu}',\n\t\t\t\tphong_tam_den='{$phong_tam_den}',muc_gia_tu='{$muc_gia_tu}',muc_gia_den='{$muc_gia_den}',so_tang_tu='{$so_tang_tu}',so_tang_den='{$so_tang_den}',loai_gia_nc='{$loai_gia_nc}',\n\t\t\t\thuong_id='{$huong_id}',tinh_trang_noi_that='{$tinh_trang_noi_that}',speak_english='{$speak_english}',chinh_chu='{$chinh_chu}',nhan_mail='{$nhan_mail}' WHERE email = '{$email}'"; } else { if ($userid == 0) { $user_id = U_ReModelProperties::layMaSoNonUser() + 1; $userid = 'NONUSER_' . $user_id; } $sql = "insert into jos_yeu_cau_bds (id,query,user_id,ngay_dang,tien_ich_id,quan_huyen_id,loai_giao_dich_id,loai_bds_id,tinh_thanh_id,duong_pho,du_an_id,dien_tich_su_dung_tu,dien_tich_su_dung_den,\n\t\t\t\tdien_tich_san_tu,dien_tich_san_den,phong_ngu_tu,phong_ngu_den,phong_tam_tu,phong_tam_den,muc_gia_tu,muc_gia_den,so_tang_tu,so_tang_den,loai_gia_nc,huong_id,tinh_trang_noi_that,speak_english,chinh_chu,email,nhan_mail) \n\t\t\t\tvalue ('{$userid}','{$query}','{$userid}','{$date}','{$tienich}','{$quanhuyen}','{$loai_giao_dich_id}','{$loai_bds_id}','{$tinh_thanh_id}','{$duong_pho}','{$du_an_id}','{$dien_tich_su_dung_tu}','{$dien_tich_su_dung_den}',\n\t\t\t\t'{$dien_tich_san_tu}','{$dien_tich_san_den}','{$phong_ngu_tu}','{$phong_ngu_den}','{$phong_tam_tu}','{$phong_tam_den}','{$muc_gia_tu}','{$muc_gia_den}','{$so_tang_tu}','{$so_tang_den}','{$loai_gia_nc}',\n\t\t\t\t'{$huong_id}','{$tinh_trang_noi_that}','{$speak_english}','{$chinh_chu}','{$email}','{$nhan_mail}')"; } } $db->setQuery($sql); if ($db->query()) { $userdn = JRequest::getVar('username', '', 'method', 'username'); $emaildn = JRequest::getVar('email', '', 'method', ''); if ($userdn !== '') { $username = $userdn; } else { $username = $emaildn; } $user = JFactory::getUser(); if ($itemid != 247) { if ($user->get('id') == 0) { $credentials = array(); $options = null; $credentials['username'] = $username; $credentials['password'] = JRequest::getVar('password', '', 'post', JREQUEST_ALLOWRAW); $mainframe->login($credentials, $options); unset($_SESSION['tmp']); } $this->setRedirect('vi?option=com_u_re&view=manage&layout=yeucau&Itemid=242&msg=success'); } else { unset($_SESSION['tmp']); $this->setRedirect('index.php?option=com_content&view=frontpage&Itemid=247&lang=vi&msg=success'); } $id = U_ReModelProperties::getIdResultByEmai($email); //gửi mail thông báo $unticklink = JURI::base() . 'vi?option=com_u_re&task=untickEmail&id=' . $id . '&email=' . $email . '&tokenuntick=' . time(); $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $name = JRequest::getVar('name', '', 'POST', 'string'); include_once 'libraries/com_u_re/php/config.php'; $art_id = U_ReConfig::getValueByKey('TEMPLATEEMAIL', 'tao_yeu_cau'); $sqlcontent = "SELECT introtext from jos_content where id = '{$art_id}'"; $db =& JFactory::getDBO(); $db->setQuery($sqlcontent); $rowcontent = $db->loadRow(); $noidung = $rowcontent[0]; $noidung = str_replace("%ten%", $name, $noidung); $noidung = str_replace("%link%", $unticklink, $noidung); $noidung = str_replace("images/", JURI::base() . "images/", $noidung); $subject = 'Tạo yêu cầu BĐS tại Mạng lưới Bất động sản'; //$body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $sitename, $token, $url); $body = $noidung; JUtility::sendMail($mailfrom, $fromname, $email, $subject, $body, $mod = 1); } else { if (JRequest::getVar('username', '', 'method', 'username') != '') { $credentials = array(); $options = null; $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getVar('password', '', 'post', JREQUEST_ALLOWRAW); $mainframe->login($credentials, $options); unset($_SESSION['tmp']); $this->setRedirect('vi?option=com_u_re&view=manage&layout=yeucau&Itemid=242&msg=fail'); } } //dang nhap }