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