1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
shareit_usd.php
См. документацию.
1<?
2if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
3
4$STAT_RIGHT = $APPLICATION->GetGroupRight("statistic");
5if($STAT_RIGHT=="D") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
6
7/***************************************************************************
8Convertation of the standard ShareIt CSV file to the
9CSV file format of the Statistics module.
10
11Currency: USD
12***************************************************************************/
13
14/*
15 Input parameters:
16 INPUT_CSV_FILE - path to the source file
17 OUTPUT_CSV_FILE - path to the resulting file
18*/
19
20$SEPARATOR = ","; // CSV separator
21$CURRENCY = "USD"; // Currency
22
23function CleanUpCsv(&$item)
24{
25 $item = trim($item, "\"");
26}
27
28function PrepareQuotes(&$item)
29{
30 $item = "\"".str_replace("\"","\"\"", $item)."\"";
31}
32
33if ($fp_in = fopen($INPUT_CSV_FILE,"rb"))
34{
35 $upload_dir = rtrim($_SERVER["DOCUMENT_ROOT"], "/")."/".COption::GetOptionString("main","upload_dir","/upload/"). "/statistic";
36 if (mb_substr($OUTPUT_CSV_FILE, 0, mb_strlen($upload_dir)) == $upload_dir && $fp_out = fopen($OUTPUT_CSV_FILE,"wb"))
37 {
38 $i = 0; // counter of the read valuable lines
39 $j = 0; // counter of the written to the resulting file lines
40 $lang_date_format = FORMAT_DATETIME; // date format for the current language
41 $event1 = "shareit";
42 $event2 = "buy";
43 $EVENT_ID = CStatEventType::ConditionSet($event1, $event2, $arEventType)." (".$event1." / ".$event2.")";
44 $SITE_ID = GetEventSiteID(); // short site identifier (ID)
45 while (!feof($fp_in))
46 {
47 $arrCSV = fgetcsv($fp_in, 4096, $SEPARATOR);
48 if (is_array($arrCSV) && count($arrCSV)>1)
49 {
50 array_walk($arrCSV, "CleanUpCsv");
51 reset($arrCSV);
52 $i++;
53 // if it is the first line then
54 if ($arrCSV[0]=="PADATE")
55 {
56 // get an array with the field numbers
57 $arrS = array_flip($arrCSV);
58 }
59 elseif ($arrCSV[0]!="PADATE" && is_array($arrS) && count($arrS)>0) // else form the CSV line in module format and write it to the resulting file
60 {
61 $arrRes = array();
62
63 // ID of an event type;
64 $arrRes[] = $EVENT_ID;
65
66 // event3
67 $arrRes[] = $arrCSV[$arrS["PURCHASEID"]]." / ".$arrCSV[$arrS["PRODUCTID"]];
68
69 // date
70 $arrRes[] = $DB->FormatDate(trim($arrCSV[$arrS["TDATE"]]), "MM/DD/YYYY HH:MI:SS", $lang_date_format);
71
72 // additional parameter
73 $ADDITIONAL_PARAMETER = $arrCSV[$arrS["ADDITIONAL1"]];
74 $arrRes[] = $ADDITIONAL_PARAMETER;
75
76 // money sum
77 $arrRes[] = $arrCSV[$arrS["TOTAL"]];
78
79 // currency
80 //$arrRes[] = $arrCSV[$arrS["CURRENCY"]];
81 $arrRes[] = $CURRENCY;
82
83 // if short site identifier exists in Additional parameter then
84 if (mb_strpos($ADDITIONAL_PARAMETER, $SITE_ID) !== false)
85 {
86 // write the line to the resulting CSV file
87 $j++;
88 array_walk($arrRes, "PrepareQuotes");
89 $str = implode(",",$arrRes);
90 if ($j>1) $str = "\n".$str;
91 fputs($fp_out, $str);
92 }
93 }
94 }
95 }
96 @fclose($fp_out);
97 }
98 @fclose($fp_in);
99}
100
101/*
102
103Description of column headers:
104
105PADATE Date on which the order was paid
106TDATE Date on which the order was paid (including time)
107DESCRIPTION Description of the order, for example 'Order', 'Refund', etc.
108SETTLED Dummy field (for compatibility reasons)
109PAYMENTTYPE Type of payment
110 Payment methods available:
111 CAS Cash
112 CHK Check
113 WTR Bank transfer
114 CCA Credit card
115 DBC Debit Card
116 INV Purchase order
117 INH Purchase order requiring approval
118 SBX Online wire transfer (in Germany only)
119 NPN No payment required
120REFNUM Your reference number
121LASTNAME Customer's last name
122FIRSTNAME Customer's first name
123COMPANY Company name
124STREET Customer's address: Street
125CITY Customer's address: City
126ZIP Customer's address: Zip / Postal Code
127STATE Customer's address: State/Province (for USA & Canada)
128COUNTRY Customer's address: Country
129EMAIL Customer's e-mail address
130PHONE Customer's phone number
131FAX Customer's fax number
132PRODUCTID ID of the product sold
133PRODUCTNAME Name of the product sold
134NUMLICENSE Number of licenses sold
135SINGLEPRICE Unit price
136VAT The we collected for you
137SHIPPING Shipping fees we collected for you
138CURRENCY Currency of this transaction
139TOTAL The total price for this order
140PURCHASEID Purchase ID of this order
141VATID Customer's ID
142KEY License key (optional)
143RESELLER ID of the reseller/key account
144REG_NAME The product is licensed to
145SALUTATION Salutation
146TITLE Title
147ADDITIONAL1 Additional field 1
148ADDITIONAL2 Additional field 2
149DISCOUNT Customer's discount
150COUPONCODE Coupon code
151PROMOTIONID Promotion ID
152PUBLISHERS_PRODUCT_ID Product ID (in your inventory management system)
153EAN_CODE EAN
154RUNNING_NO Position of this item in the shopping cart.
155LANGUAGE Language of the customer
156
157*/
158?>
global $APPLICATION
Определения include.php:80
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
Определения option.php:8
static ConditionSet($event1, $event2, &$arEventType)
Определения stateventtype.php:106
$str
Определения commerceml2.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
const FORMAT_DATETIME
Определения include.php:64
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$SEPARATOR
Определения plimus.php:18
$STAT_RIGHT
Определения plimus.php:4
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
$CURRENCY
Определения result.php:6
PrepareQuotes(&$item)
Определения shareit_usd.php:28
CleanUpCsv(&$item)
Определения shareit_usd.php:23
GetEventSiteID()
Определения stat_tools.php:544
$SITE_ID
Определения yandex_run.php:607