Exemple #1
0
 /**
  * (non-PHPdoc)
  *
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $dEndDate->addDay(1);
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate1', $dStartDate->toString("MM/d/yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('pDate2', $dEndDate->toString("MM/d/yyyy"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://www.auto-europe.co.uk/afftools/iatareport_popup.cfm?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $xmlTransactionList = self::readTransactions($exportReport[0]);
     foreach ($xmlTransactionList as $xmlTransaction) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $date = new Zend_date($xmlTransaction['Booked'], "MM/dd/yyyy");
         $transaction['date'] = $date->toString("yyyy-MM-dd 00:00:00");
         $transaction['amount'] = (double) $xmlTransaction['commissionValue'];
         $transaction['commission'] = (double) $xmlTransaction['commission'];
         $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $transaction['unique_id'] = $xmlTransaction['Res #'];
         if (isset($xmlTransaction['Affiliate1']) && isset($xmlTransaction['Affiliate2'])) {
             $customId = (string) $xmlTransaction['Affiliate1'] . (string) $xmlTransaction['Affiliate2'];
             $customId = "afal-" . current(unpack('H*', base64_decode(str_replace(array(".", "-"), array("/", "+"), $customId))));
             $transaction['custom_id'] = $customId;
         }
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
Exemple #2
0
 /**
  * Constructor and Login
  * @param $tradeDoubler
  * @return Oara_Network_Publisher_Td_Export
  */
 public function __construct($credentials)
 {
     $this->_credentials = $credentials;
     $user = $this->_credentials['user'];
     $password = $this->_credentials['password'];
     $loginUrl = 'https://member.impactradius.co.uk/secure/login.user';
     $valuesLogin = array(new Oara_Curl_Parameter('j_username', $user), new Oara_Curl_Parameter('j_password', $password));
     $credentials = $this->_credentials;
     $this->_newClient = new Oara_Curl_Access($loginUrl, $valuesLogin, $credentials);
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
     $exportReport = $this->_newClient->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('div .uitkFields');
     $count = count($results);
     if ($count == 0) {
         $activeAPI = array(new Oara_Curl_Parameter('_eventId', "activate"));
         $urls = array();
         $urls[] = new Oara_Curl_Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', $activeAPI);
         $exportReport = $this->_newClient->post($urls);
         $urls = array();
         $urls[] = new Oara_Curl_Request('https://member.impactradius.co.uk/secure/mediapartner/accountSettings/mp-wsapi-flow.ihtml?', array());
         $exportReport = $this->_newClient->get($urls);
         $dom = new Zend_Dom_Query($exportReport[0]);
         $results = $dom->query('div .uitkFields');
         $count = count($results);
         // get number of matches: 4
         if ($count == 0) {
             throw new Exception("No API credentials");
         }
     }
     $i = 0;
     foreach ($results as $result) {
         if ($i == 0) {
             $this->_accountSid = str_replace(array("\n", "\t", " "), "", $result->nodeValue);
         } else {
             if ($i == 1) {
                 $this->_authToken = str_replace(array("\n", "\t", " "), "", $result->nodeValue);
             }
         }
         $i++;
     }
 }
Exemple #3
0
 /**
  * Constructor and Login
  * @param $cartrawler
  * @return Oara_Network_Publisher_Tv_Export
  */
 public function __construct($credentials)
 {
     $user = $credentials['user'];
     $password = $credentials['password'];
     $loginUrl = 'http://book.terravision.eu/login_check?';
     $valuesLogin = array(new Oara_Curl_Parameter('_username', $user), new Oara_Curl_Parameter('_password', $password), new Oara_Curl_Parameter('_submit', 'Login'));
     $this->_client = new Oara_Curl_Access($loginUrl, $valuesLogin, $credentials);
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/login', array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('input[name="_csrf_token"]');
     $token = null;
     foreach ($results as $result) {
         $token = $result->getAttribute("value");
     }
     $valuesLogin = array(new Oara_Curl_Parameter('_username', $user), new Oara_Curl_Parameter('_password', $password), new Oara_Curl_Parameter('_submit', 'Login'), new Oara_Curl_Parameter('_csrf_token', $token));
     $urls = array();
     $urls[] = new Oara_Curl_Request($loginUrl, $valuesLogin);
     $exportReport = $this->_client->post($urls);
 }
