1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
basefile.php
См. документацию.
1<?
2namespace Sale\Handlers\Delivery\Additional\DeliveryRequests\RusPost\Requests;
3
4use Bitrix\Main;
5use Bitrix\Main\Localization\Loc;
6use Bitrix\Sale\Delivery\Requests;
7
8Loc::loadMessages(__FILE__);
9
15abstract class BaseFile extends Base
16{
22 public function process(array $shipmentIds, array $additional = array())
23 {
24 $result = new Requests\ResultFile();
25
26 if(count($shipmentIds) !== 1)
27 {
28 $result->addError( new Main\Error(Loc::getMessage('SALE_DLVRS_ADD_DREQ_RBASEF_01')));
29 return $result;
30 }
31
32 $shipmentId = current($shipmentIds);
33
34 if(intval($shipmentId) <= 0)
35 {
36 $result->addError( new Main\Error(Loc::getMessage('SALE_DLVRS_ADD_DREQ_RBASEF_02')));
37 return $result;
38 }
39
40 $res = Requests\ShipmentTable::getList(array(
41 'filter' => array(
42 '=SHIPMENT_ID' => $shipmentId,
43 '=REQUEST.DELIVERY_ID' => $this->deliveryService->getId()
44 )
45 ));
46
47 $row = $res->fetch();
48
49 if(!$row || $row['EXTERNAL_ID'] == '')
50 {
51 $result->addError(
52 new Main\Error(
53 Loc::getMessage(
54 'SALE_DLVRS_ADD_DREQ_RBASEF_03',
55 array('#SHIPMENT_LINK#' => Requests\Helper::getShipmentEditLink($shipmentId))
56 )));
57
58 return $result;
59 }
60
61 $this->path = str_replace('{id}', $row['EXTERNAL_ID'], $this->path);
62 return $this->send();
63 }
64
70 public function send(array $requestData = array(), array $additional = array())
71 {
72 $result = new Requests\ResultFile();
73 $httpRes = false;
74
75 if(@$this->httpClient->query($this->type, $this->getUrl()))
76 $httpRes = $this->httpClient->getResult();
77
78 $errors = $this->httpClient->getError();
79
80 if (!$httpRes && !empty($errors))
81 {
82 $result = new Requests\Result();
83
84 foreach($errors as $errorCode => $errMes)
85 {
86 if($errMes == 'Socket connection error.')
87 {
88 $errMes = Loc::getMessage(
89 'SALE_DLVRS_ADD_DREQ_RBASE_SEND_ERROR',
90 array('#URL#' => $this->url)
91 );
92 }
93
94 $result->addError(new Main\Error($errMes, $errorCode));
95 }
96 }
97 else
98 {
99 $status = $this->httpClient->getStatus();
100
101 if ($status != 200)
102 {
103 if($status == 403)
104 $errorMsg = Loc::getMessage('SALE_DLVRS_ADD_DREQ_RBASEF_04');
105 elseif($status == 404)
106 $errorMsg = Loc::getMessage('SALE_DLVRS_ADD_DREQ_RBASEF_05');
107 elseif($status == 500)
108 $errorMsg = Loc::getMessage('SALE_DLVRS_ADD_DREQ_RBASEF_06');
109 else
110 $errorMsg = 'Http status: '.$status;
111
112 $result->addError(new Main\Error($errorMsg,'STATUS_'.$status));
113 }
114 }
115
116 if($result->isSuccess())
117 {
118 $headers = $this->httpClient->getHeaders();
119 $fileName = $headers->getFilename();
120
121 if($fileName <> '')
122 {
123 $ext = '';
124 $contentType = $headers->getContentType();
125
126 if($contentType == 'application/zip')
127 {
128 $ext = 'zip';
129 }
130 elseif($contentType == 'application/pdf')
131 {
132 $ext = 'pdf';
133 }
134
135 if($ext <> '')
136 {
137 $fileName .= '.'.$ext;
138 }
139
140 $result->setFileName($fileName);
141 $result->setFileContent($httpRes);
142 }
143 }
144
145 return $result;
146 }
147}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
Определения cron_frame.php:23
$status
Определения session.php:10
if(!function_exists(__NAMESPACE__.'\\___972068685'))
Определения license.php:1
trait Error
Определения error.php:11
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$fileName
Определения quickway.php:305
$contentType
Определения quickway.php:301
$errorMsg
Определения refund.php:16
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
path
Определения template_copy.php:201