- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/notify.php
- Класс: BitrixSaleNotify
- Вызов: Notify::sendShipmentAllowDelivery
static function sendShipmentAllowDelivery(InternalsEntity $entity)
{
$result = new Result();
if (static::isNotifyDisabled())
{
return $result;
}
if (!$entity instanceof Shipment)
{
throw new MainArgumentTypeException('entity', 'BitrixSaleShipment');
}
if (static::hasSentEvent('s'.$entity->getId(), static::EVENT_SHIPMENT_DELIVER_SEND_EMAIL_EVENT_NAME))
{
return $result;
}
/** @var ShipmentCollection $shipmentCollection */
if (!$shipmentCollection = $entity->getCollection())
{
$result->addError(new ResultError(MainLocalizationLoc::getMessage("SALE_NOTIFY_SHIPMENT_COLLECTION_NOT_FOUND")));
return $result;
}
/** @var Order $order */
if (!$order = $shipmentCollection->getOrder())
{
$result->addError(new ResultError(MainLocalizationLoc::getMessage("SALE_NOTIFY_ORDER_NOT_FOUND")));
return $result;
}
if (!$order->isAllowDelivery())
{
return $result;
}
$fields = Array(
"ORDER_ID" => $order->getField("ACCOUNT_NUMBER"),
"ORDER_REAL_ID" => $order->getField("ID"),
"ORDER_ACCOUNT_NUMBER_ENCODE" => urlencode(urlencode($order->getField("ACCOUNT_NUMBER"))),
"ORDER_DATE" => $order->getDateInsert()->toString(),
"SHIPMENT_ID" => $entity->getId(),
"SHIPMENT_DATE" => $entity->getField("DATE_INSERT")->toString(),
"EMAIL" => static::getUserEmail($order),
"SALE_EMAIL" => MainConfigOption::get("sale", "order_email", "order@".$_SERVER["SERVER_NAME"]),
"ORDER_PUBLIC_URL" => HelpersOrder::isAllowGuestView($order) ? HelpersOrder::getPublicLink($order) : ""
);
$eventName = static::EVENT_SHIPMENT_DELIVER_SEND_EMAIL_EVENT_NAME;
$send = true;
foreach(GetModuleEvents("sale", static::EVENT_ON_SHIPMENT_DELIVER_SEND_EMAIL, true) as $oldEvent)
{
if (ExecuteModuleEventEx($oldEvent, array($order->getId(), &$eventName, &$fields)) === false)
{
$send = false;
}
}
if($send)
{
$event = new CEvent;
$event->Send($eventName, $order->getField('LID'), $fields, "Y", "", array(), static::getOrderLanguageId($order));
}
CSaleMobileOrderPush::send(static::EVENT_MOBILE_PUSH_SHIPMENT_ALLOW_DELIVERY, array("ORDER" => static::getOrderFields($order)));
static::addSentEvent('s'.$entity->getId(), static::EVENT_SHIPMENT_DELIVER_SEND_EMAIL_EVENT_NAME);
return $result;
}