1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
csv.php
См. документацию.
1<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
2
4
5if (!isset($arFilter) || !is_array($arFilter))
6 die("Wrong use 1");
7if (!isset($arSelectFields) || !is_array($arSelectFields))
8 die("Wrong use 2");
9
11
12
14 'filter' => $arFilter,
15 'select' => $arSelectFields,
16 'runtime' => $runtimeFields
17);
18
19if (!empty($by))
20{
21 $order = (!empty($order) && $order == "DESC" ? "DESC" : "ASC");
22 $filter['order'] = array($by => $order);
23}
24
25$dbOrderList = \Bitrix\Sale\Internals\OrderTable::getList($filter);
26ob_start();
27
28for ($i = 0, $max = count($arShownFieldsParams); $i < $max; $i++)
29{
30 switch ($arShownFieldsParams[$i]["KEY"])
31 {
32 case "ID":
33 echo "\"".str_replace("\"", "\"\"", $arShownFieldsParams[$i]["COLUMN_NAME"])."\",";
34 echo "\"".str_replace("\"", "\"\"", GetMessage("SEXC_ORDER_DATE"))."\"";
35 break;
36 case "PAYED":
37 echo "\"".str_replace("\"", "\"\"", $arShownFieldsParams[$i]["COLUMN_NAME"])."\",";
38 echo "\"".str_replace("\"", "\"\"", GetMessage("SEXC_PAY_DATE"))."\"";
39 break;
40 default:
41 echo "\"".str_replace("\"", "\"\"", $arShownFieldsParams[$i]["COLUMN_NAME"])."\"";
42 break;
43 }
44
45 if ($i < count($arShownFieldsParams) - 1)
47}
48echo "\n";
49
50while ($arOrder = $dbOrderList->fetch())
51{
52 for ($i = 0, $max = count($arShownFieldsParams); $i < $max; $i++)
53 {
54 switch ($arShownFieldsParams[$i]["KEY"])
55 {
56 case "ID":
57 echo "\"".str_replace("\"", "\"\"", $arOrder["ID"])."\"".$fieldsSeparator;
58 echo "\"".str_replace("\"", "\"\"", $arOrder["DATE_INSERT"])."\"";
59 break;
60 case "LID":
61 if (!isset($LOCAL_SITE_LIST_CACHE[$arOrder["LID"]])
62 || !is_array($LOCAL_SITE_LIST_CACHE[$arOrder["LID"]]))
63 {
64 $dbSite = CSite::GetByID($arOrder["LID"]);
65 if ($arSite = $dbSite->Fetch())
66 $LOCAL_SITE_LIST_CACHE[$arOrder["LID"]] = htmlspecialcharsEx($arSite["NAME"]);
67 }
68 $printValue = "[".$arOrder["LID"]."] ".$LOCAL_SITE_LIST_CACHE[$arOrder["LID"]];
69 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
70 break;
71 case "PERSON_TYPE":
72 if (!isset($LOCAL_PERSON_TYPE_CACHE[$arOrder["PERSON_TYPE_ID"]])
73 || !is_array($LOCAL_PERSON_TYPE_CACHE[$arOrder["PERSON_TYPE_ID"]]))
74 {
75 if ($arPersonType = CSalePersonType::GetByID($arOrder["PERSON_TYPE_ID"]))
76 $LOCAL_PERSON_TYPE_CACHE[$arOrder["PERSON_TYPE_ID"]] = htmlspecialcharsEx($arPersonType["NAME"]);
77 }
78 $printValue = "[".$arOrder["PERSON_TYPE_ID"]."] ".$LOCAL_PERSON_TYPE_CACHE[$arOrder["PERSON_TYPE_ID"]];
79 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
80 break;
81 case "PAYED":
82 echo "\"".str_replace("\"", "\"\"", (($arOrder["PAYED"] == "Y") ? GetMessage("SEXC_YES") : GetMessage("SEXC_NO")))."\"".$fieldsSeparator;
83 echo "\"".str_replace("\"", "\"\"", $arOrder["DATE_PAYED"])."\"";
84 break;
85 case "CANCELED":
86 $printValue = (($arOrder["CANCELED"] == "Y") ? GetMessage("SEXC_YES") : GetMessage("SEXC_NO"))." ";
87 $printValue .= $arOrder["DATE_CANCELED"];
88 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
89 break;
90 case "STATUS":
91 if (!isset($LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]])
92 || !is_array($LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]]))
93 {
94 if ($arStatus = CSaleStatus::GetByID($arOrder["STATUS_ID"]))
95 $LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]] = htmlspecialcharsEx($arStatus["NAME"]);
96 }
97
98 $printValue = "[".$arOrder["STATUS_ID"]."] ".$LOCAL_STATUS_CACHE[$arOrder["STATUS_ID"]]." ";
99 $printValue .= $arOrder["DATE_STATUS"];
100 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
101 break;
102 case "PAY_VOUCHER_NUM":
103 echo "\"".str_replace("\"", "\"\"", $arOrder["PAY_VOUCHER_NUM"])."\"";
104 break;
105 case "PAY_VOUCHER_DATE":
106 echo "\"".str_replace("\"", "\"\"", $arOrder["PAY_VOUCHER_DATE"])."\"";
107 break;
108 case "DELIVERY_DOC_NUM":
109 echo "\"".str_replace("\"", "\"\"", $arOrder["DELIVERY_DOC_NUM"])."\"";
110 break;
111 case "DELIVERY_DOC_DATE":
112 echo "\"".str_replace("\"", "\"\"", $arOrder["DELIVERY_DOC_DATE"])."\"";
113 break;
114 case "PRICE_DELIVERY":
115 $printValue = SaleFormatCurrency($arOrder["PRICE_DELIVERY"], $arOrder["CURRENCY"]);
116 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
117 break;
118 case "ALLOW_DELIVERY":
119 $printValue = (($arOrder["ALLOW_DELIVERY"] == "Y") ? GetMessage("SEXC_YES") : GetMessage("SEXC_NO"))." ";
120 $printValue .= $arOrder["DATE_ALLOW_DELIVERY"];
121 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
122 break;
123 case "PRICE":
124 $printValue = SaleFormatCurrency($arOrder["PRICE"], $arOrder["CURRENCY"]);
125 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
126 break;
127 case "SUM_PAID":
128 $printValue = SaleFormatCurrency($arOrder["SUM_PAID"], $arOrder["CURRENCY"]);
129 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
130 break;
131 case "USER":
132 if (!isset($LOCAL_PAYED_USER_CACHE[$arOrder["USER_ID"]])
133 || !is_array($LOCAL_PAYED_USER_CACHE[$arOrder["USER_ID"]]))
134 {
135 $dbUser = CUser::GetByID($arOrder["USER_ID"]);
136 if ($arUser = $dbUser->Fetch())
137 $LOCAL_PAYED_USER_CACHE[$arOrder["USER_ID"]] = htmlspecialcharsEx($arUser["NAME"].(($arUser["NAME"] == '' || $arUser["LAST_NAME"] == '') ? "" : " ").$arUser["LAST_NAME"]." (".$arUser["LOGIN"].")");
138 }
139 $printValue = "[".$arOrder["USER_ID"]."] ".$LOCAL_PAYED_USER_CACHE[$arOrder["USER_ID"]];
140 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
141 break;
142 case "PAY_SYSTEM":
143 if (intval($arOrder["PAY_SYSTEM_ID"]) > 0)
144 {
145 if (!isset($LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]])
146 || !is_array($LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]]))
147 {
148 if ($arPaySys = CSalePaySystem::GetByID($arOrder["PAY_SYSTEM_ID"]))
149 $LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]] = htmlspecialcharsEx($arPaySys["NAME"]);
150 }
151
152 $printValue = "[".$arOrder["PAY_SYSTEM_ID"]."] ".$LOCAL_PAY_SYSTEM_CACHE[$arOrder["PAY_SYSTEM_ID"]];
153 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
154 }
155 break;
156 case "DELIVERY":
157 if (intval($arOrder["DELIVERY_ID"]) > 0)
158 {
159 if (!isset($LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]])
160 || !is_array($LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]]))
161 {
162 if ($arDelivery = CSaleDelivery::GetByID($arOrder["DELIVERY_ID"]))
163 $LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]] = htmlspecialcharsEx($arDelivery["NAME"]);
164 }
165
166 $printValue = "[".$arOrder["DELIVERY_ID"]."] ".$LOCAL_DELIVERY_CACHE[$arOrder["DELIVERY_ID"]];
167 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
168 }
169 break;
170 case "DATE_UPDATE":
171 echo "\"".str_replace("\"", "\"\"", $arOrder["DATE_UPDATE"])."\"";
172 break;
173 case "PS_STATUS":
174 if ($arOrder["PS_STATUS"] == "Y")
175 $printValue = GetMessage("SEXC_SUCCESS")." ".$arOrder["PS_RESPONSE_DATE"];
176 elseif ($arOrder["PS_STATUS"] == "N")
177 $printValue = GetMessage("SEXC_UNSUCCESS")." ".$arOrder["PS_RESPONSE_DATE"];
178 else
179 $printValue = GetMessage("SEXC_NONE");
180 break;
181 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
182 case "PS_SUM":
183 $printValue = SaleFormatCurrency($arOrder["PS_SUM"], $arOrder["PS_CURRENCY"]);
184 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
185 break;
186 case "TAX_VALUE":
187 $printValue = SaleFormatCurrency($arOrder["TAX_VALUE"], $arOrder["CURRENCY"]);
188 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
189 break;
190 case "BASKET":
191 $printValue = "";
192 $bNeedLine = False;
193 $dbItemsList = CSaleBasket::GetList(
194 array("NAME" => "ASC"),
195 array("ORDER_ID" => $arOrder["ID"])
196 );
197 while ($arItem = $dbItemsList->Fetch())
198 {
199 if ($bNeedLine)
200 $printValue .= "\n";
201 $bNeedLine = True;
202
203 $printValue .= "[".$arItem["PRODUCT_ID"]."] ";
204 $printValue .= $arItem["NAME"];
205 $printValue .= " (".$arItem["QUANTITY"].GetMessage("SEXC_SHT");
206 }
207 echo "\"".str_replace("\"", "\"\"", $printValue)."\"";
208 break;
209 }
210
211 if ($i < count($arShownFieldsParams) - 1)
212 echo $fieldsSeparator;
213 }
214 echo "\n";
215}
216
217$content = ob_get_contents();
218ob_end_clean();
219
220header('Pragma: public');
221header('Cache-control: private');
222header('Accept-Ranges: bytes');
223header('Content-Length: '.mb_strlen($content));
224header("Content-Type: application/force-download");
225header('Content-Disposition: attachment; filename=data.csv');
226
227
228echo $content;
229
230?>
static GetByID($ID)
Определения delivery.php:249
static GetByID($id, $personTypeId=0)
Определения pay_system.php:82
static GetByID($ID)
Определения person_type.php:69
static GetByID($ID)
Определения site.php:749
static GetByID($ID)
Определения user.php:3820
Определения basket.php:8
static GetByID($statusId, $languageId=LANGUAGE_ID, $type=null)
Определения status.php:23
if(!empty($by)) $dbOrderList
Определения commerceml.php:40
while( $arBasket=$dbBasket->Fetch())
Определения commerceml.php:73
$content
Определения commerceml.php:144
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$filter
Определения iblock_catalog_list.php:54
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
Определения cron_frame.php:23
htmlspecialcharsEx($str)
Определения tools.php:2685
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$order
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
die
Определения quickway.php:367
$i
Определения factura.php:643
</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
$fieldsSeparator
Определения csv.php:10
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
Определения include.php:142
$max
Определения template_copy.php:262
$arFilter
Определения user_search.php:106
switch( $_REQUEST[ 'bxsender'])().Authorize(<? break
Определения wrapper_popup.php:7