Skip to content

Commit

Permalink
v.1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
zahalski committed Jun 29, 2022
1 parent 54ffd10 commit 230859f
Show file tree
Hide file tree
Showing 21 changed files with 3,865 additions and 74 deletions.
120 changes: 89 additions & 31 deletions bitrix/modules/awz.ydelivery/admin/offers_list_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@

$api = Helper::getApiByProfileId($curProfile);

if(isset($prepareData['bx_external']))
unset($prepareData['bx_external']);

$offersRes = $api->getOffers($prepareData);

//echo'<pre>';print_r($offersRes);echo'</pre>';
Expand All @@ -235,6 +238,14 @@
$arOffers = $offers['result']['offers'];
}


echo'<div class="debug_yandex">';
echo'<div class="debug_prepareData"><pre>';print_r($prepareData);echo'</pre></div>';
echo'<div class="debug_offersRes"><pre>';print_r($offersRes);echo'</pre></div>';
echo'<div class="debug_LastResponse"><pre>';print_r($api->getLastResponse());echo'</pre></div>';
echo'</div>';
echo'<a href="#" class="debug_yandex_show">'.Loc::getMessage('AWZ_YDELIVERY_SYSTEM_INFO').'</a>';

//echo'<pre>';print_r($autoOffer);echo'</pre>';

}else{
Expand All @@ -252,7 +263,7 @@
));
}

$locationCode = $propertyCollection->getDeliveryLocation()->getValue();
/*$locationCode = $propertyCollection->getDeliveryLocation()->getValue();
if ($loc = \Bitrix\Sale\Location\LocationTable::getRowById($locationCode)) {
$locationCode = $loc['CODE'];
}
Expand Down Expand Up @@ -289,16 +300,51 @@
);
//return $result;
}
*/

/* @var \Bitrix\Sale\EntityPropertyValue $prop*/
$adressProp = $propertyCollection->getAddress();

$items = Helper::getItems($order);
$prepareAutoResult = OffersTable::getPrepare($order, true);
$items = array();
$prepareAutoData = array();
$locationName = '';
if($prepareAutoResult->isSuccess()){
$prepareAutoData = $prepareAutoResult->getData();
$items = $prepareAutoData['items'];
$locationName = $prepareAutoData['bx_external']['location_name'];
//echo'<pre>';print_r($prepareAutoData);echo'</pre>';
}else{
CAdminMessage::ShowMessage(array(
'TYPE'=>'ERROR',
'MESSAGE'=>implode('; ', $prepareAutoResult->getErrorMessages())
));
$items = Helper::getItems($order);
}


//echo'<pre>';print_r($_REQUEST);echo'</pre>';
//echo'<pre>';print_r($arOffers);echo'</pre>';

?>

