Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/boxberry.delivery/options/ |
Upload File : |
<?php use \Bitrix\Main\Config\Option; use Bitrix\Main\Context; use Boxberry\Bitrix\Helpers\Options; use Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); $bbStatuses = Options::getBbStatusesArray(); $bitrixStatuses = Options::getBitrixOrderStatuses(); $shipmentStatuses = Options::getBitrixShipmentStatuses(); $request = Context::getCurrent()->getRequest(); $postList = $request->getPostList(); if ($request->isAdminSection() && ($postList->get('save') || $postList->get('apply'))) { foreach ($bitrixStatuses as $bitrixStatusId => $bitrixStatusName) { Option::set(BB_MODULE_ID, $bitrixStatusId, $request->get($bitrixStatusId)); } $agentActive = $postList->get('STATUS_SYNC_ENABLE'); $agentInterval = $postList->get('STATUS_SYNC_AGENT_INTERVAL'); Option::set(BB_MODULE_ID, "STATUS_SYNC_ENABLE", $agentActive); Option::set(BB_MODULE_ID, "STATUS_SYNC_ORDERS_LIMIT", $postList->get('STATUS_SYNC_ORDERS_LIMIT')); Option::set(BB_MODULE_ID, "STATUS_SYNC_ORDERS_EXCLUDE_DAYS", $postList->get('STATUS_SYNC_ORDERS_EXCLUDE_DAYS')); Option::set(BB_MODULE_ID, "STATUS_SYNC_AGENT_INTERVAL", $agentInterval); Option::set(BB_MODULE_ID, "SET_ORDER_PAID_WHEN_DELIVERED", $postList->get('SET_ORDER_PAID_WHEN_DELIVERED')); foreach ($shipmentStatuses as $shipmentStatusId => $shipmentStatusName) { Option::set(BB_MODULE_ID, $shipmentStatusId, $request->get($shipmentStatusId)); Option::set(BB_MODULE_ID, $shipmentStatusId . "_shipped", $postList->get($shipmentStatusId . "_shipped") ?? 'N'); } $agentName = 'Boxberry\Bitrix\Agents\Tracking::syncStatuses();'; if ($agentActive == 'N') { CAgent::RemoveAgent($agentName, BB_MODULE_ID); } elseif ($agentActive == 'Y' && $agentInterval < 1) { CAgent::RemoveAgent($agentName, BB_MODULE_ID); } elseif ($agentActive == 'Y' && $agentInterval >= 1) { $res = CAgent::GetList($arOrder = array("ID" => "DESC"), $arFilter = array("NAME" => $agentName)); if ($arRes = $res->Fetch()) { CAgent::Update($arRes['ID'], array("AGENT_INTERVAL" => $agentInterval * 60)); } else { CAgent::AddAgent( $agentName, BB_MODULE_ID, "N", $agentInterval * 60, date('d.m.Y H:i:s', strtotime('now + 1 minute')), "Y", date('d.m.Y H:i:s', strtotime('now + 1 minute')), 30 ); } } } ?> <tr class="heading"> <td colspan="2"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_HEADER_NAME')?></td> </tr> <tr> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_ENABLE_NAME')?></td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <input type="hidden" name="STATUS_SYNC_ENABLE" value="N"> <label for="status_sync_enable"></label><input type="checkbox" value="Y" name="STATUS_SYNC_ENABLE" id="status_sync_enable" class="" <?php echo (Option::get(BB_MODULE_ID, "STATUS_SYNC_ENABLE", "N") == 'Y')? 'checked = "checked"' : ''?>> <span data-hint="<?php echo Loc::getMessage('SYNC_STATUSES_OPTION_HINT')?>"></span> </td> </tr> <tr class="heading"> <td colspan="2"><?php echo Loc::getMessage('SYNC_ORDER_STATUSES')?></td> </tr> <?php foreach ($bitrixStatuses as $bitrixStatusId => $bitrixStatusName): ?> <tr id="order_status_sync"> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo $bitrixStatusName ?> :</td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <label> <select name="<?php echo $bitrixStatusId ?>"> <?php foreach ($bbStatuses as $bbStatusId => $bbStatusName): ?> <option value="<?php echo $bbStatusId ?>" <?php echo (Option::get(BB_MODULE_ID, $bitrixStatusId, '') == $bbStatusId) ? 'selected' : ''; ?>><?php echo $bbStatusName ?></option> <?php endforeach; ?> </select> </label> </td> </tr> <?php endforeach; ?> <tr class="heading"> <td colspan="2"> <?php echo Loc::getMessage('SYNC_SHIPMENT_STATUSES')?> <span class="shipped-label"><?php echo Loc::getMessage('SHIPPED_FLAG_HEADER')?></span> </td> </tr> <?php foreach ($shipmentStatuses as $shipmentStatusId => $shipmentStatusName): ?> <tr id="shipment_status_sync"> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo $shipmentStatusName ?> :</td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <label for="<?php echo $shipmentStatusId ?>"> <select name="<?php echo $shipmentStatusId ?>" data-select-type="shipment_status"> <?php foreach ($bbStatuses as $bbStatusId => $bbStatusName): ?> <option value="<?php echo $bbStatusId ?>" <?php echo (Option::get(BB_MODULE_ID, $shipmentStatusId, '') == $bbStatusId) ? 'selected' : ''; ?>><?php echo $bbStatusName ?></option> <?php endforeach; ?> </select> </label> <label for="<?php echo $shipmentStatusId ?>_shipped"> <input type="checkbox" id="<?php echo $shipmentStatusId ?>_shipped" name="<?php echo $shipmentStatusId ?>_shipped" value="Y" class="shipped-checkbox" <?php echo (Option::get(BB_MODULE_ID, $shipmentStatusId . "_shipped", "N") == 'Y')? 'checked = "checked"' : ''?>> </label> </td> </tr> <?php endforeach; ?> <tr class="heading"> <td colspan="2"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_HEADER_NAME')?></td> </tr> <tr> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_ORDERS_NAME')?></td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <label> <input type="text" name="STATUS_SYNC_ORDERS_LIMIT" id="status_sync_orders_limit" size="10" value="<?php echo Option::get(BB_MODULE_ID, "STATUS_SYNC_ORDERS_LIMIT", '100')?>"> </label><span data-hint="<?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_ORDERS_HINT')?>"></span> </td> </tr> <tr> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_INTERVAL_NAME')?></td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <label> <input type="text" name="STATUS_SYNC_AGENT_INTERVAL" id="status_sync_agent_interval" size="10" value="<?php echo Option::get(BB_MODULE_ID, "STATUS_SYNC_AGENT_INTERVAL", '30')?>"> </label><span data-hint="<?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_INTERVAL_HINT')?>"></span> </td> </tr> <tr> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_EXCLUDE_NAME')?></td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <label> <input type="text" name="STATUS_SYNC_ORDERS_EXCLUDE_DAYS" id="status_sync_orders_exclude_days" size="10" value="<?php echo Option::get(BB_MODULE_ID, "STATUS_SYNC_ORDERS_EXCLUDE_DAYS", '60')?>"> </label><span data-hint="<?php echo Loc::getMessage('SYNC_STATUSES_OPTIONS_AGENT_EXCLUDE_HINT')?>"></span> </td> </tr> <tr class="heading"> <td colspan="2"><?php echo Loc::getMessage('SUCCESS_DELIVERY_ACTION')?></td> </tr> <tr> <td style="width: 50%;" class="adm-detail-content-cell-l"><?php echo Loc::getMessage('SET_ORDER_PAID_WHEN_DELIVERED')?></td> <td style="width: 50%;" class="adm-detail-content-cell-r"> <input type="hidden" name="SET_ORDER_PAID_WHEN_DELIVERED" value="N"> <label for="set_order_paid_when_delivered"></label><input type="checkbox" value="Y" name="SET_ORDER_PAID_WHEN_DELIVERED" id="set_order_paid_when_delivered" class="" <?php echo (Option::get(BB_MODULE_ID, "SET_ORDER_PAID_WHEN_DELIVERED", "N") == 'Y')? 'checked = "checked"' : ''?>> </td> </tr>