Заказ детально с использованием fancybox

Заказ детально с использованием fancybox.

Кнопка, по клику на которую открывается информация о заказе:

<span data-type="ajax" data-fancybox data-src="/ajax/personal/personal-detail.php?id=<?=$order['ORDER']['ACCOUNT_NUMBER'];?>&color=<?=$order['ORDER']['STATUS_ID']?>" class="table-personal__inner table-personal__more">Перейти</span>

Здесь посредством get передаем номер заказа и его статус.

Содержимое файла personal-detail.php:

<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog"))
{
$order = \Bitrix\Sale\Order::loadByAccountNumber($_GET['id']);
//дата заказа
$date = $order->getDateInsert();
//Дата статуса
$dateStatus = $order->getField("DATE_STATUS");
//Статус заказа
$status_id = $order->getField("STATUS_ID");
switch($status_id){
case 'F':
$status_name = 'Выполнен';
break;
case 'N':
$status_name = 'Принят, ожидается оплата';
break;
default:
$status_name = 'Отменен';
}
//Корзина
$basket = $order->getBasket();
//print_r($order->getAvailableFields());
$basket->getQuantityList();
//Свойства заказа
$propertyCollection = $order->getPropertyCollection();
//Оплаты заказа
$paymentCollection = $order->getPaymentCollection();
if(!$paymentCollection->hasPaidPayment()){
$arResult = [];
// Способы доставки
$resDelivery=CSaleDelivery::GetList(Array(),Array("LID"=>SITE_ID,"ACTIVE"=>"Y"),false,false,Array());
if($arDelivery=$resDelivery->Fetch()){
do{
$arResult["DELIVERY_TYPE"][]=$arDelivery;
}while($arDelivery=$resDelivery->Fetch());
}
// Способы оплаты
$arPaySystem=Array();
$resPaySystem=CSalePaySystem::GetList(Array(),Array("ACTIVE" => "Y"),false,false,Array());
while($arPaySystemItem=$resPaySystem->Fetch()){
$arResult["PAY_SYSTEM"][]=$arPaySystemItem;
}
}
//Доставки заказа
$shipmentCollection = $order->getShipmentCollection();
?>
<div class="" id="order-detail">
<div class="personal-detail">
<div class="row">

<div class="col-12 personal-detail__status<?if($_GET['color'] == "N"):?> status-yellow__bg<?elseif($_GET['color'] == "F"):?> status-green__bg<?else:?> status-red__bg<?endif;?>">
Заказ №<?=$order->getId();?> от <?=$date->format("d.m.Y");?>, <?=array_sum($basket->getQuantityList())?> <?
$count = array_sum($basket->getQuantityList()) % 10;
if ($count == '1')
{
echo "товар";
}
elseif ($count >= '2' && $count <= '4')
{
echo "товара";
}
else
{
echo "товаров";
}
?> на сумму <?=$order->getPrice();?> руб.

</div>
</div>
<div class="personal-detail__inner">
<div class="row">
<div class="col">
<p class="personal__capture text-uppercase">ФИО</p>
<?$rsUser = CUser::GetByID($order->getUserId());
$arUser = $rsUser->Fetch();
$arGroups = CUser::GetUserGroup($order->getUserId());
//Юридическое ли лицо, м, не слишу:
$isLegal = in_array(7,$arGroups);
echo $arUser['NAME'].' '.$arUser['LAST_NAME'];?>
</div>
<div class="col">
<p class="personal__capture text-uppercase">Текущий статус от <?=$dateStatus->format('d.m.Y');?></p>
<?=$status_name?>
</div>
<div class="col-auto">
<p class="personal__capture text-uppercase">сумма</p>
<?=$order->getPrice();?> руб.
</div>

<?if($status_id == "N"):?>
<div class="col-auto">
<span class="personal__button personal__button--red text-uppercase" data-order="<?=$_GET['id']?>" id="cancel-detail">Отменить</span>
</div>
<?endif;?>
<div class="col-auto">
<span class="personal__button text-uppercase" data-order="<?=$_GET['id']?>" id="repeat-detail">Повторить заказ</span>
</div>
</div>
<div class="personal__margener"></div>
<!--Оплата-->
<div class="row">
<div class="col">
<div class="table-personal--gr personal-detail__psh">
<?foreach ($paymentCollection as $payment) {?>
<svg class="personal__icon">
<use xlink:href="<?=SITE_TEMPLATE_PATH?>/assets/images/icon/sprait.svg#card"></use>
</svg>
<span class="payment-detail<?=$_GET['id']?>"><?=$psName = $payment->getPaymentSystemName();?></span>
<?}?>
</div>
</div>
<?if(!$paymentCollection->hasPaidPayment() && $status_id == "N"):?>
<div class="col-auto">
<a href="/payment.php?ORDER_ID=<?=$_GET['id']?>" class="personal__button personal__button--redbg text-uppercase">Оплатить</a>
</div>
<?endif;?>
<?if(!$paymentCollection->hasPaidPayment() && $isLegal):?>
<div class="col-12"><span class="personal__dropdown text-uppercase">изменить способ оплаты <span class="carat"></span></span>
<div class="personal-open-detail">
<?foreach($arResult["PAY_SYSTEM"] as $key=>$arPSystem):?>
<label class="site-bar__label registr__controls-label" data-order="<?=$_GET['id']?>">
<input class="site-bar__inp" type="radio" name="user__payment" id="psystem<?=$arPSystem["ID"]?>" value="<?=$arPSystem["ID"]?>" <?if(!$key):?>checked<?endif;?>>
<div class="site-bar__face"></div>
<div class="site-bar__text"><?=$arPSystem["NAME"]?></div>
</label>
<?endforeach;?>
</div>
</div>
<?endif;?>
</div>
<!--Конец оплата-->
<div class="personal__margener"></div>
<!--Доставка-->
<div class="row">
<div class="col">
<div class="table-personal--gr personal-detail__psh">
<?foreach ($shipmentCollection as $shipment) {?>
<?
if($shipment->isSystem())
continue;?>
<svg class="personal__icon">
<use xlink:href="<?=SITE_TEMPLATE_PATH?>/assets/images/icon/sprait.svg#shopping"></use>
</svg>
<span class="shipment-detail<?=$_GET['id']?>"><?=$shipment->getField('DELIVERY_NAME');?></span>
<?}?>
</div>
</div>
<?if(!$paymentCollection->hasPaidPayment() && $isLegal):?>
<div class="col-12"><span class="personal__dropdown text-uppercase">изменить способ доставки <span class="carat"></span></span>
<div class="personal-open-detail">
<?foreach($arResult["DELIVERY_TYPE"] as $key=>$arDType):?>
<label class="site-bar__label registr__controls-label" data-order="<?=$_GET['id']?>">
<input class="site-bar__inp" type="radio" name="user__delivery" id="dtype<?=$arDType["ID"]?>" value="<?=$arDType["ID"]?>" <?if(!$key):?>checked<?endif;?>>
<div class="site-bar__face"></div>
<div class="site-bar__text"><?=$arDType["NAME"]?></div>
</label>
<?endforeach;?>
</div>
</div>
<?endif;?>
</div>
<!--Конец Доставка-->
</div>
<div class="personal__bordered"></div>
<div class="personal-detail__inner">
<div class="row">
<div class="col-6">
<p class="personal__capture text-uppercase">наименование</p>
</div>
<div class="col-2 text-center">
<p class="personal__capture text-uppercase">цена</p>
</div>
<div class="col-2 text-center">
<p class="personal__capture text-uppercase">количество</p>
</div>
<div class="col-2 text-center">
<p class="personal__capture text-uppercase">сумма</p>
</div>
</div>
<div class="personal__bordered"></div>
<div class="personal__margener"></div>
<?foreach ($basket as $key=>$basketItem) {?>
<div class="row personal__table table-personal<?if($key == 0 || $key%2==0):?> table-personal--gr<?endif?>">
<div class="col-6 table-personal__item">
<?=$basketItem->getField('NAME')?>
</div>
<div class="col-2 text-center table-personal__item">
<?=$basketItem->getPrice();?> руб.
</div>
<div class="col-2 text-center table-personal__item">
<?=$basketItem->getQuantity();?> шт.
</div>
<div class="col-2 text-center table-personal__item">
<?=$basketItem->getFinalPrice();?> руб.
</div>
</div>
<?}?>
</div>
</div>
</div>

<?}
?>

Возврат к списку