1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
regsoft.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 Regsoft 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
22function CleanUpCsv(&$item)
23{
24 $item = trim($item, "\"");
25}
26
27function PrepareQuotes(&$item)
28{
29 $item = "\"".str_replace("\"","\"\"", $item)."\"";
30}
31
32if ($fp_in = fopen($INPUT_CSV_FILE,"rb"))
33{
34 $upload_dir = $_SERVER["DOCUMENT_ROOT"]."/".COption::GetOptionString("main","upload_dir","/upload/"). "/statistic";
35 if (mb_substr($OUTPUT_CSV_FILE, 0, mb_strlen($upload_dir)) == $upload_dir && $fp_out = fopen($OUTPUT_CSV_FILE,"wb"))
36 {
37 $i = 0; // counter of the read valuable lines
38 $j = 0; // counter of the written to the resulting file lines
39 $lang_date_format = FORMAT_DATE; // date format for the current language
40 $event1 = "regsoft";
41 $event2 = "buy";
42 $EVENT_ID = CStatEventType::ConditionSet($event1, $event2, $arEventType)." (".$event1." / ".$event2.")";
43 $SITE_ID = GetEventSiteID(); // short site identifier (ID)
44 while (!feof($fp_in))
45 {
46 $arrCSV = fgetcsv($fp_in, 4096, $SEPARATOR);
47 if (is_array($arrCSV) && count($arrCSV)>1)
48 {
49 array_walk($arrCSV, "CleanUpCsv");
50 reset($arrCSV);
51 $i++;
52 // if it is the first line then
53 if ($arrCSV[0]=="Tracking ID")
54 {
55 // get an array with the field numbers
56 $arrS = array_flip($arrCSV);
57 }
58 elseif ($arrCSV[0]!="Tracking ID" && is_array($arrS) && count($arrS)>0) // else form the CSV line in module format and write it to the resulting file
59 {
60 $arrRes = array();
61
62 // ID of an event type;
63 $arrRes[] = $EVENT_ID;
64
65 // event3
66 $arrRes[] = $arrCSV[$arrS["Order ID"]]." / ".$arrCSV[$arrS["Product ID"]]." / ".$arrCSV[$arrS["Tracking ID"]];
67
68 // date
69 $arrRes[] = $DB->FormatDate(trim($arrCSV[$arrS["Order Date"]]), "MM/DD/YYYY", $lang_date_format);
70
71 // additional parameter
72 $ADDITIONAL_PARAMETER = $arrCSV[$arrS["Reseller ID"]];
73 $arrRes[] = $ADDITIONAL_PARAMETER;
74
75 // money sum
76 $arrRes[] = $arrCSV[$arrS["Total"]];
77
78 // currency
79 $arrRes[] = "USD";
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
101Column headers:
102
103Tracking ID | Order ID | Product ID | Country | Qty | E-Mail | Customer Name | Company Name | Address 1 | Address 2 | Address 3 | City | State | Zip | Order Date | Phone Number | Total | CD Purchase | Reseller ID | Order IP | Serial Number | Order Referrer | Price Code |
104
105*/
106?>
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_DATE
Определения include.php:63
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
PrepareQuotes(&$item)
Определения regsoft.php:27
CleanUpCsv(&$item)
Определения regsoft.php:22
$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
GetEventSiteID()
Определения stat_tools.php:544
$SITE_ID
Определения yandex_run.php:607