Exemple #4
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $totalOverviews = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/stats', array());
     $exportReport = $this->_client->get($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('input[name="form[_token]"]');
     $token = null;
     foreach ($results as $result) {
         $token = $result->getAttribute("value");
     }
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('form[year]', $dStartDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('fform[_token]', $token);
     $valuesFormExport[] = new Oara_Curl_Parameter('show', 'Show');
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://book.terravision.eu/partner/my/stats?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $stringToFind = $dStartDate->toString("MM-yyyy");
     /*** load the html into the object ***/
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('.frame > table');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current()));
     $num = count($exportData);
     $transactionCounter = 0;
     $valueCounter = 0;
     $commissionCounter = 0;
     for ($i = 1; $i < $num - 1; $i++) {
         $transactionArray = str_getcsv($exportData[$i], ";");
         if ($transactionArray[0] == $stringToFind) {
             $transactionCounter = $transactionArray[12];
             $valueCounter += $transactionArray[14];
             $commissionCounter += $transactionArray[16];
         }
     }
     if ($transactionCounter > 0) {
         $dateList = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate);
         for ($i = 0; $i < count($dateList); $i++) {
             $transaction = array();
             $transaction['merchantId'] = 1;
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             $transaction['date'] = $dateList[$i]->toString("yyyy-MM-dd HH:mm:ss");
             $transaction['amount'] = $valueCounter / count($dateList);
             $transaction['commission'] = $commissionCounter / count($dateList);
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemple #5
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null)
 {
     $totalTransactions = array();
     $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
     $valuesFormExport[] = new Oara_Curl_Parameter('start_year', $dStartDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('start_month', $dStartDate->toString("M"));
     $valuesFormExport[] = new Oara_Curl_Parameter('start_day', $dStartDate->toString("d"));
     $valuesFormExport[] = new Oara_Curl_Parameter('end_year', $dEndDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('end_month', $dEndDate->toString("M"));
     $valuesFormExport[] = new Oara_Curl_Parameter('end_day', $dEndDate->toString("d"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://www.cartrawler.com/affengine/AFFxreservelist2.asp?action=update', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $exportTransactionList = self::readTransactionTable($exportReport[0], $dStartDate, $dEndDate);
     foreach ($exportTransactionList as $exportTransaction) {
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transactionDate = new Zend_Date($exportTransaction[1], "d MMM yy", 'en_US');
         $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
         $transaction['amount'] = (double) $exportTransaction[5];
         $transaction['commission'] = (double) $exportTransaction[11];
         if ($exportTransaction[8] == 'CONFIRMED') {
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         } else {
             if ($exportTransaction[8] == 'CANCELLED') {
                 $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
             } else {
                 if ($exportTransaction[8] == 'UNCONFIRMED' || $exportTransaction[8] == 'REBOOKED' || $exportTransaction[8] == 'PENDING INVOICE') {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     throw new Exception("New status found " . $transaction['status']);
                 }
             }
         }
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
Exemple #6
0
 /**
  * (non-PHPdoc)
  * @see Oara/Network/Oara_Network_Base#getCreatives()
  */
 public function getCreatives()
 {
     $creativesMap = array();
     $merchantList = self::getMerchantList();
     foreach ($merchantList as $merchant) {
         $websiteFirstId = null;
         $websiteMap = array();
         if (isset($this->_websitesList[$merchant['cid']])) {
             $websiteMap = $this->_websitesList[$merchant['cid']];
         }
         foreach ($websiteMap as $websiteid => $websiteName) {
             $websiteFirstId = $websiteid;
             break;
         }
         if ($websiteFirstId != null) {
             $urls = array();
             $valuesFormExport = Oara_Utilities::cloneArray($this->_exportCreativeParameters);
             $valuesFormExport[] = new Oara_Curl_Parameter('programGEListParameterTransport.siteId', $websiteFirstId);
             $valuesFormExport[] = new Oara_Curl_Parameter('programGEListParameterTransport.programIdOrName', $merchant['cid']);
             $urls[] = new Oara_Curl_Request('http://www.tradedoubler.com/pan/aGEList.action?', $valuesFormExport);
             $exportReport = $this->_client->post($urls);
             for ($i = 0; $i < count($exportReport); $i++) {
                 if (preg_match_all("/javascript: showCode\\((.+)?\\)/", $exportReport[$i], $matches)) {
                     foreach ($matches[1] as $parameters) {
                         $paramatersArray = explode(',', $parameters);
                         $programId = $paramatersArray[1];
                         $graphicalElementId = $paramatersArray[0];
                         $affiliateId = $paramatersArray[3];
                         if (is_numeric($programId) && is_numeric($graphicalElementId) && is_numeric($affiliateId)) {
                             /**
                             			    				$creativesMap[(string)$programId][] = "<script type=\"text/javascript\">
                             																	   var uri = 'http://impgb.tradedoubler.com/imp?type(img)g($graphicalElementId)a($affiliateId)' + new String (Math.random()).substring (2, 11);
                             																	   document.write('<a href=\"http://clkuk.tradedoubler.com/click?p=$programId&a=$affiliateId&g=$graphicalElementId\" target=\"_BLANK\"><img src=\"'+uri+'\" border=0></a>');
                             																	   </script>";
                             			    				
                             								$creativesMap[(string)$programId][] = "<script type=\"text/javascript\">
                             																	   var uri = 'http://impgb.tradedoubler.com/imp?type(iframe)g($graphicalElementId)a($affiliateId)' + new String (Math.random()).substring (2, 11);
                             																	   document.write('<iframe src=\"'+uri +'\" width=\"234\" height=\"60\" frameborder=\"0\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"></iframe>');
                             																	   </script>";
                             								**/
                             $creativesMap[(string) $programId][] = "<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   var uri = 'http://impgb.tradedoubler.com/imp?type(js)g({$graphicalElementId})a({$affiliateId})' + new String (Math.random()).substring (2, 11);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   document.write('<sc'+'ript type=\"text/javascript\" src=\"'+uri+'\" charset=\"\"></sc'+'ript>');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   </script>";
                         }
                     }
                 }
             }
         }
     }
     return $creativesMap;
 }
Exemple #7
0
 /**
  * Constructor and Login
  * @param $por
  * @return Oara_Network_Por_Api
  */
 public function __construct($credentials)
 {
     $user = $credentials['user'];
     $password = $credentials['password'];
     $this->_apiPassword = $credentials['apiPassword'];
     $loginUrl = 'https://secure.paidonresults.com/cgi-bin/affiliate-login/login.pl';
     $valuesLogin = array(new Oara_Curl_Parameter('username', $user), new Oara_Curl_Parameter('password', $password));
     $this->_client = new Oara_Curl_Access($loginUrl, $valuesLogin, $credentials);
     $valuesFormExport = array(new Oara_Curl_Parameter('username', $user), new Oara_Curl_Parameter('password', $password));
     $urls = array();
     $urls[] = new Oara_Curl_Request($loginUrl, $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     if (!preg_match("/session=(.*)\"/", $exportReport[0], $matches)) {
         throw new Exception("No session found");
     }
     $this->_sessionId = $matches[1];
     if (preg_match("/URL=(.*)\"/", $exportReport[0], $matches)) {
         $urls = array();
         $urls[] = new Oara_Curl_Request($matches[1], array());
         $exportReport = $this->_client->get($urls);
     }
     $this->_exportMerchantParameters = array(new Oara_Curl_Parameter('apikey', $this->_apiPassword), new Oara_Curl_Parameter('Format', 'CSV'), new Oara_Curl_Parameter('FieldSeparator', 'comma'), new Oara_Curl_Parameter('AffiliateID', $user), new Oara_Curl_Parameter('MerchantCategories', 'ALL'), new Oara_Curl_Parameter('Fields', 'MerchantID,MerchantName,MerchantURL'), new Oara_Curl_Parameter('JoinedMerchants', 'YES'), new Oara_Curl_Parameter('MerchantsNotJoined', 'NO'));
     $this->_exportTransactionParameters = array(new Oara_Curl_Parameter('apikey', $this->_apiPassword), new Oara_Curl_Parameter('Format', 'CSV'), new Oara_Curl_Parameter('FieldSeparator', 'comma'), new Oara_Curl_Parameter('AffiliateID', $user), new Oara_Curl_Parameter('Fields', 'MerchantID,OrderDate,HTTPReferal,CustomTrackingID,OrderValue,AffiliateCommission,TransactionType,CreativeName'), new Oara_Curl_Parameter('AffiliateID', $user), new Oara_Curl_Parameter('DateFormat', 'DD/MM/YYYY+HH:MN:SS'), new Oara_Curl_Parameter('PendingSales', 'YES'), new Oara_Curl_Parameter('ValidatedSales', 'YES'), new Oara_Curl_Parameter('VoidSales', 'YES'), new Oara_Curl_Parameter('GetNewSales', 'YES'));
 }
Exemple #8
0
 /**
  * It returns an array with the different merchants
  * @return array
  */
 private function getMerchantReportList()
 {
     $merchantReportList = array();
     $valuesFormExport = $this->_exportMerchantParameters;
     $valuesFormExport[] = new Oara_Curl_Parameter('programAffiliateStatusId', '3');
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://affiliates.wehkamp.nl/pan/aReport3Internal.action?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $exportReport[0] = self::checkReportError($exportReport[0], $urls[0]);
     $merchantReportList = self::getExportMerchantReport($exportReport[0]);
     $valuesFormExport = $this->_exportMerchantParameters;
     $valuesFormExport[] = new Oara_Curl_Parameter('programAffiliateStatusId', '4');
     $urls = array();
     $urls[] = new Oara_Curl_Request('https://affiliates.wehkamp.nl/pan/aReport3Internal.action?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $exportReport[0] = self::checkReportError($exportReport[0], $urls[0]);
     $merchantReportListAux = self::getExportMerchantReport($exportReport[0]);
     foreach ($merchantReportListAux as $key => $value) {
         $merchantReportList[$key] = $value;
     }
     return $merchantReportList;
 }
Exemple #9
0
 /**
  * Read the html table in the report
  * @param string $htmlReport
  * @param Zend_Date $startDate
  * @param Zend_Date $endDate
  * @param int $iteration
  * @return array:
  */
 public function readTransactionTable($startDate, $endDate)
 {
     $transactions = array();
     $valuesFormExport = array();
     $valuesFormExport[] = new Oara_Curl_Parameter('mese', $startDate->toString("MM"));
     $valuesFormExport[] = new Oara_Curl_Parameter('anno', $endDate->toString("yyyy"));
     $valuesFormExport[] = new Oara_Curl_Parameter('vai', '  Go  ');
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://booking.terravision.eu/statsales.asp?', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     /*** load the html into the object ***/
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->validateOnParse = true;
     $doc->loadHTML($exportReport[0]);
     $tableList = $doc->getElementsByTagName('table');
     $clickNumber = substr($tableList->item(6)->childNodes->item(0)->childNodes->item(2)->nodeValue, 0, -2);
     $transactionNumber = $tableList->item(6)->childNodes->item(2)->childNodes->item(2)->nodeValue;
     if ($transactionNumber != 0) {
         $totalAmout = 0;
         $totalCommission = 0;
         if ($tableList->item(10)->childNodes->item(3) != null) {
             $totalAmout = str_replace(',', '.', str_replace('.', '', substr($tableList->item(10)->childNodes->item(3)->childNodes->item(2)->nodeValue, 5)));
             $totalCommission = str_replace(',', '.', str_replace('.', '', substr($tableList->item(10)->childNodes->item(6)->childNodes->item(2)->nodeValue, 4)));
         }
         $amountPerTransaction = $totalAmout / $transactionNumber;
         $commissionPerTransaction = $totalCommission / $transactionNumber;
         for ($i = 0; $i < $transactionNumber; $i++) {
             $obj = new stdClass();
             $obj->date = $endDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj->amount = $amountPerTransaction;
             $obj->commission = $commissionPerTransaction;
             $transactions[] = $obj;
         }
     }
     return $transactions;
 }
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getMerchantList()
  */
 public function getMerchantList()
 {
     $merchants = array();
     $valuesFormExport = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://www' . $this->_serverNumber . '.netaffiliation.com/index.php/affiliate/statistics', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $results = $dom->query('#statistiquesGenerales_liste_programme optgroup');
     foreach ($results as $result) {
         $merchantLines = $result->childNodes;
         for ($i = 0; $i < $merchantLines->length; $i++) {
             $cid = $merchantLines->item($i)->attributes->getNamedItem("value")->nodeValue;
             $cid = str_replace("p", "", $cid);
             $obj = array();
             $name = $merchantLines->item($i)->nodeValue;
             $obj = array();
             $obj['cid'] = $cid;
             $obj['name'] = $name;
             $merchants[] = $obj;
         }
     }
     return $merchants;
 }
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $valuesFormExport = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://system.fashiontraffic.com/stats/lead_report', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $valuesFormExport = array();
     $hidden = $dom->query('#ConversionReportForm input[name="data[_Token][key]"][type="hidden"]');
     foreach ($hidden as $values) {
         $valuesFormExport[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $hidden = $dom->query('#ConversionReportForm input[name="data[_Token][fields]"][type="hidden"]');
     foreach ($hidden as $values) {
         $valuesFormExport[] = new Oara_Curl_Parameter($values->getAttribute("name"), $values->getAttribute("value"));
     }
     $valuesFormExport[] = new Oara_Curl_Parameter("_method", 'POST');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][page]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.offer_id');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.datetime');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.ad_id');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.source');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info1');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info2');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info3');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info4');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.affiliate_info5');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.conversion_payout');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][fields][]", 'Stat.conversion_status');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][search][field]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[Report][search][value]", '');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][timezone]", 'America/New_York');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][preset_date_range]", 'other');
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][start_date]", $dStartDate->toString("yyyy-MM-dd"));
     $valuesFormExport[] = new Oara_Curl_Parameter("data[DateRange][end_date]", $dEndDate->toString("yyyy-MM-dd"));
     $urls = array();
     $urls[] = new Oara_Curl_Request('http://system.fashiontraffic.com/stats/lead_report', $valuesFormExport);
     $exportReport = $this->_client->post($urls);
     $csvUrl = null;
     if (preg_match("/report:(.*).csv/", $exportReport[0], $match)) {
         $csvUrl = "http://system.fashiontraffic.com/stats/conversion_report/report:{$match[1]}.csv";
     }
     $valuesFormExport = array();
     $urls = array();
     $urls[] = new Oara_Curl_Request($csvUrl, $valuesFormExport);
     $exportReport = $this->_client->get($urls);
     $exportData = str_getcsv($exportReport[0], "\n");
     $num = count($exportData);
     for ($i = 1; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (in_array((int) $transactionExportArray[0], $merchantList)) {
             $transaction = array();
             $merchantId = (int) $transactionExportArray[0];
             $transaction['merchantId'] = $merchantId;
             $transaction['date'] = $transactionExportArray[1];
             if ($transactionExportArray[5] != null) {
                 $transaction['custom_id'] = $transactionExportArray[5];
             }
             if ($transactionExportArray[10] == 'approved') {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($transactionExportArray[10] == 'rejected') {
                     $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                 } else {
                     throw new Exception("Status {$transactionExportArray[10]} unknown");
                 }
             }
             if (preg_match('/[-+]?[0-9]*\\.?[0-9]+/', $transactionExportArray[9], $match)) {
                 $transaction['amount'] = (double) $match[0];
             }
             if (preg_match('/[-+]?[0-9]*\\.?[0-9]+/', $transactionExportArray[9], $match)) {
                 $transaction['commission'] = (double) $match[0];
             }
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Exemple #12
0
 private function readTransactionRef($csvExport, $dStartDate, $dEndDate)
 {
     $transactions = array();
     $transactionRef = array();
     $exportData = str_getcsv($csvExport, "\n");
     $num = count($exportData);
     for ($i = 3; $i < $num - 2; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ",");
         if (count($transactionExportArray) <= 1) {
             throw new Exception('Fail getting the transactions');
         }
         //to avoid the repeated transaction reference
         $transactionRef[$transactionExportArray[2]] = '';
     }
     $urls = array();
     foreach ($transactionRef as $ref => $nothing) {
         $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters);
         $valuesFormExport[] = new Oara_Curl_Parameter('startDayFilter', $dStartDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('startMonthFilter', $dStartDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('startYearFilter', $dStartDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endDayFilter', $dEndDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endMonthFilter', $dEndDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('endYearFilter', $dEndDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartDayFilter', $dStartDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartMonthFilter', $dStartDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origStartYearFilter', $dStartDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndDayFilter', $dEndDate->toString("d"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndMonthFilter', $dEndDate->toString("M"));
         $valuesFormExport[] = new Oara_Curl_Parameter('origEndYearFilter', $dEndDate->toString("yyyy"));
         $valuesFormExport[] = new Oara_Curl_Parameter('bookingRecord.idString', $ref);
         $urls[] = new Oara_Curl_Request('http://www.traveljigsawgroup.com/affiliates/AffiliateBookingRecord.do', $valuesFormExport);
     }
     if (count($urls) > 0) {
         $exportReport = $this->_client->post($urls);
         $num = count($exportReport);
         for ($z = 0; $z < $num; $z++) {
             $doc = new DOMDocument();
             libxml_use_internal_errors(true);
             $doc->validateOnParse = true;
             $doc->loadHTML($exportReport[$z]);
             $tableList = $doc->getElementsByTagName('table');
             $exportData1 = self::htmlToCsv(self::DOMinnerHTML($tableList->item(6)));
             $exportData3 = self::htmlToCsv(self::DOMinnerHTML($tableList->item(8)));
             $exportStatus = self::htmlToCsv(self::DOMinnerHTML($tableList->item(9)));
             $obj = array();
             $rowNum = count($exportData1);
             for ($i = 1; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportData1[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $rowNum = count($exportData3);
             for ($i = 1; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportData3[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $rowNum = count($exportStatus);
             for ($i = $rowNum - 2; $i < $rowNum - 1; $i++) {
                 $exportColumnData = str_getcsv($exportStatus[$i], ";");
                 $columnNum = count($exportColumnData);
                 for ($j = 0; $j < $columnNum; $j++) {
                     $obj[] = $exportColumnData[$j];
                 }
             }
             $transactions[] = $obj;
         }
     }
     return $transactions;
 }