diff --git a/api/index.php b/api/index.php index 61ccf54..fc63aeb 100644 --- a/api/index.php +++ b/api/index.php @@ -80,6 +80,16 @@ use Bitrix\Main\Context, Bitrix\Main\Loader, Bitrix\Iblock; +function checkRequestIsLocal() +{ + if(strpos($_SERVER['HTTP_X_FORWARDED_FOR'], SELF_IP) > -1) + { + return true; + } + + return false; +} + if($_SERVER['REMOTE_USER'] && strpos($_SERVER['REMOTE_USER'], "Bearer") > -1) { $token = str_replace("Bearer ", "", $_SERVER['REMOTE_USER']); @@ -281,7 +291,7 @@ switch($PARAM_1) "error" => "wrong_user_uri", "message" => "Empty user URI", ]); - + die(); } break; @@ -298,6 +308,9 @@ switch($PARAM_1) if(CModule::IncludeModule('iblock')) { $filter = [ "ACTIVE" => "Y", "IBLOCK_ID" => 1 ]; + + if(!empty($REQ['PROGRAM'])) { $filter['PROPERTY_LEASING_PROGRAMS'] = $REQ['PROGRAM']; } + if(!empty($REQ['BRAND_ID'])) { $filter["PROPERTY_BRAND"] = $REQ['BRAND_ID']; } if(!empty($REQ['MODEL_ID'])) { $filter["PROPERTY_MODEL"] = $REQ['MODEL_ID']; } if(!empty($REQ['MODIFICATION'])) { $filter["PROPERTY_MODIFICATION"] = $REQ['MODIFICATION']; } @@ -422,6 +435,7 @@ switch($PARAM_1) sort($ENGINE_POWER); sort($ENGINE_VOLUME); + sort($BODY); print json_encode([ "bodies" => $BODY, "gears" => $GEAR, @@ -530,22 +544,22 @@ switch($PARAM_1) $ipAddress = GeoIp\Manager::getRealIp(); $result = GeoIp\Manager::getDataResult($ipAddress, "ru"); - $REQ['FORM_FIELD_REGION'] = $result->getGeoData()->regionName.", ".$result->getGeoData()->cityName; + $_REQUEST['FORM_FIELD_REGION'] = $result->getGeoData()->regionName.", ".$result->getGeoData()->cityName; $error = ""; $arr = Array(); $form_errors = Array(); $arParams['request'] = $_REQUEST; $attach = false; - + $form_code = trim($_REQUEST['form']); - + $form = CForm::GetBySID($form_code); $form = $form->Fetch(); - + $formQuestions = Array(); $formAnswers = Array(); - + $sort = "s_sort"; $order = "asc"; $filtered = false; @@ -554,11 +568,11 @@ switch($PARAM_1) { $rsAnswers = CFormAnswer::GetList($arFormQuestion['ID'], $$sort, $$order, Array(), $$filtered); $arAnswer = $rsAnswers->Fetch(); - + $arFormQuestion['ANSWER'] = $arAnswer; $formQuestions[] = $arFormQuestion; } - + $c = 1; foreach($formQuestions AS $fq) { @@ -576,7 +590,7 @@ switch($PARAM_1) } } } - + if($fq['ANSWER']['FIELD_TYPE'] == "file") { if(is_array($_FILES[$fq['SID']])) @@ -608,12 +622,12 @@ switch($PARAM_1) { $formAnswers["form_".$fq['ANSWER']['FIELD_TYPE']."_".$fq['ANSWER']['ID']] = $_REQUEST[$fq['SID']]; } - + $arr['q'][] = $fq; - + $c++; } - + if(!empty($_SESSION[$_REQUEST['form']."_CAPTCHA"])) { if($_SESSION[$_REQUEST['form'].'_CAPTCHA'] != $_REQUEST[$_REQUEST['form'].'_CAPTCHA']) @@ -621,21 +635,21 @@ switch($PARAM_1) array_push($form_errors, $_REQUEST['form'].'_CAPTCHA'); } } - + $arr['FILES'] = $_FILES; - + if(count($form_errors) == 0) { if($RESULT_ID = CFormResult::Add($form['ID'], $formAnswers)) { $arr['status'] = "complete"; - + if($attach || array_key_exists("FORM_FILLING", $_REQUEST)) { if($attach) { $arAnswer = CFormResult::GetDataByID($RESULT_ID, Array(), $arResult, $arAnswer2); - + $fields = Array(); $attached_files = Array(); foreach($arAnswer AS $k => $v) @@ -717,7 +731,7 @@ switch($PARAM_1) } $arr['request'] = $_REQUEST; $arr['answers'] = $formAnswers; - + print json_encode($arr); die(); } @@ -735,6 +749,234 @@ switch($PARAM_1) } break; + case "recovery": + { + switch($PARAM_3) + { + case "email": + { + if(checkRequestIsLocal()) + { + $rs_user = \CUser::GetByLogin($REQ['email']); + $ar_user = $rs_user->Fetch(); + + if(is_array($ar_user)) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_PASSWORD_RECOVERY_CODE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "CODE" => $REQ['code'], + ) + ]); + + print json_encode([ + "status" => "success", + ]); + } + else + { + print json_encode([ + "status" => "error", + "error" => "wrong_email", + "message" => "Wrong email", + ]); + } + } + } + break; + + case "password": + { + if(checkRequestIsLocal()) + { + $rs_user = \CUser::GetByLogin($REQ['email']); + $ar_user = $rs_user->Fetch(); + + if(is_array($ar_user)) + { + $user = new \CUser; + $profile = [ + "PASSWORD" => $REQ['password'], + "CONFIRM_PASSWORD" => $REQ['password'], + ]; + + $user->Update($ar_user['ID'], $profile); + + if($user->LAST_ERROR) + { + print json_encode([ + "status" => "error", + "error" => "wrong_payload", + "message" => $user->LAST_ERROR, + ]); + } + else + { + /* + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_INFO", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "ORG_NAME" => $ar_user['UF_ORG_TITLE'], + "LOGIN" => $REQ['email'], + "PASS" => $REQ['password'], + ) + ]); + */ + + print json_encode([ + "status" => "success", + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "wrong_email", + "message" => "Wrong email", + ]); + } + } + } + break; + } + } + break; + + case "change": + { + switch($PARAM_3) + { + case "password": + { + if(checkRequestIsLocal()) + { + $user = new \CUser; + $login_result = $user->Login($REQ['email'], $REQ['password'], "N"); + + if($login_result == 1) + { + $existed_user_res = \CUser::GetByLogin($REQ['email']); + $existed_user = $existed_user_res->Fetch(); + + if(is_array($existed_user)) + { + $profile = [ + "PASSWORD" => $REQ['new_password'], + "CONFIRM_PASSWORD" => $REQ['new_password_repeat'], + ]; + + $user->Update($existed_user['ID'], $profile); + + if($user->LAST_ERROR) + { + print json_encode([ + "status" => "error", + "error" => "wrong_payload", + "message" => $user->LAST_ERROR, + ]); + } + else + { + print json_encode([ + "status" => "success", + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "unknow_user", + "message" => "Unknown user", + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "wrong_email", + "message" => "Wrong email", + ]); + } + } + } + break; + + case "phone": + { + if(checkRequestIsLocal()) + { + $token = str_replace("Bearer ", "", $_SERVER['REMOTE_USER']); + $auth = (array) \Bitrix\Main\Web\JWT::decode($token, $secret, ["HS256"]); + + $user = new \CUser; + + $existed_user_res = \CUser::GetByLogin($REQ['email']); + $existed_user = $existed_user_res->Fetch(); + + if(is_array($existed_user)) + { + if($existed_user['XML_ID'] == $auth['acc_number']) + { + $existed_phone_users_res = \CUser::GetList(["ID" => "ASC"], false, [ "UF_PHONE_NUMBER" => $REQ['phone'] ], []); + while($existed_phone_user = $existed_phone_users_res->Fetch()) + { + $user->Update($existed_user['ID'], [ + "UF_PHONE_NUMBER" => "", + ]); + } + + $profile = [ + "UF_PHONE_NUMBER" => $REQ['phone'], + ]; + + $user->Update($existed_user['ID'], $profile); + + if($user->LAST_ERROR) + { + print json_encode([ + "status" => "error", + "error" => "wrong_payload", + "message" => $user->LAST_ERROR, + ]); + } + else + { + print json_encode([ + "status" => "success", + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "wrong_company", + "message" => "Wrong company", + ]); + } + } + else + { + print json_encode([ + "status" => "error", + "error" => "wrong_email", + "message" => "Wrong email", + ]); + } + } + } + break; + } + } + break; + case "auth": { switch($PARAM_3) @@ -749,14 +991,12 @@ switch($PARAM_1) $rs_user = \CUser::GetByLogin($REQ['email']); $ar_user = $rs_user->Fetch(); - //print_r($ar_user); - $user_data = [ "email" => $ar_user['LOGIN'], "name" => $ar_user['NAME'], "secondname" => $ar_user['SECOND_NAME'], "lastname" => $ar_user['LAST_NAME'], - "phone" => $ar_user['UF_PHONE'], + "phone" => $ar_user['UF_PHONE_NUMBER'], "phone_verified" => $ar_user['UF_PHONE_VERIFIED'], ]; @@ -782,64 +1022,11 @@ switch($PARAM_1) "message" => "Wrong username or password", ]); } - - print $arAuthResult; } break; case "phone": { - /* - $oUserTypeEntity = new CUserTypeEntity(); - //$oUserTypeEntity->Delete(12); - - $aUserFields = array( - 'ENTITY_ID' => 'USER', - 'FIELD_NAME' => 'UF_PHONE_NUMBER', - 'USER_TYPE_ID' => 'string', - 'XML_ID' => 'XML_USER_PHONE_NUMBER', - 'SORT' => 500, - 'MULTIPLE' => 'N', - 'MANDATORY' => 'N', - 'SHOW_FILTER' => 'N', - 'SHOW_IN_LIST' => '', - 'EDIT_IN_LIST' => '', - 'IS_SEARCHABLE' => 'N', - 'SETTINGS' => array( - 'DEFAULT_VALUE' => '', - 'SIZE' => '20', - 'ROWS' => '1', - 'MIN_LENGTH' => '0', - 'MAX_LENGTH' => '0', - 'REGEXP' => '', - ), - 'EDIT_FORM_LABEL' => array( - 'ru' => 'Номер телефона', - 'en' => 'Phone number', - ), - 'LIST_COLUMN_LABEL' => array( - 'ru' => 'Номер телефона', - 'en' => 'Phone number', - ), - 'LIST_FILTER_LABEL' => array( - 'ru' => 'Номер телефона', - 'en' => 'Phone number', - ), - 'ERROR_MESSAGE' => array( - 'ru' => 'Ошибка при заполнении пользовательского свойства', - 'en' => 'An error in completing the user field', - ), - 'HELP_MESSAGE' => array( - 'ru' => '', - 'en' => '', - ), - ); - - $iUserFieldId = $oUserTypeEntity->Add( $aUserFields ); // int - print $iUserFieldId; - die(); - */ - if(!empty($REQ['phone'])) { $user = new \CUser; @@ -850,13 +1037,12 @@ switch($PARAM_1) while($arUser = $rsUsers->Fetch()) { array_push($numbers, $arUser); - //echo $arUser['ID'].' '.$arUser['LOGIN']."\n"; } if(count($numbers) > 0) { $ar_user = $numbers[count( $numbers ) - 1]; - + print json_encode([ "status" => "success", "acc_number" => $ar_user['XML_ID'], @@ -935,117 +1121,34 @@ switch($PARAM_1) } break; - case "contracts": + case "materials": { - if($auth['acc_number']) + if(CModule::IncludeModule('iblock')) { - $token = \Bitrix\Main\Web\JWT::encode(["acc_number" => $auth['acc_number']], $secret_crm, 'HS256', null, null); - $parameters = ["acc_number" => $auth['acc_number']]; + $sort = ["ACTIVE_FROM" => "DESC", "SORT" => "DESC"]; + $filter = ["ACTIVE" => "Y", "IBLOCK_ID" => 21]; + $options = []; - $url = API_HOST."/lk/Account/GetContracts/?".http_build_query($parameters); - - $c = curl_init(); - curl_setopt($c, CURLOPT_URL, $url); - curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($c, CURLOPT_TIMEOUT, 30); - curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($c, CURLOPT_POST, 0); - curl_setopt($c, CURLOPT_HTTPHEADER, [ - "Content-Type: application/json", - "Authorization: Bearer ".$token."", - ]); - - $response = curl_exec($c); - curl_close($c); - - print json_encode([ - "status" => "success", - "contracts" => $response, - ]); - } - else - { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); } - die(); - } - break; - - case "calendar": - { - if($auth['acc_number']) - { - $token = \Bitrix\Main\Web\JWT::encode(["acc_number" => $auth['acc_number']], $secret, 'HS256', null, null); - $parameters = ["acc_number" => $auth['acc_number']]; - - $url = API_HOST."/lk/Account/GetPaymentCalendar/?".http_build_query($parameters); - - $c = curl_init(); - curl_setopt($c, CURLOPT_URL, $url); - curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($c, CURLOPT_TIMEOUT, 30); - curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($c, CURLOPT_POST, 0); - curl_setopt($c, CURLOPT_HTTPHEADER, [ - "Content-Type: application/json", - "Authorization: Bearer ".$token."", - ]); - - $response = curl_exec($c); - curl_close($c); - - print json_encode([ - "status" => "success", - "contracts" => $response, - ]); - } - else - { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); } - die(); - } - break; - - case "contract": - { - switch($PARAM_4) - { - case "osago": + $materials = []; + $materials_res = CIBlockElement::GetList($sort, $filter, false, $options); + while ($materials_ob_element = $materials_res->GetNextElement()) { - if($auth['acc_number']) - { - $token = \Bitrix\Main\Web\JWT::encode(["acc_number" => $auth['acc_number']], $secret, 'HS256', null, null); - $parameters = ["acc_number" => $auth['acc_number']]; + $materials_ar_res = $materials_ob_element->GetFields(); + $materials_ar_res['PROPERTIES'] = $materials_ob_element->GetProperties(); - $url = API_HOST."/lk/Account/GetPaymentCalendar/?".http_build_query($parameters); + $f = CFile::GetByID($materials_ar_res['PROPERTIES']['FILE']['VALUE']); - $c = curl_init(); - curl_setopt($c, CURLOPT_URL, $url); - curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); - curl_setopt($c, CURLOPT_TIMEOUT, 30); - curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($c, CURLOPT_POST, 0); - curl_setopt($c, CURLOPT_HTTPHEADER, [ - "Content-Type: application/json", - "Authorization: Bearer ".$token."", - ]); - - $response = curl_exec($c); - curl_close($c); - - print json_encode([ - "status" => "success", - "contracts" => $response, - ]); - } - else - { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); } - die(); + $materials[] = [ + "name" => $materials_ar_res['NAME'], + "description" => $materials_ar_res['PREVIEW_TEXT'], + "filename" => $f->Fetch()['ORIGINAL_NAME'], + "url" => CFile::GetPath($materials_ar_res['PROPERTIES']['FILE']['VALUE']), + ]; } - break; + + print json_encode([ + "materials" => $materials, + ]); } } break; @@ -1073,6 +1176,7 @@ switch($PARAM_1) "lease_period" => $REQ['lease_period'], "redemption_payment" => $REQ['redemption_payment'], ]); + $c = curl_init(); curl_setopt($c, CURLOPT_URL, API_HOST."/calculator/"); curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30); diff --git a/catalog/index.php b/catalog/index.php index a8cf17b..f327968 100644 --- a/catalog/index.php +++ b/catalog/index.php @@ -19,6 +19,9 @@ $APPLICATION->SetTitle("Каталог"); "ENGINE_POWER_TO" => $_REQUEST['ENGINE_POWER_TO'], "ENGINE_VOLUME_FROM" => $_REQUEST['ENGINE_VOLUME_FROM'], "ENGINE_VOLUME_TO" => $_REQUEST['ENGINE_VOLUME_TO'], + "SORT" => $_REQUEST['SORT'], + "PATH" => "/catalog/", + "PROGRAM" => null, ) ); ?> diff --git a/index.php b/index.php index 455e1d3..447f6c6 100644 --- a/index.php +++ b/index.php @@ -10,13 +10,16 @@ $APPLICATION->SetTitle("Эволюция автолизинга. Лизинг а
- IncludeComponent( - "evolution:form.catalog.filter", - "", - Array( - "SELECTED" => [] - ) - ); ?> + IncludeComponent( + "evolution:form.catalog.filter", + "", + Array( + "SELECTED" => [], + "SORTING" => false, + "PATH" => "/catalog/", + "PROGRAM" => null, + ) + ); ?>
diff --git a/local/components/evolution/about.career.vacancy/component.php b/local/components/evolution/about.career.vacancy/component.php index 8f9ba86..3f85473 100644 --- a/local/components/evolution/about.career.vacancy/component.php +++ b/local/components/evolution/about.career.vacancy/component.php @@ -33,6 +33,13 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $ar_res['PROPERTIES'] = $obElement->GetProperties(); $ar_res['PROPERTIES']['REGION']['RELATED'] = get_related_array(15, $ar_res['PROPERTIES']['REGION']['VALUE']); + $regions = []; + foreach($ar_res['PROPERTIES']['REGION']['RELATED'] AS $r) + { + array_push($regions, $r['NAME']); + } + $ar_res['REGIONS'] = $regions; + $arResult = $ar_res; } diff --git a/local/components/evolution/about.career.vacancy/templates/.default/template.php b/local/components/evolution/about.career.vacancy/templates/.default/template.php index b65b496..c90e914 100644 --- a/local/components/evolution/about.career.vacancy/templates/.default/template.php +++ b/local/components/evolution/about.career.vacancy/templates/.default/template.php @@ -47,7 +47,7 @@ $this->setFrameMode(true); "", Array( "VACANCY" => $arResult["NAME"], - "VACANCY_REGION" => $arResult['PROPERTIES']['REGION']['RELATED']['NAME'], + "VACANCY_REGIONS" => $arResult['REGIONS'], ) ); ?> \ No newline at end of file diff --git a/local/components/evolution/catalog.sort/component.php b/local/components/evolution/catalog.sort/component.php new file mode 100644 index 0000000..96e37c2 --- /dev/null +++ b/local/components/evolution/catalog.sort/component.php @@ -0,0 +1,18 @@ +includeComponentTemplate(); \ No newline at end of file diff --git a/local/components/evolution/catalog.sort/templates/.default/template.php b/local/components/evolution/catalog.sort/templates/.default/template.php new file mode 100644 index 0000000..025988b --- /dev/null +++ b/local/components/evolution/catalog.sort/templates/.default/template.php @@ -0,0 +1,33 @@ +setFrameMode(true); +?> +
+
+ + +
+ +
+ +
+ +
diff --git a/local/components/evolution/catalog/component.php b/local/components/evolution/catalog/component.php index c2c5b03..8b3d623 100644 --- a/local/components/evolution/catalog/component.php +++ b/local/components/evolution/catalog/component.php @@ -27,16 +27,39 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) 'ITEMS' => [] ]; - $sort = Array("SORT" => "ASC", "NAME" => "ASC"); - $filter = Array("ACTIVE" => "Y", "IBLOCK_ID" => 1); - $options = Array("nPageSize" => 6); - $query = null; $query_arr = []; - $pages_url = "/catalog"; + $sort = Array("SORT" => "ASC", "NAME" => "ASC"); + if(isset($arParams['SORT'])) + { + if($arParams['SORT'] === "name") + { + $sort = Array("SORT" => "ASC", "NAME" => "ASC"); + $arResult['SCROLL'] = true; + } + if($arParams['SORT'] === "low") + { + $sort = Array("SORT" => "ASC", "PROPERTY_PRICE" => "ASC"); + $query_arr['SORT'] = $arParams['SORT']; + $arResult['SCROLL'] = true; + } + if($arParams['SORT'] === "high") + { + $sort = Array("SORT" => "ASC", "PROPERTY_PRICE" => "DESC"); + $query_arr['SORT'] = $arParams['SORT']; + $arResult['SCROLL'] = true; + } + + $arResult['SELECTED']['SORT'] = $arParams['SORT']; + } + $filter = Array("ACTIVE" => "Y", "IBLOCK_ID" => 1); + $options = Array("nPageSize" => 6); + + $pages_url = $arParams['PATH']; $arResult['EXTENDED'] = false; + $arResult['FILTER_SMALL'] = $arParams['FILTER_SMALL'] ? true : false; if(!empty($arParams['BRAND'])) { @@ -45,11 +68,13 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) { $brands_ar_res = $brands_ob_element->GetFields(); $filter['PROPERTY_BRAND'] = $brands_ar_res['ID']; - $pages_url = $pages_url."/".$brands_ar_res['CODE']; + $pages_url = $pages_url.$brands_ar_res['CODE']."/"; $arResult['SELECTED']['BRAND'] = $brands_ar_res['CODE']; } $arResult['EXTENDED'] = true; + $arResult['FILTER_SMALL'] = false; + $arResult['SCROLL'] = true; } if(!empty($arParams['MODEL'])) @@ -59,11 +84,12 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) { $models_ar_res = $models_ob_element->GetFields(); $filter['PROPERTY_MODEL'] = $models_ar_res['ID']; - $pages_url = $pages_url."/".$models_ar_res['CODE']; + $pages_url = $pages_url.$models_ar_res['CODE']."/"; $arResult['SELECTED']['MODEL'] = $models_ar_res['CODE']; } $arResult['EXTENDED'] = true; + $arResult['SCROLL'] = true; } if(!empty($arParams['MODIFICATION'])) @@ -73,6 +99,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $filter['PROPERTY_MODIFICATION'] = $arParams['MODIFICATION']; $query_arr['MODIFICATION'] = $arParams['MODIFICATION']; + $arResult['SCROLL'] = true; } if(!empty($arParams['DRIVE'])) @@ -82,6 +109,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $filter['=PROPERTY_DRIVE'] = $arParams['DRIVE']; $query_arr['DRIVE'] = $arParams['DRIVE']; + $arResult['SCROLL'] = true; } if(!empty($arParams['BODY'])) @@ -91,6 +119,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $filter['=PROPERTY_BODY'] = $arParams['BODY']; $query_arr['BODY'] = $arParams['BODY']; + $arResult['SCROLL'] = true; } if(!empty($arParams['GEAR'])) @@ -100,6 +129,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $filter['=PROPERTY_GEAR'] = $arParams['GEAR']; $query_arr['GEAR'] = $arParams['GEAR']; + $arResult['SCROLL'] = true; } if(!empty($arParams['ENGINE_FUEL'])) @@ -109,6 +139,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $arResult['SELECTED']['ENGINE_FUEL'] = $arParams['ENGINE_FUEL']; $query_arr['ENGINE_FUEL'] = $arParams['ENGINE_FUEL']; + $arResult['SCROLL'] = true; } if(!empty($arParams['ENGINE_POWER_FROM']) || !empty($arParams['ENGINE_POWER_TO'])) @@ -125,6 +156,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $arResult['SELECTED']['ENGINE_POWER_TO'] = $arParams['ENGINE_POWER_TO']; $query_arr['ENGINE_POWER_TO'] = $arParams['ENGINE_POWER_TO']; } + $arResult['SCROLL'] = true; } if(!empty($arParams['ENGINE_VOLUME_FROM']) || !empty($arParams['ENGINE_VOLUME_TO'])) @@ -141,9 +173,10 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $arResult['SELECTED']['ENGINE_VOLUME_TO'] = $arParams['ENGINE_VOLUME_TO']; $query_arr['ENGINE_VOLUME_TO'] = $arParams['ENGINE_VOLUME_TO']; } + $arResult['SCROLL'] = true; } - $pages_url = $pages_url."/"; + //$pages_url = $pages_url."/"; if(count($query_arr) > 0) { @@ -252,7 +285,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $navComponentObject, "", "catalog", - "N", + "N", null, [ "section_code" => !empty($arParams['section_code']) ? $arParams['section_code'] : $pages_url, diff --git a/local/components/evolution/catalog/templates/.default/template.php b/local/components/evolution/catalog/templates/.default/template.php index 1eebe4a..be04a87 100644 --- a/local/components/evolution/catalog/templates/.default/template.php +++ b/local/components/evolution/catalog/templates/.default/template.php @@ -16,7 +16,6 @@ $this->setFrameMode(true);