<style>
.debug_prepareData, .debug_offersRes, .debug_LastResponse {display:block;border:1px solid #000000;padding:10px;margin:10px;}
.debug_yandex {display:none;}
</style>
<script>
$(document).on('click','.debug_yandex_show',function(e){
e.preventDefault();
if($(this).hasClass('active')){
$('.debug_yandex').hide();
$(this).html('<?=Loc::getMessage('AWZ_YDELIVERY_SYSTEM_INFO')?>');
$(this).removeClass('active');
}else{
$('.debug_yandex').show();
$(this).html('<?=Loc::getMessage('AWZ_YDELIVERY_SYSTEM_HIDE')?>');
$(this).addClass('active');
}
});
</script>
<?if(!empty($arOffers)){?>

<div class="adm-list-table-layout">
Expand Down Expand Up @@ -570,7 +616,7 @@
<?foreach(array(0,1,2) as $key){?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell">
<?$val = $items[0]['place_barcode'];
<?$val = $prepareAutoData['places'][0]['barcode'];
if($key != 0) $val = '';
if(isset($_REQUEST['places'][$key]['barcode'])) $val = htmlspecialcharsEx(trim($_REQUEST['places'][$key]['barcode']));
?>
Expand Down Expand Up @@ -625,6 +671,8 @@
<td class="adm-detail-content-cell-r">
<?
$val = '';
if(isset($prepareAutoData['info']['operator_request_id']))
$val = $prepareAutoData['info']['operator_request_id'];
if(isset($_REQUEST['info']['order_new'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['order_new']));
?>
<input type="text" name="info[order_new]" value="<?=$val?>">
Expand All @@ -647,11 +695,13 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $adressProp->getValue();
$userComment = $order->getField('USER_DESCRIPTION');
$val = '';
if(isset($prepareAutoData['info']['comment']))
$val = $prepareAutoData['info']['comment'];
/*$userComment = $order->getField('USER_DESCRIPTION');
if($userComment){
$val .= '; '.$userComment;
}
}*/
if(isset($_REQUEST['info']['comment'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['comment']));
?>
<textarea cols="30" rows="5" name="info[comment]"><?=$val?></textarea>
Expand All @@ -664,7 +714,9 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $locationName.', '.$adressProp->getValue();
$val = '';
if(isset($prepareAutoData['destination']['custom_location']['details']['full_address']))
$val = $prepareAutoData['destination']['custom_location']['details']['full_address'];
if(isset($_REQUEST['info']['address'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['address']));
?>
<textarea cols="30" rows="5" name="info[address]"><?=$val?></textarea>
Expand All @@ -678,6 +730,8 @@
<td class="adm-detail-content-cell-r">
<?
$val = '';
if(isset($prepareAutoData['destination']['custom_location']['details']['room']))
$val = $prepareAutoData['destination']['custom_location']['details']['room'];
if(isset($_REQUEST['info']['address_kv'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['address_kv']));
?>
<input type="text" name="info[address_kv]" value="<?=$val?>">
Expand All @@ -691,13 +745,8 @@
<td class="adm-detail-content-cell-r">
<?
$val = '';
$propertyCollection = $order->getPropertyCollection();
/* @var \Bitrix\Sale\EntityPropertyValue $prop*/
foreach($propertyCollection as $prop){
if($prop->getField('CODE') == Helper::getPropPvzCode($profilePvz)){
$val = $prop->getValue();
}
}
if(isset($prepareAutoData['destination']['platform_station']['platform_id']))
$val = $prepareAutoData['destination']['platform_station']['platform_id'];
if(isset($_REQUEST['info']['pvz'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['pvz']));
?>
<input type="text" id="info-pvz-field" name="info[pvz]" value="<?=$val?>">
Expand Down Expand Up @@ -748,13 +797,8 @@
<td class="adm-detail-content-cell-r">
<?
$val = '';
$propertyCollection = $order->getPropertyCollection();
/* @var \Bitrix\Sale\EntityPropertyValue $prop*/
foreach($propertyCollection as $prop){
if($prop->getField('CODE') == Helper::getPropDateCode($curProfile)){
$val = $prop->getValue();
}
}
if(isset($prepareAutoData['bx_external']['delivery_date']))
$val = $prepareAutoData['bx_external']['delivery_date'];
if(isset($_REQUEST['info']['date_dost'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['date_dost']));
?>
<input type="text" name="info[date_dost]" value="<?=$val?>">
Expand All @@ -766,7 +810,9 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $propertyCollection->getPayerName()->getValue();
$val = '';
if(isset($prepareAutoData['recipient_info']['first_name']))
$val = $prepareAutoData['recipient_info']['first_name'];
if(isset($_REQUEST['info']['first_name'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['first_name']));
?>
<input type="text" name="info[first_name]" value="<?=$val?>">
Expand All @@ -778,7 +824,9 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $propertyCollection->getPhone()->getValue();
$val = '';
if(isset($prepareAutoData['recipient_info']['phone']))
$val = $prepareAutoData['recipient_info']['phone'];
if(isset($_REQUEST['info']['phone'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['phone']));
?>
<input type="text" name="info[phone]" value="<?=$val?>">
Expand All @@ -790,7 +838,9 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $propertyCollection->getUserEmail()->getValue();
$val = '';
if(isset($prepareAutoData['recipient_info']['email']))
$val = $prepareAutoData['recipient_info']['email'];
if(isset($_REQUEST['info']['email'])) $val = htmlspecialcharsEx(trim($_REQUEST['info']['email']));
?>
<input type="text" name="info[email]" value="<?=$val?>">
Expand Down Expand Up @@ -819,7 +869,9 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$val = $order->getDeliveryPrice();
$val = '';
if(isset($prepareAutoData['billing_info']['delivery_cost']))
$val = $prepareAutoData['billing_info']['delivery_cost']/100;
if(isset($_REQUEST['order']['delivery_cost']))
$val = round($_REQUEST['order']['delivery_cost'], 2);
?>
Expand All @@ -832,11 +884,14 @@
</td>
<td class="adm-detail-content-cell-r">
<?
$valAr = '';
$valAr = array();
$valAr = Helper::getYandexPaymentIdFromOrder($order, $curProfile);
if(!empty($valAr)){
/*if(!empty($valAr)){
$val = $valAr[0];
}
}*/
$val = '';
if(isset($prepareAutoData['billing_info']['payment_method']))
$val = $prepareAutoData['billing_info']['payment_method'];
$methods = Helper::getYandexPayMethods();

if(isset($_REQUEST['order']['payment_method']))
Expand All @@ -860,7 +915,9 @@
</td>
</tr>
<tr>
<td width="50%" class="adm-detail-content-cell-l">last_mile_policy</td>
<td width="50%" class="adm-detail-content-cell-l">
<?=Loc::getMessage('AWZ_YDELIVERY_MILE_POLISY')?>
</td>
<td class="adm-detail-content-cell-r">
<?
$val = '';
Expand All @@ -869,7 +926,8 @@
}else{
$methods = Helper::getYandexLastMilePolicy(Helper::DOST_TYPE_PVZ);
}

if(isset($prepareAutoData['last_mile_policy']))
$val = $prepareAutoData['last_mile_policy'];
if(isset($_REQUEST['order']['last_mile_policy'])) $val = htmlspecialcharsEx(trim($_REQUEST['order']['last_mile_policy']));

?>
Expand Down
2 changes: 2 additions & 0 deletions bitrix/modules/awz.ydelivery/admin/pickpoint_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
\CUtil::InitJSCore(array('ajax', 'awz_yd_lib'));

$key = Option::get("fileman", "yandex_map_api_key");
$setSearchAddress = Option::get($module_id, "MAP_ADDRESS", "N", "");
Asset::getInstance()->addString('<script>window._awz_yd_lib_setSearchAddress = "'.$setSearchAddress.'";</script>', true);
Asset::getInstance()->addString('<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU&apikey='.$key.'"></script>', true);

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
Expand Down
14 changes: 10 additions & 4 deletions bitrix/modules/awz.ydelivery/install/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if(!window.awz_yd_modal){
},
success: function(resp){
var data = resp.data;
console.log(data);
//console.log(data);
if(resp.status === 'error'){
var msg = '';
var k;
Expand Down Expand Up @@ -144,10 +144,16 @@ if(!window.awz_yd_modal){
});
},
initMap: function(){

var controls = ['zoomControl', 'searchControl'];
if(window.hasOwnProperty('_awz_yd_lib_setSearchAddress') && window._awz_yd_lib_setSearchAddress != 'Y'){
controls = ['zoomControl'];
}

this.map = new ymaps.Map("awz-yd-map",{
center: [55.7522, 37.6156],
zoom: 14,
controls: ['zoomControl', 'searchControl']
controls: controls
},{
balloonMaxWidth: 280
});
Expand Down Expand Up @@ -214,7 +220,7 @@ if(!window.awz_yd_modal){
if(!!e) e.preventDefault();
var form = $('#AWZ_YD_POINT_LINK').parents('form');
if(!$('#AWZ_YD_POINT_ID').length){
console.log(form);
//console.log(form);
form.prepend('<input type="hidden" name="AWZ_YD_POINT_ID" id="AWZ_YD_POINT_ID" value="">');
}
$('#AWZ_YD_POINT_ID').val($(this).attr('data-id'));
Expand Down Expand Up @@ -371,6 +377,6 @@ if(!window.awz_yd_modal){
}

$(document).ready(function(){
console.log('register module awz.ydelivery');
//console.log('register module awz.ydelivery');
window.awz_yd_modal.initHandlers();
});
4 changes: 2 additions & 2 deletions bitrix/modules/awz.ydelivery/install/version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "1.0.8",
"VERSION_DATE" => "2022-06-29 13:35:00"
"VERSION" => "1.0.9",
"VERSION_DATE" => "2022-06-30 01:53:00"
);
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@
$MESS["AWZ_YDELIVERY_ADRES_DOSTAVKI"] = "Адрес доставки: ";
$MESS["AWZ_YDELIVERY_ADRES"] = "Адрес:";
$MESS["AWZ_YDELIVERY_PVZ"] = "ПВЗ: ";
$MESS["AWZ_YDELIVERY_MILE_POLISY"] = "Политика доставки";
$MESS["AWZ_YDELIVERY_SYSTEM_INFO"] = "Показать системную информацию запроса";
$MESS["AWZ_YDELIVERY_SYSTEM_HIDE"] = "Скрыть системную информацию запроса";
?>
1 change: 1 addition & 0 deletions bitrix/modules/awz.ydelivery/lang/ru/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@
$MESS["AWZ_YDELIVERY_OPT_L_UPPVZ_LINK"] = "Связь ПВЗ с внешними источниками";
$MESS["AWZ_YDELIVERY_OPT_L_UPPVZ_LOAD"] = "Перейти к загрузке";
$MESS["AWZ_YDELIVERY_OPT_L_UPPVZ_LINK_ON"] = "Включить поиск ПВЗ по внешним кодам";
$MESS["AWZ_YDELIVERY_OPT_MAP_ADRESS"] = "Включить строку поиска адреса на Яндекс Карте (обязателен ключ API в настройках модуля fileman)";
?>
2 changes: 2 additions & 0 deletions bitrix/modules/awz.ydelivery/lib/handlersbx.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ public static function OrderDeliveryBuildList(&$arResult, &$arUserResult, $arPar
\CUtil::InitJSCore(array('ajax', 'awz_yd_lib'));

$key = Option::get("fileman", "yandex_map_api_key");
$setSearchAddress = Option::get(Handler::MODULE_ID, "MAP_ADDRESS", "N", "");
Asset::getInstance()->addString('<script>window._awz_yd_lib_setSearchAddress = "'.$setSearchAddress.'";</script>', true);
Asset::getInstance()->addString('<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU&apikey='.$key.'"></script>', true);

}
Expand Down
Loading

0 comments on commit 230859f

Please sign in to comment.