Каталог автомобилей

-
@@ -31,56 +30,47 @@ $this->setFrameMode(true);
- - - - - - -
- -
-
- -
-
- */?> - - -
"> -
-
-
- -
-
- -
- - +
"> + +
+
+
- -
-
"> -
- +
+ +
+ + +
+ +
+
"> +
IncludeComponent( "evolution:form.catalog.filter", "", Array( - "SELECTED" => $arResult['SELECTED'] + "SELECTED" => $arResult['SELECTED'], + "PATH" => $arParams['PATH'], + "SORTING" => true, + "PROGRAM" => $arParams['PROGRAM'], + "SCROLL" => $arResult['SCROLL'], ) ); ?> - -
- - +
+ IncludeComponent( + "evolution:catalog.sort", + "", + Array( + "SORT" => $arParams['SORT'], + "FILTER" => $arResult['FILTER_SMALL'], + ) + ); ?> 0): ?>
diff --git a/local/components/evolution/form.catalog.filter/component.php b/local/components/evolution/form.catalog.filter/component.php index d655d56..fa6ea6b 100644 --- a/local/components/evolution/form.catalog.filter/component.php +++ b/local/components/evolution/form.catalog.filter/component.php @@ -22,6 +22,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) { $arResult = [ 'SELECTED' => $arParams['SELECTED'], + 'SCROLL' => $arParams['SCROLL'], ]; $this->IncludeComponentTemplate(); diff --git a/local/components/evolution/form.catalog.filter/templates/.default/script.js b/local/components/evolution/form.catalog.filter/templates/.default/script.js index a2cef79..e02c286 100644 --- a/local/components/evolution/form.catalog.filter/templates/.default/script.js +++ b/local/components/evolution/form.catalog.filter/templates/.default/script.js @@ -1,11 +1,17 @@ +var current = {}; var selected = {}; var inputs = {}; +var path = ""; +var program = null; -function formCatalogFilter(props) +function formCatalogFilter(p, pr, props) { - console.log("props???"); - console.log(props); + console.log("FILTER", "program", pr); + path = p; selected = props; + current = props; + program = pr; + $(".filter_header .tabs .tab").on("click", function() { $(".filter_header .tabs .tab").removeClass("active"); @@ -21,6 +27,10 @@ function updateCounter(parameters) $("#catalog_filter_search_button_counter").hide(); var params = {}; + if(program !== null) + { + params['PROGRAM'] = program; + } for(let i in parameters) { if(parameters[i] !== undefined) { params[i] = parameters[i]; } @@ -138,6 +148,11 @@ function loadModifications(uid) $(function() { + $("#catalog_filter_form").on("submit", function(event) + { + event.preventDefault(); + }); + $.get("/api/catalog/brands/", { params: {}, @@ -182,7 +197,10 @@ $(function() selected['MODIFICATION'] = undefined; if($(this).val() === "") - { + { + selected['BRAND'] = undefined; + selected['BRAND_ID'] = undefined; + $("#small_filter_brands").find("option").first().text("Марка").attr("disabled", "disabled"); $("#small_filter_models").empty(); $("#small_filter_models").append(""); @@ -191,6 +209,8 @@ $(function() $("#filter_models").append(""); $("#filter_modifications").empty(); $("#filter_modifications").append(""); + + updateCounter(selected); } else { @@ -332,28 +352,26 @@ $(function() $("#catalog_small_find").on("click", function() { - var path = "/catalog"; + var p = path; - if($("#small_filter_brands").val() !== "") + if($("#small_filter_brands").val() !== "" && $("#small_filter_brands").val() !== null) { - path = path+"/"+$("#small_filter_brands").val(); + p = p + $("#small_filter_brands").val()+"/"; } - if($("#small_filter_models").val() !== "") + if($("#small_filter_models").val() !== "" && $("#small_filter_models").val() !== null) { - path = path+"/"+$("#small_filter_models").val(); + p = p + $("#small_filter_models").val()+"/"; } - path = path+"/"; - - window.location.href = path; + window.location.href = p; //$("#catalog_small_form").submit(); }); $("#rich_filter_toggle").on("click", function() { updateCounter(selected); - $("#filter").addClass("visible"); - $("#catalog_small_filter").addClass("hidden"); + $("#filter").addClass("visible").css("display", "block"); + $("#catalog_small_filter").addClass("hidden").css("display", "none"); }); $.get("/api/catalog/parameters/", @@ -463,28 +481,28 @@ $(function() $("#catalog_filter_search_button").on("click", function(e) { e.preventDefault(); - var path = "/catalog"; + var p = path; if($("#filter_brands").val() !== undefined && $("#filter_brands").val() !== null && $("#filter_brands").val() !== "") { - path = path+"/"+$("#filter_brands").val(); + p = p + $("#filter_brands").val()+"/"; } if($("#filter_models").val() !== undefined && $("#filter_models").val() !== null && $("#filter_models").val() !== "") { - path = path+"/"+$("#filter_models").val(); + p = p + $("#filter_models").val()+"/"; } - var p = {}; + var pa = {}; for(let i in selected) { if(i !== "BRAND" && i !== "BRAND_ID" && i !== "MODEL" && i !== "MODEL_ID") { - p[i] = selected[i]; + pa[i] = selected[i]; } } - path = path+"/?"+$.param(p); - window.location.href = path; + p = p + "?"+$.param(pa); + window.location.href = p; }); $("#filter_engine_volume_from").on("change", function() @@ -530,4 +548,47 @@ $(function() inputs['engine_volume_to'] = event.target.value; }); */ + + $(".sort_option").on("click", function() + { + console.log("path", path); + var value = $(this).data("value"); + var p = path; + var o = {}; + for(let i in current) + { + if(i !== "SORT" && i !== "BRAND" && i !== "MODEL" && i !== "BRAND_ID" && i !== "MODEL_ID") + { + o[i] = current[i]; + } + } + if(current['BRAND'] !== undefined) + { + p = p + current['BRAND']+"/"; + } + if(current['MODEL'] !== undefined) + { + p = p + current['MODEL']+"/"; + } + p = p+"?"; + //if(value !== "name") + //{ + p = p + "SORT="+value; + //} + + var params = $.param(o); + if(params.length > 0) + { + p = "&"+params; + } + + document.location.href = p; + }); + + $(".i-filter").on("click", function() + { + $(".filter_selector").css("display", "none"); + //$(this).parent().parent().css("display", "none"); + $("#catalog_small_filter").css("display", "block"); + }); }); \ No newline at end of file diff --git a/local/components/evolution/form.catalog.filter/templates/.default/template.php b/local/components/evolution/form.catalog.filter/templates/.default/template.php index bd202be..0b6b837 100644 --- a/local/components/evolution/form.catalog.filter/templates/.default/template.php +++ b/local/components/evolution/form.catalog.filter/templates/.default/template.php @@ -15,7 +15,7 @@ $this->setFrameMode(true);