/** * (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; }
/** * (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; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00%24m_mainPlaceholder%24m_periodFromField_hidden', "%3CDateChooser%20Value%3D%22" . $dStartDate->toString("yyyy") . "x" . $dStartDate->toString("M") . "x" . $dStartDate->toString("d") . "%22%3E%3C/DateChooser%3E"); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00xmxmainPlaceholderxmxperiodFromField_input', $dStartDate->toString("dd/MM/yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00_m_mainPlaceholder_m_periodFromField_DrpPnl_Calendar1', "%3Cx%20PostData%3D%22" . $dStartDate->toString("yyyy") . "x" . $dStartDate->toString("M") . "x" . $dStartDate->toString("yyyy") . "x" . $dStartDate->toString("M") . "x" . $dStartDate->toString("d") . "%22%3E%3C/x%3E"); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00%24m_mainPlaceholder%24m_periodToField_hidden', "%3CDateChooser%20Value%3D%22" . $dEndDate->toString("yyyy") . "x" . $dEndDate->toString("M") . "x" . $dEndDate->toString("d") . "%22%3E%3C/DateChooser%3E"); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00xmxmainPlaceholderxmxperiodToField_input', $dEndDate->toString("dd/MM/yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('ctl00_m_mainPlaceholder_m_periodToField_DrpPnl_Calendar1', "%3Cx%20PostData%3D%22" . $dEndDate->toString("yyyy") . "x" . $dEndDate->toString("M") . "x" . $dEndDate->toString("yyyy") . "x" . $dEndDate->toString("M") . "x" . $dEndDate->toString("d") . "%22%3E%3C/x%3E"); $urls = array(); $urls[] = new Oara_Curl_Request('https://www.bet365affiliates.com/Members/Members/Statistics/Default.aspx', array()); $exportReport = $this->_client->get($urls); $forbiddenList = array('ctl00$m_mainPlaceholder$m_periodFromField_hidden', 'ctl00_m_mainPlaceholder_m_periodFromField_DrpPnl_Calendar1', 'ctl00$m_mainPlaceholder$m_periodToField_hidden', 'ctl00_m_mainPlaceholder_m_periodToField_DrpPnl_Calendar1'); $dom = new Zend_Dom_Query($exportReport[0]); $hiddenList = $dom->query('input[type="hidden"]'); foreach ($hiddenList as $hidden) { if (!in_array($hidden->getAttribute("name"), $forbiddenList)) { $valuesFromExport[] = new Oara_Curl_Parameter($hidden->getAttribute("name"), $hidden->getAttribute("value")); } } $urls = array(); $urls[] = new Oara_Curl_Request('https://www.bet365affiliates.com/Members/Members/Statistics/Default.aspx', $valuesFromExport); $exportReport = $this->_client->post($urls); $dom = new Zend_Dom_Query($exportReport[0]); $tableList = $dom->query('table'); $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current())); $num = count($exportData); for ($i = 2; $i < $num - 1; $i++) { $overviewExportArray = str_getcsv($exportData[$i], ";"); $overview = array(); $overview['merchantId'] = 1; $overviewDate = new Zend_Date($overviewExportArray[1], 'dd-MM-yyyy', 'en'); $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $overview['click_number'] = (int) $overviewExportArray[2]; $overview['impression_number'] = 0; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($overview)) { $overviewArray[] = $overview; } } return $overviewArray; }
/** * (non-PHPdoc) * @see Oara/Network/Oara_Network_Base#getPaymentHistory() */ public function getPaymentHistory() { $paymentHistory = array(); $valuesFromExport = $this->_exportPaymentParameters; $urls = array(); $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', array()); $exportReport = $this->_client->get($urls); /*** load the html into the object ***/ $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->validateOnParse = true; $doc->loadHTML($exportReport[0]); $hiddenList = $doc->getElementsByTagName('input'); for ($i = 0; $i < $hiddenList->length; $i++) { $attrs = $hiddenList->item($i)->attributes; if ($attrs->getNamedItem("type")->nodeValue == 'hidden') { //we are adding the hidden parameters $valuesFromExport[] = new Oara_Curl_Parameter($attrs->getNamedItem("name")->nodeValue, $attrs->getNamedItem("value")->nodeValue); } } $yearSelect = $doc->getElementById('ctl00_ContentPlaceHolder1_ddlYear')->childNodes; $yearStart = (int) $yearSelect->item($yearSelect->length - 1)->attributes->getNamedItem("value")->nodeValue; $nowDays = new Zend_Date(); $yearEnd = (int) $nowDays->get(Zend_Date::YEAR); $urls = array(); for ($i = $yearStart; $i <= $yearEnd; $i++) { $requestValuesFromExport = Oara_Utilities::cloneArray($valuesFromExport); $requestValuesFromExport[] = new Oara_Curl_Parameter('ctl00$ContentPlaceHolder1$ddlYear', (string) $i); $urls[] = new Oara_Curl_Request('https://admin.omgpm.com/v2/finance/affiliate/view_payments.aspx?', $requestValuesFromExport); } $exportReport = $this->_client->post($urls); for ($i = 0; $i < count($exportReport); $i++) { if (!preg_match("/No Results for this criteria/i", $exportReport[$i])) { $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->validateOnParse = true; $doc->loadHTML($exportReport[$i]); $table = $doc->getElementById('ctl00_ContentPlaceHolder1_gvSummary'); $paymentList = $table->childNodes; for ($j = 1; $j < $paymentList->length; $j++) { $paymentData = $paymentList->item($j)->childNodes; $obj = array(); $obj['value'] = Oara_Utilities::parseDouble($paymentData->item(5)->nodeValue); if ($obj['value'] != null) { $date = new Zend_date($paymentData->item(8)->nodeValue, "dd/MM/yyyy HH:mm:ss"); $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss"); $obj['pid'] = $paymentData->item(2)->nodeValue; $ass = $paymentData->item(5)->nodeValue; $obj['method'] = 'BACS'; $paymentHistory[] = $obj; } } } } return $paymentHistory; }
/** * (non-PHPdoc) * @see Oara_Network::getTransactionList() */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { $totalTransactions = array(); $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2)); self::login(); $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFormExport[] = new Oara_Curl_Parameter('startDate', self::formatDate($dStartDate)); $valuesFormExport[] = new Oara_Curl_Parameter('endDate', self::formatDate($dEndDate)); $urls = array(); $urls[] = new Oara_Curl_Request('https://affiliates.wehkamp.nl/pan/aReport3Internal.action?', $valuesFormExport); $exportReport = $this->_client->get($urls); $exportReport[0] = self::checkReportError($exportReport[0], $urls[0]); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); for ($i = 2; $i < $num - 1; $i++) { $transactionExportArray = str_getcsv($exportData[$i], ","); if (!isset($transactionExportArray[2])) { throw new Exception('Problem getting transaction\\n\\n'); } if ($transactionExportArray[0] !== '' && in_array((int) $transactionExportArray[2], $merchantList)) { $transaction = array(); $transaction['merchantId'] = $transactionExportArray[2]; $transactionDate = self::toDate($transactionExportArray[4]); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); if ($transactionExportArray[8] != '') { $transaction['unique_id'] = $transactionExportArray[8]; } else { if ($transactionExportArray[7] != '') { $transaction['unique_id'] = $transactionExportArray[7]; } else { throw new Exception("No Identifier"); } } if ($transactionExportArray[9] != '') { $transaction['custom_id'] = $transactionExportArray[9]; } if ($transactionExportArray[11] == 'A') { $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { if ($transactionExportArray[11] == 'P') { $transaction['status'] = Oara_Utilities::STATUS_PENDING; } else { if ($transactionExportArray[11] == 'D') { $transaction['status'] = Oara_Utilities::STATUS_DECLINED; } } } if ($transactionExportArray[19] != '') { $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[19]); } else { $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[20]); } $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[20]); $totalTransactions[] = $transaction; } } return $totalTransactions; }
/** * (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; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { self::logIn(); $overviewArray = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $epcStartDate = clone $dStartDate; $epcStartDate->addDay(1); $epcEndDate = clone $dEndDate; $epcEndDate->addDay(1); $overviewExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $overviewExport[] = new Oara_Curl_Parameter('epc_start_date', $epcStartDate->toString("MM/dd/yy")); $overviewExport[] = new Oara_Curl_Parameter('epc_start_date_month', $epcStartDate->toString("MM")); $overviewExport[] = new Oara_Curl_Parameter('epc_start_date_day', $epcStartDate->toString("dd")); $overviewExport[] = new Oara_Curl_Parameter('epc_start_date_year', $epcStartDate->toString("yyyy")); $overviewExport[] = new Oara_Curl_Parameter('epc_end_date', $epcEndDate->toString("MM/dd/yy")); $overviewExport[] = new Oara_Curl_Parameter('epc_end_date_month', $epcEndDate->toString("MM")); $overviewExport[] = new Oara_Curl_Parameter('epc_end_date_day', $epcEndDate->toString("dd")); $overviewExport[] = new Oara_Curl_Parameter('epc_end_date_year', $epcEndDate->toString("yyyy")); $overviewByDateArray = array(); $try = 0; $done = false; while (!$done && $try < 5) { try { $urls = array(); $urls[] = new Oara_Curl_Request('https://publisher.ebaypartnernetwork.com/PublisherReportsTx?', $overviewExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\n"); $overviewByDateArray = array_merge($overviewByDateArray, self::getOverviewReportRecursive($exportData)); $done = true; } catch (Exception $e) { $try++; } } if ($try == 5) { echo $exportReport[0]; throw new Exception("Couldn't get overview "); } // Ad clicks and transactions for this day foreach ($overviewByDateArray as $date => $obj) { $overviewDate = new Zend_Date($date, "yyyy/MM/dd"); $returnObject = self::getDayFromArray($obj['merchantId'], $transactionArray, $overviewDate, true); $transactionDateArray = $returnObject->resultArray; $transactionArray = $returnObject->dateArray; unset($overviewDate); foreach ($transactionDateArray as $transaction) { $obj['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $obj['transaction_confirmed_value'] += $transaction['amount']; $obj['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $obj['transaction_pending_value'] += $transaction['amount']; $obj['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $obj['transaction_declined_value'] += $transaction['amount']; $obj['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($obj)) { $overviewArray[] = $obj; } } //Add transactions foreach ($transactionArray as $merchantId => $merchantTransaction) { foreach ($merchantTransaction as $date => $transactionList) { $overview = array(); $overview['merchantId'] = $merchantId; $overviewDate = new Zend_Date($date, "yyyy-MM-dd"); $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); unset($overviewDate); $overview['click_number'] = 0; $overview['impression_number'] = 0; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; foreach ($transactionList as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } $overviewArray[] = $overview; } } return $overviewArray; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus) */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { self::logIn(); $totalTransactions = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('start_date', $dStartDate->toString("M/d/yy")); $valuesFromExport[] = new Oara_Curl_Parameter('start_date_month', $dStartDate->toString("MM")); $valuesFromExport[] = new Oara_Curl_Parameter('start_date_day', $dStartDate->toString("d")); $valuesFromExport[] = new Oara_Curl_Parameter('start_date_year', $dStartDate->toString("yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('end_date', $dEndDate->toString("M/d/yy")); $valuesFromExport[] = new Oara_Curl_Parameter('end_date_month', $dEndDate->toString("M")); $valuesFromExport[] = new Oara_Curl_Parameter('end_date_day', $dEndDate->toString("d")); $valuesFromExport[] = new Oara_Curl_Parameter('end_date_year', $dEndDate->toString("yyyy")); $urls = array(); $urls[] = new Oara_Curl_Request('https://publisher.ebaypartnernetwork.com/PublisherReportsTx?', $valuesFromExport); $exportReport = array(); $exportData = array(); try { $exportReport = $this->_client->get($urls, 'content', 5); $exportData = str_getcsv($exportReport[0], "\n"); } catch (Exception $e) { } $num = count($exportData); for ($i = 1; $i < $num; $i++) { $transactionExportArray = str_getcsv($exportData[$i], "\t"); if ($transactionExportArray[2] == "Winning Bid (Revenue)") { $transaction = array(); $transaction['merchantId'] = 1; $transactionDate = new Zend_Date($transactionExportArray[1], 'yyyy-MM-dd', 'en'); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); unset($transactionDate); if ($transactionExportArray[6] != null) { $transaction['custom_id'] = $transactionExportArray[6]; } $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[15]); $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[3]); $totalTransactions[] = $transaction; } } return $totalTransactions; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus) */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { $nowDate = new Zend_Date(); $dStartDate = clone $dStartDate; $dStartDate->setLocale('en'); $dStartDate->setHour("00"); $dStartDate->setMinute("00"); $dStartDate->setSecond("00"); $dEndDate = clone $dEndDate; $dEndDate->setLocale('en'); $dEndDate->setHour("23"); $dEndDate->setMinute("59"); $dEndDate->setSecond("59"); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('startDate', $dStartDate->toString("dd-MMM-yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('endDate', $dEndDate->toString("dd-MMM-yyyy")); $transactions = array(); $urls = array(); $urls[] = new Oara_Curl_Request('http://ws-external.afnt.co.uk/apiv1/AFFILIATES/affiliatefuture.asmx/GetTransactionListbyDate?', $valuesFromExport); $urls[] = new Oara_Curl_Request('http://ws-external.afnt.co.uk/apiv1/AFFILIATES/affiliatefuture.asmx/GetCancelledTransactionListbyDate?', $valuesFromExport); $exportReport = $this->_client->get($urls); for ($i = 0; $i < count($urls); $i++) { $xml = self::loadXml($exportReport[$i]); if (isset($xml->error)) { throw new Exception('Error connecting with the server'); } if (isset($xml->TransactionList)) { foreach ($xml->TransactionList as $transaction) { $date = new Zend_Date(self::findAttribute($transaction, 'TransactionDate'), "yyyy-MM-ddTHH:mm:ss"); if (in_array((int) self::findAttribute($transaction, 'ProgrammeID'), $merchantList) && $date->compare($dStartDate) >= 0 && $date->compare($dEndDate) <= 0) { $obj = array(); $obj['merchantId'] = self::findAttribute($transaction, 'ProgrammeID'); $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss"); if (self::findAttribute($transaction, 'TrackingReference') != null) { $obj['custom_id'] = self::findAttribute($transaction, 'TrackingReference'); } $obj['unique_id'] = self::findAttribute($transaction, 'TransactionID'); if ($i == 0) { if (Oara_Utilities::numberOfDaysBetweenTwoDates($date, $nowDate) > 5) { $obj['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { $obj['status'] = Oara_Utilities::STATUS_PENDING; } } else { if ($i == 1) { $obj['status'] = Oara_Utilities::STATUS_DECLINED; } } $obj['amount'] = self::findAttribute($transaction, 'SaleValue'); $obj['commission'] = self::findAttribute($transaction, 'SaleCommission'); $leadCommission = self::findAttribute($transaction, 'LeadCommission'); if ($leadCommission != 0) { $obj['commission'] += $leadCommission; } $transactions[] = $obj; } } } } return $transactions; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Interface#getOverviewList($aMerchantIds, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $firstDayMonth = new Zend_Date(); $firstDayMonth->setDay(1); $firstDayMonth->setHour("00"); $firstDayMonth->setMinute("00"); $firstDayMonth->setSecond("00"); $modeArray = array("AdSense for Content", "AdSense for Search", "AdSense for Feeds", "AdSense for Domains"); $valuesExport = array(); $valuesExport[] = new Oara_Curl_Parameter('d', $dStartDate->toString("yyyy/M/d") . "-" . $dEndDate->toString("yyyy/M/d")); $valuesExportReport[] = new Oara_Curl_Parameter('ag', 'date'); $valuesExport[] = new Oara_Curl_Parameter('oc', 'earnings'); $valuesExport[] = new Oara_Curl_Parameter('oo', 'descending'); $valuesExport[] = new Oara_Curl_Parameter('hl', 'en_GB'); $urls = array(); $valuesExportReport = Oara_Utilities::cloneArray($valuesExport); $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFCYAdSense for Content'); $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport); $valuesExportReport = Oara_Utilities::cloneArray($valuesExport); $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFSYAdSense for Search'); $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport); $valuesExportReport = Oara_Utilities::cloneArray($valuesExport); $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFFYAdSense for Feeds'); $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport); $valuesExportReport = Oara_Utilities::cloneArray($valuesExport); $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFDYAdSense for Domains'); $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport); $content = $this->_client->post($urls); for ($i = 0; $i < count($content); $i++) { $exportData = str_getcsv(@iconv('UTF-16', 'UTF-8', $content[$i]), "\n"); for ($j = 1; $j < count($exportData); $j++) { $overviewExportArray = str_getcsv($exportData[$j], "\t"); $obj = array(); $obj['merchantId'] = 1; $overviewDate = new Zend_Date($overviewExportArray[0], "yyyy-MM-dd"); $overviewDate->setHour("00"); $overviewDate->setMinute("00"); $overviewDate->setSecond("00"); $obj['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['link'] = $modeArray[$i]; $obj['transaction_number'] = 0; $obj['transaction_confirmed_commission'] = 0; $obj['transaction_confirmed_value'] = 0; $obj['transaction_pending_commission'] = 0; $obj['transaction_pending_value'] = 0; $obj['transaction_declined_commission'] = 0; $obj['transaction_declined_value'] = 0; $obj['impression_number'] = (int) Oara_Utilities::parseDouble($overviewExportArray[1]); $obj['click_number'] = Oara_Utilities::parseDouble($overviewExportArray[2]); if ($firstDayMonth->compare($overviewDate) <= 0) { $obj['transaction_pending_commission'] = Oara_Utilities::parseDouble($overviewExportArray[6]); $obj['transaction_pending_value'] = Oara_Utilities::parseDouble($overviewExportArray[6]); } else { $obj['transaction_confirmed_commission'] = Oara_Utilities::parseDouble($overviewExportArray[6]); $obj['transaction_confirmed_value'] = Oara_Utilities::parseDouble($overviewExportArray[6]); } if (Oara_Utilities::checkRegister($obj)) { $overviewArray[] = $obj; } } } unset($urls); return $overviewArray; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('fromPeriod', $dStartDate->toString("yyyy-MM-dd")); $valuesFromExport[] = new Oara_Curl_Parameter('toPeriod', $dEndDate->toString("yyyy-MM-dd")); $urls = array(); $urls[] = new Oara_Curl_Request('https://www.affutd.com/en/traffic-stats/advertiser', array()); $exportReport = $this->_client->get($urls); $dom = new Zend_Dom_Query($exportReport[0]); $campaignOption = $dom->query('option[label="DEFAULT"]'); $campaignOption = $campaignOption->current(); $valuesFromExport[] = new Oara_Curl_Parameter('campaign', $campaignOption->getAttribute('value')); $hiddenParam = $dom->query('#jsonCampaigns'); $hiddenParam = $hiddenParam->current(); $valuesFromExport[] = new Oara_Curl_Parameter($hiddenParam->getAttribute('id'), $hiddenParam->getAttribute('value')); $urls = array(); $urls[] = new Oara_Curl_Request('https://www.affutd.com/en/traffic-stats/advertiser', $valuesFromExport); $exportReport = $this->_client->post($urls); $exportData = str_getcsv($exportReport[0], "\n"); $num = count($exportData); for ($i = 1; $i < $num - 1; $i++) { $overviewExportArray = str_getcsv($exportData[$i], ","); if (isset($this->_merchantMap[$overviewExportArray[0]]) && in_array($this->_merchantMap[$overviewExportArray[0]], $merchantList)) { $overview = array(); $overview['merchantId'] = $this->_merchantMap[$overviewExportArray[0]]; $overviewDate = new Zend_Date($overviewExportArray[1], 'yyyy-MM-dd', 'en'); $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $overview['click_number'] = (int) $overviewExportArray[8]; $overview['impression_number'] = (int) $overviewExportArray[9]; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($overview)) { $overviewArray[] = $overview; } } } return $overviewArray; }
/** * (non-PHPdoc) * @see Oara/Network/Oara_Network_Base#getPaymentHistory() */ public function getPaymentHistory() { $paymentHistory = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportPaymentParameters); $valuesFromExport[] = new Oara_Curl_Parameter('fromDate', "01/01/2000"); $dEndDate = new Zend_Date(); $valuesFromExport[] = new Oara_Curl_Parameter('until', $dEndDate->toString("dd/MM/yyyy")); $urls = array(); $urls[] = new Oara_Curl_Request('https://www.ladbrokes.com/aff_man', $valuesFromExport); $exportReport = $this->_client->post($urls); $dom = new Zend_Dom_Query($exportReport[0]); $tableList = $dom->query('#results_table'); $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current())); $num = count($exportData); for ($i = 2; $i < $num - 2; $i++) { $paymentExportArray = str_getcsv($exportData[$i], ";"); $obj = array(); $date = new Zend_Date($paymentExportArray[1], "dd/MM/yy", 'en'); $obj['date'] = $date->toString("yyyy-MM-dd HH:mm:ss"); $obj['pid'] = $i - 1; $obj['value'] = $paymentExportArray[10]; $obj['method'] = 'BACS'; $paymentHistory[] = $obj; } return $paymentHistory; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $totalOverview = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('campaignID', self::getAdvertisersCampaigns($merchantList)); $valuesFromExport[] = new Oara_Curl_Parameter('fromDate', $dStartDate->toString("dd/MM/yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('toDate', $dEndDate->toString("dd/MM/yyyy")); $urls = array(); $urls[] = new Oara_Curl_Request('http://www.dgmpro.com/affiliates/cfc/dgmreports.cfc?method=getSummaryCSV', $valuesFromExport); $exportReport = $this->_curlClient->post($urls); $reportUrl = null; if (preg_match("/<filelocation>(.*)<\\/filelocation>/", $exportReport[0], $matches)) { $reportUrl = trim($matches[1]); } else { throw new Exception('No transaction report found'); } $urls = array(); $urls[] = new Oara_Curl_Request($reportUrl, array()); $exportReport = $this->_curlClient->get($urls); $exportData = str_getcsv($exportReport[0], "\n"); if (self::checkOverview($exportData)) { $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $iteration = self::calculeIterationNumber(count($merchantList), $this->_pageSize); for ($it = 0; $it < $iteration; $it++) { $merchantStartIndex = $this->_pageSize * $it; if (count($merchantList) > $this->_pageSize * ($it + 1)) { $merchantEndIndex = $this->_pageSize * ($it + 1); } else { $merchantEndIndex = count($merchantList); } $urls = array(); for ($merchantIndex = $merchantStartIndex; $merchantIndex < $merchantEndIndex; $merchantIndex++) { $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('campaignID', self::getAdvertisersCampaigns(array($merchantList[$merchantIndex]))); $valuesFromExport[] = new Oara_Curl_Parameter('fromDate', $dStartDate->toString("dd/MM/yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('toDate', $dEndDate->toString("dd/MM/yyyy")); $urls[] = new Oara_Curl_Request('http://www.dgmpro.com/affiliates/cfc/dgmreports.cfc?method=getSummaryCSV', $valuesFromExport); } $exportReportUrl = $this->_curlClient->post($urls); $urls = array(); for ($i = 0; $i < count($exportReportUrl); $i++) { $reportUrl = null; if (preg_match("/<filelocation>(.*)<\\/filelocation>/", $exportReportUrl[$i], $matches)) { $reportUrl = trim($matches[1]); $urls[] = new Oara_Curl_Request($reportUrl, array()); } else { throw new Exception('No transaction report found'); } } $overviewRegisters = $this->_curlClient->get($urls); for ($i = 0; $i < count($overviewRegisters); $i++) { $exportData = str_getcsv($overviewRegisters[$i], "\n"); for ($j = 7; $j < count($exportData) - 2; $j++) { $overviewExportArray = str_getcsv($exportData[$j], ","); $overview = array(); $overview['merchantId'] = $merchantList[$i]; $transactionDate = new Zend_Date($overviewExportArray[0], 'dd-MMM-yyyy HH:mm:ss', 'en_GB'); $overview['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); $overview['click_number'] = (int) $overviewExportArray[2]; $overview['impression_number'] = (int) $overviewExportArray[1]; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $transactionDate); foreach ($transactionDateArray as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($overview)) { $totalOverview[] = $overview; } } } } } return $totalOverview; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus) */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { $totalTransactions = array(); $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2)); $valuesFromExport = array(); $urls = array(); $urls[] = new Oara_Curl_Request('https://secure.paymode.com/paymode/reports-baiv2.jsp?', array()); $exportReport = $this->_client->get($urls); $dom = new Zend_Dom_Query($exportReport[0]); $results = $dom->query('input[type="hidden"]'); foreach ($results as $hidden) { $name = $hidden->getAttribute("name"); $value = $hidden->getAttribute("value"); $valuesFromExport[] = new Oara_Curl_Parameter($name, $value); } $valuesFromExport[] = new Oara_Curl_Parameter('dataSource', '1'); $valuesFromExport[] = new Oara_Curl_Parameter('RA:reports-baiv2.jspCHOOSE', '620541800'); $valuesFromExport[] = new Oara_Curl_Parameter('reportFormat', 'csv'); $valuesFromExport[] = new Oara_Curl_Parameter('includeCurrencyCodeColumn', 'on'); $valuesFromExport[] = new Oara_Curl_Parameter('remitTypeCode', ''); $valuesFromExport[] = new Oara_Curl_Parameter('PAYMENT_CURRENCY_TYPE', 'CREDIT'); $valuesFromExport[] = new Oara_Curl_Parameter('PAYMENT_CURRENCY_TYPE', 'INSTRUCTION'); $valuesFromExport[] = new Oara_Curl_Parameter('subSiteExtID', ''); $valuesFromExport[] = new Oara_Curl_Parameter('ediProvider835Version', '5010'); $valuesFromExport[] = new Oara_Curl_Parameter('tooManyRowsCheck', 'true'); $urls = array(); $dateList = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate); foreach ($dateList as $date) { $valuesFromExportTemp = Oara_Utilities::cloneArray($valuesFromExport); $valuesFromExportTemp[] = new Oara_Curl_Parameter('date', $date->toString("MM/dd/yyyy")); $urls[] = new Oara_Curl_Request('https://secure.paymode.com/paymode/reports-do_csv.jsp?closeJQS=true?', $valuesFromExportTemp); } $exportReport = $this->_client->get($urls); $transactionCounter = 0; $valueCounter = 0; $commissionCounter = 0; $j = 0; foreach ($exportReport as $report) { $reportParameters = $urls[$j]->getParameters(); $reportDate = $reportParameters[count($reportParameters) - 1]->getValue(); $transactionDate = new Zend_Date($reportDate, 'MM/dd/yyyy', 'en'); if (!preg_match("/logout.jsp/", $report)) { $exportReportData = str_getcsv($report, "\n"); $num = count($exportReportData); for ($i = 1; $i < $num; $i++) { $transactionArray = str_getcsv($exportReportData[$i], ","); if (count($transactionArray) == 30 && $transactionArray[0] == 'D' && $transactionArray[1] == null) { $transactionCounter++; $valueCounter += $filter->filter($transactionArray[24]); $commissionCounter += $filter->filter($transactionArray[28]); } } } $j++; } if ($transactionCounter > 0) { for ($i = 0; $i < count($dateList); $i++) { $transaction = array(); $transaction['merchantId'] = 1; $transaction['status'] = Oara_Utilities::STATUS_PAID; $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; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Interface#getOverviewList($aMerchantIds, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $transactionArray = array(); $mothOverviewUrls = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('from_year', $dStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('from_month', $dStartDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('from_day', $dStartDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('to_year', $dEndDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('to_month', $dEndDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('to_day', $dEndDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('prog_id', '0'); $urls = array(); $urls[] = new Oara_Curl_Request('http://users.buy.at/ma/index.php/affiliateReport/dailySummary?', $valuesFromExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\r\n"); if (self::checkOverview($exportData)) { $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); foreach ($merchantList as $idMerchant) { $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('from_year', $dStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('from_month', $dStartDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('from_day', $dStartDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('to_year', $dEndDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('to_month', $dEndDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('to_day', $dEndDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('prog_id', $idMerchant); $mothOverviewUrls[] = new Oara_Curl_Request('http://users.buy.at/ma/index.php/affiliateReport/dailySummary?', $valuesFromExport); } } if (count($mothOverviewUrls) > 0) { $exportReport = $this->_client->get($mothOverviewUrls); $exportReportNumber = count($exportReport); for ($i = 0; $i < $exportReportNumber; $i++) { $exportData = str_getcsv($exportReport[$i], "\r\n"); $num = count($exportData); if (self::checkOverview($exportData)) { for ($j = 1; $j < $num; $j++) { $overviewExportArray = str_getcsv($exportData[$j], ","); $parameter = $mothOverviewUrls[$i]->getParameter(21); $parameterMerchantId = $parameter->getValue(); $obj = array(); $obj['merchantId'] = $parameterMerchantId; $overviewDate = new Zend_Date($overviewExportArray[0], "yyyy-MM-dd"); $obj['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['impression_number'] = 0; $obj['click_number'] = $overviewExportArray[1]; $obj['transaction_number'] = 0; $obj['transaction_confirmed_commission'] = 0; $obj['transaction_confirmed_value'] = 0; $obj['transaction_pending_commission'] = 0; $obj['transaction_pending_value'] = 0; $obj['transaction_declined_commission'] = 0; $obj['transaction_declined_value'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($obj['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $obj['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $obj['transaction_confirmed_value'] += $transaction['amount']; $obj['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $obj['transaction_pending_value'] += $transaction['amount']; $obj['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $obj['transaction_declined_value'] += $transaction['amount']; $obj['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($obj)) { $overviewArray[] = $obj; } } } } } return $overviewArray; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $urls = array(); foreach ($merchantList as $merchantId) { $overviewExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $overviewExport[] = new Oara_Curl_Parameter('program', $merchantId); $overviewExport[] = new Oara_Curl_Parameter('period', $dStartDate->toString("yyyyMMdd") . "-" . $dEndDate->toString("yyyyMMdd")); $urls[] = new Oara_Curl_Request('http://publisher.daisycon.com/en/affiliatemarketing/stats/month/?', $overviewExport); } $exportReport = $this->_client->get($urls); for ($i = 1; $i < count($exportReport); $i++) { $exportData = str_getcsv($exportReport[$i], "\r\n"); $num = count($exportData); $overviewDate = clone $dStartDate; $overviewDate->setHour(0); $overviewDate->setMinute(0); $overviewDate->setSecond(0); for ($j = 1; $j < $num; $j++) { $overviewExportArray = str_getcsv($exportData[$j], ";"); $obj = array(); $urlParams = $urls[$i]->getParameters(); $obj['merchantId'] = $urlParams[6]->getValue(); $overviewDate->setDay($overviewExportArray[0]); $obj['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['impression_number'] = 0; $obj['click_number'] = $overviewExportArray[1]; $obj['transaction_number'] = 0; $obj['transaction_confirmed_commission'] = 0; $obj['transaction_confirmed_value'] = 0; $obj['transaction_pending_commission'] = 0; $obj['transaction_pending_value'] = 0; $obj['transaction_declined_commission'] = 0; $obj['transaction_declined_value'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($obj['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $obj['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $obj['transaction_confirmed_value'] += $transaction['amount']; $obj['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $obj['transaction_pending_value'] += $transaction['amount']; $obj['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $obj['transaction_declined_value'] += $transaction['amount']; $obj['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($obj)) { $overviewArray[] = $obj; } } } return $overviewArray; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $totalOverview = array(); $mothOverviewUrls = array(); $valuesFormExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFormExport[] = new Oara_Curl_Parameter('fromDate', $dStartDate->toString("M/d/yyyy")); $valuesFormExport[] = new Oara_Curl_Parameter('toDate', $dEndDate->toString("M/d/yyyy")); $mothOverviewUrls[] = new Oara_Curl_Request('https://cli.linksynergy.com/cli/publisher/reports/advancedReports.php', $valuesFormExport); $exportMothReport = $this->_client->post($mothOverviewUrls); $exportReportNumber = count($exportMothReport); for ($i = 0; $i < $exportReportNumber; $i++) { $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->validateOnParse = true; $doc->loadHTML($exportMothReport[$i]); $frame = $doc->getElementById('frame'); if ($frame !== null) { $frameUrl = null; foreach ($frame->attributes as $attrName => $attrNode) { if ($attrName == 'src') { $frameUrl = $attrNode->nodeValue; } } $urls = array(); $urls[] = new Oara_Curl_Request($frameUrl, array()); $exportReport = $this->_client->get($urls); if (preg_match("/result=\"searching\"/", $exportReport[0]) || preg_match("/Logging in/", $exportReport[0])) { $urls = array(); $urls[] = new Oara_Curl_Request($frameUrl, array()); $exportReport = $this->_client->get($urls); } if (!preg_match("/<a class=\"NQWMenuItem\" name=\"SectionElements\" href=\"javascript:void\\(null\\);\" onclick=\"NQWClearActiveMenu\\(\\);Download\\('([^<]*)'\\); return false\">Download Data<\\/a>/", $exportReport[0], $matches)) { if (preg_match("/No Results/", $exportReport[0])) { return $totalOverview; } } } } $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $mothOverviewUrls = array(); $dateArray = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate); $dateArraySize = sizeof($dateArray); for ($i = 0; $i < $dateArraySize; $i++) { $valuesFormExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFormExport[] = new Oara_Curl_Parameter('fromDate', $dateArray[$i]->toString("M/d/yyyy")); $valuesFormExport[] = new Oara_Curl_Parameter('toDate', $dateArray[$i]->toString("M/d/yyyy")); $mothOverviewUrls[] = new Oara_Curl_Request('https://cli.linksynergy.com/cli/publisher/reports/advancedReports.php', $valuesFormExport); } $exportMothReport = $this->_client->post($mothOverviewUrls); $exportReportNumber = count($exportMothReport); for ($i = 0; $i < $exportReportNumber; $i++) { $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->validateOnParse = true; $doc->loadHTML($exportMothReport[$i]); $frame = $doc->getElementById('frame'); $frameUrl = null; if ($frame !== null) { foreach ($frame->attributes as $attrName => $attrNode) { if ($attrName == 'src') { $frameUrl = $attrNode->nodeValue; } } $urls = array(); $urls[] = new Oara_Curl_Request($frameUrl, array()); $exportReport = $this->_client->get($urls); while (!preg_match("/No Results/", $exportReport[0], $matches)) { if (preg_match("/<a class=\"NQWMenuItem\" name=\"SectionElements\" href=\"javascript:void\\(null\\);\" onclick=\"NQWClearActiveMenu\\(\\);Download\\('([^<]*)'\\); return false\">Download Data<\\/a>/", $exportReport[0], $matches)) { $totalOverview = self::getOverview($matches, $totalOverview, $merchantList, $mothOverviewUrls[$i]->getParameter(9), $transactionArray); break; } else { if (preg_match("/result=\"searching\"/", $exportReport[0]) || preg_match("/Logging in/", $exportReport[0])) { $urls = array(); $urls[] = new Oara_Curl_Request($frameUrl, array()); $exportReport = $this->_client->get($urls); } else { //echo $exportReport[0]; throw new Exception("Error getting transactions"); } } } } } return $totalOverview; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $overviewArray = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $mothOverviewUrls = array(); $dateArray = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate); $dateArraySize = sizeof($dateArray); for ($i = 0; $i < $dateArraySize; $i++) { $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFormExport[] = new Oara_Curl_Parameter('datefrom', $dateArray[$i]->toString("yyyy-MM-dd")); $valuesFormExport[] = new Oara_Curl_Parameter('dateto', $dateArray[$i]->toString("yyyy-MM-dd")); $mothUrls[] = new Oara_Curl_Request('https://accounts.skimlinks.com/reports_export.php?', $valuesFormExport); } $exportReport = $this->_client->get($mothUrls); $exportReportNumber = count($exportReport); for ($i = 0; $i < $exportReportNumber; $i++) { $exportData = str_getcsv($exportReport[$i], "\n"); $num = count($exportData); for ($j = 1; $j < $num - 5; $j++) { $overviewExportArray = str_getcsv($exportData[$j], ","); if (Oara_Utilities::parseDouble($overviewExportArray[2]) != 0 && isset($this->_merchantMap[$overviewExportArray[0]]) && in_array($this->_merchantMap[$overviewExportArray[0]], $merchantList)) { $overview = array(); $overview['merchantId'] = $this->_merchantMap[$overviewExportArray[0]]; $overviewDate = new Zend_Date($mothUrls[$i]->getParameter(5)->getValue(), 'yyyy-MM-dd', 'en'); $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $overview['click_number'] = (int) $overviewExportArray[1]; $overview['impression_number'] = 0; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($overview)) { $overviewArray[] = $overview; } } } } return $overviewArray; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $totalOverviews = array(); $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $startDate = $dStartDate->toString('dd/MM/yyyy'); $endDate = $dEndDate->toString('dd/MM/yyyy'); $valuesFormExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); //$valuesFormExport[] = new Oara_Curl_Parameter('merchant', '0'); $valuesFormExport[] = new Oara_Curl_Parameter('datefrom', $startDate); $valuesFormExport[] = new Oara_Curl_Parameter('dateto', $endDate); $urls = array(); $urls[] = new Oara_Curl_Request($this->_serverUrl . 'reports/remote.aspx?', $valuesFormExport); $exportReport = $this->_client->get($urls); $exportData = array(); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); if ($num > 1) { for ($j = 1; $j < $num; $j++) { $overviewExportArray = str_getcsv($exportData[$j], ","); if (isset($this->_merchantMap[$overviewExportArray[1]]) && in_array((int) $this->_merchantMap[$overviewExportArray[1]], $merchantList)) { $overview = array(); $merchantId = $this->_merchantMap[$overviewExportArray[1]]; $overview['merchantId'] = $merchantId; $overviewDate = new Zend_Date($overviewExportArray[0], "dd/MM/yyyy"); $overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $overview['click_number'] = (int) $overviewExportArray[3]; $overview['impression_number'] = (int) $overviewExportArray[4]; $overview['transaction_number'] = 0; $overview['transaction_confirmed_value'] = 0; $overview['transaction_confirmed_commission'] = 0; $overview['transaction_pending_value'] = 0; $overview['transaction_pending_commission'] = 0; $overview['transaction_declined_value'] = 0; $overview['transaction_declined_commission'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($overview['merchantId'], $transactionArray, $overviewDate); foreach ($transactionDateArray as $transaction) { $overview['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $overview['transaction_confirmed_value'] += $transaction['amount']; $overview['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $overview['transaction_pending_value'] += $transaction['amount']; $overview['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $overview['transaction_declined_value'] += $transaction['amount']; $overview['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($overview)) { $totalOverviews[] = $overview; } } } } return $totalOverviews; }
private function getTransactionReportRecursive($id, $startDate, $endDate) { $totalTransactions = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('startDay', $startDate->toString("d")); $valuesFromExport[] = new Oara_Curl_Parameter('startMonth', (int) $startDate->toString("M") - 1); $valuesFromExport[] = new Oara_Curl_Parameter('startYear', $startDate->toString("yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('endDay', $endDate->toString("d")); $valuesFromExport[] = new Oara_Curl_Parameter('endMonth', (int) $endDate->toString("M") - 1); $valuesFromExport[] = new Oara_Curl_Parameter('endYear', $endDate->toString("yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('idbox_store_id', $id); $urls = array(); $urls[] = new Oara_Curl_Request($this->_networkServer . "/gp/associates/network/reports/report.html?", $valuesFromExport); $exportReport = $this->_client->get($urls); if (preg_match("/DOCTYPE/", $exportReport[0])) { return array(); } $exportData = str_getcsv($exportReport[0], "\n"); $index = 2; try { if (!isset($transactionExportArray[$index]) || !isset($transactionExportArray[5])) { throw new Exception("No date"); } $transactionExportArray = str_getcsv(str_replace("\"", "", $exportData[$index]), "\t"); $transactionDate = new Zend_Date($transactionExportArray[5], 'MMMM d,yyyy', 'en'); } catch (Exception $e) { $index = 3; } $num = count($exportData); for ($i = $index; $i < $num; $i++) { $transactionExportArray = str_getcsv(str_replace("\"", "", $exportData[$i]), "\t"); $transactionDate = new Zend_Date($transactionExportArray[5], 'MMMM d,yyyy', 'en'); $transaction = array(); $transaction['merchantId'] = 1; if (!isset($transactionExportArray[5])) { throw new Exception("Request failed"); } $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); unset($transactionDate); if ($transactionExportArray[4] != null) { $transaction['custom_id'] = $transactionExportArray[4]; } $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[9]); $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[10]); $transaction['device_type'] = $transactionExportArray[11]; $transaction['skew'] = $transactionExportArray[2]; $transaction['title'] = $transactionExportArray[1]; $totalTransactions[] = $transaction; } return $totalTransactions; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Base#getOverviewList($merchantId, $dStartDate, $dEndDate) */ public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null) { $totalOverview = array(); $urls = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('startyear', $dStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('startmonth', (int) $dStartDate->get(Zend_Date::MONTH) - 1); $valuesFromExport[] = new Oara_Curl_Parameter('startday', $dStartDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('endyear', $dEndDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('endmonth', (int) $dEndDate->get(Zend_Date::MONTH) - 1); $valuesFromExport[] = new Oara_Curl_Parameter('endday', $dEndDate->get(Zend_Date::DAY)); $urls[] = new Oara_Curl_Request('https://members.cj.com/member/' . $this->_memberId . '/publisher/report/performance.do?', $valuesFromExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\n"); $num = count($exportData); if ($num > 1) { $transactionArray = Oara_Utilities::transactionMapPerDay($transactionList); $dateArray = Oara_Utilities::daysOfDifference($dStartDate, $dEndDate); foreach ($dateArray as $currentStartDate) { $groupMap = array(); $urls = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $valuesFromExport[] = new Oara_Curl_Parameter('startyear', $currentStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('startmonth', (int) $currentStartDate->get(Zend_Date::MONTH) - 1); $valuesFromExport[] = new Oara_Curl_Parameter('startday', $currentStartDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('endyear', $currentStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('endmonth', (int) $currentStartDate->get(Zend_Date::MONTH) - 1); $valuesFromExport[] = new Oara_Curl_Parameter('endday', $currentStartDate->get(Zend_Date::DAY)); $urls[] = new Oara_Curl_Request('https://members.cj.com/member/' . $this->_memberId . '/publisher/report/performance.do?', $valuesFromExport); $exportReport = $this->_client->get($urls); $clickImpressionsArray = array(); if (!preg_match("/error/i", $exportReport[0], $matches)) { $exportData = str_getcsv($exportReport[0], "\n"); $num = count($exportData); for ($i = 1; $i < $num; $i++) { $overviewExportArray = str_getcsv($exportData[$i], ","); if (isset($this->_merchantMap[$overviewExportArray[0]]) && in_array((int) $this->_merchantMap[$overviewExportArray[0]], $merchantList)) { $obj = array(); $obj['merchantId'] = $this->_merchantMap[$overviewExportArray[0]]; $obj['date'] = $currentStartDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['click_number'] = $overviewExportArray[6]; $obj['impression_number'] = $overviewExportArray[7]; $clickImpressionsArray[] = $obj; } } } else { echo "Warning overview could fail for the day " . $currentStartDate->toString("dd/MM/yyyy") . " \n\n"; } $groupMap = self::groupOverview($groupMap, $clickImpressionsArray); $transactionDateArray = array(); foreach ($transactionArray as $merchantId => $data) { $transactionDateArray = array_merge($transactionDateArray, Oara_Utilities::getDayFromArray($merchantId, $transactionArray, $currentStartDate)); } if (count($transactionDateArray) > 0) { $groupMap = self::groupOverview($groupMap, $transactionDateArray); } foreach ($groupMap as $merchant => $groupOverview) { $groupOverview['merchantId'] = $merchant; $groupOverview['date'] = $currentStartDate->toString("yyyy-MM-dd HH:mm:ss"); if (Oara_Utilities::checkRegister($groupOverview)) { $totalOverview[] = $groupOverview; } } } } return $totalOverview; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate) */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { $totalTransactions = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('from_year', $dStartDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('from_month', $dStartDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('from_day', $dStartDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('to_year', $dEndDate->get(Zend_Date::YEAR)); $valuesFromExport[] = new Oara_Curl_Parameter('to_month', $dEndDate->get(Zend_Date::MONTH)); $valuesFromExport[] = new Oara_Curl_Parameter('to_day', $dEndDate->get(Zend_Date::DAY)); $valuesFromExport[] = new Oara_Curl_Parameter('prog_id', '0'); $urls = array(); $urls[] = new Oara_Curl_Request('http://users.buy.at/ma/index.php/affiliateReport/commissionValue?', $valuesFromExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); for ($i = 1; $i < $num; $i++) { $transactionExportArray = str_getcsv($exportData[$i], ","); if (in_array((int) $transactionExportArray[12], $merchantList)) { $transaction = array(); $merchantId = (int) $transactionExportArray[12]; $transaction['merchantId'] = $merchantId; $transactionDate = new Zend_Date($transactionExportArray[5], 'dd-MM-yyyy HH:mm:ss'); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); $transaction['unique_id'] = $transactionExportArray[8]; if ($transactionExportArray[6] != null) { $transaction['custom_id'] = $transactionExportArray[6]; } if ($transactionExportArray[2] == 'Approved') { $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { if ($transactionExportArray[2] == 'Pending') { $transaction['status'] = Oara_Utilities::STATUS_PENDING; } else { if ($transactionExportArray[2] == 'Held') { $transaction['status'] = Oara_Utilities::STATUS_DECLINED; } } } $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[9]); $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[10]); $totalTransactions[] = $transaction; } } return $totalTransactions; }
/** * It returns the transactions for a payment * @see Oara_Network::paymentTransactions() */ public function paymentTransactions($paymentId, $merchantList, $startDate) { $paymentTransactionList = array(); $paymentHistory = Oara_Utilities::registerBubbleSort($this->_paymentHistory); $paymentStartDate = new Zend_Date($startDate, "yyyy-MM-dd HH:mm:ss"); $paymentEndDate = null; $enc = false; $i = 0; $payment = null; while (!$enc && $i < count($paymentHistory)) { $payment = $paymentHistory[$i]; if ($payment['pid'] == $paymentId) { $enc = true; $paymentEndDate = new Zend_Date($payment['date'], "yyyy-MM-dd HH:mm:ss"); } $i++; } if ($enc && $paymentStartDate->compare($paymentEndDate) <= 0) { $totalTransactions = array(); $dateArray = Oara_Utilities::monthsOfDifference(new Zend_Date($startDate, "yyyy-MM-dd HH:mm:ss"), $paymentEndDate); for ($i = 0; $i < count($dateArray); $i++) { $monthStartDate = clone $dateArray[$i]; $monthEndDate = null; if ($i != count($dateArray) - 1) { $monthEndDate = clone $dateArray[$i]; $monthEndDate->setDay(1); $monthEndDate->addMonth(1); $monthEndDate->subDay(1); } else { $monthEndDate = $paymentEndDate; } $monthEndDate->setHour(23); $monthEndDate->setMinute(59); $monthEndDate->setSecond(59); echo "\n importing from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n"; $urls = array(); $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFormExport[] = new Oara_Curl_Parameter('DateFrom', $monthStartDate->toString("yyyy-MM-dd")); $valuesFormExport[] = new Oara_Curl_Parameter('DateTo', $monthEndDate->toString("yyyy-MM-dd")); $urls[] = new Oara_Curl_Request('http://affiliate.paidonresults.com/api/transactions?', $valuesFormExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); for ($i = 1; $i < $num; $i++) { $transactionExportArray = str_getcsv($exportData[$i], ","); $paid = $transactionExportArray[7] == "YES" ? true : false; if (in_array($transactionExportArray[0], $merchantList) && $paid) { $transactionDate = new Zend_Date($transactionExportArray[8], "dd/MM/yyyy HH:mm:ss"); echo $paymentEndDate->toString("yyyy-MM-dd") . " " . $transactionDate->toString("yyyy-MM-dd") . "\n\n"; if ($paymentEndDate->toString("yyyy-MM-dd") == $transactionDate->toString("yyyy-MM-dd")) { $paymentTransactionList[] = $transactionExportArray[2]; } } } } } return $paymentTransactionList; }
/** * (non-PHPdoc) * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus) */ public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null) { $totalTransactions = array(); $valuesFromExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); $valuesFromExport[] = new Oara_Curl_Parameter('startDate', $dStartDate->toString("dd/MM/yyyy")); $valuesFromExport[] = new Oara_Curl_Parameter('endDate', $dEndDate->toString("dd/MM/yyyy")); $urls = array(); $urls[] = new Oara_Curl_Request("{$this->_extension}/affiliate_statistic_transaction.html?", $valuesFromExport); try { $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 (isset($merchantMap[$transactionExportArray[2]])) { $merchantId = $merchantMap[$transactionExportArray[2]]; if (in_array($merchantId, $merchantList)) { $transaction = array(); $transaction['merchantId'] = $merchantId; $transactionDate = new Zend_Date($transactionExportArray[4], 'dd/MM/yyyy HH:mm:ss', 'en'); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); $transaction['unique_id'] = $transactionExportArray[0]; if ($transactionExportArray[11] != null) { $transaction['custom_id'] = $transactionExportArray[11]; } if ($transactionExportArray[12] == "Approved" || $transactionExportArray[12] == "Approve") { $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { if ($transactionExportArray[12] == "Pending") { $transaction['status'] = Oara_Utilities::STATUS_PENDING; } else { if ($transactionExportArray[12] == "Declined" || $transactionExportArray[12] == "Rejected") { $transaction['status'] = Oara_Utilities::STATUS_DECLINED; } else { throw new Exception("No Status found " . $transactionExportArray[12]); } } } $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[7]); $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[9]); $totalTransactions[] = $transaction; } } } } catch (Exception $e) { } return $totalTransactions; }
/** * (non-PHPdoc) * @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory() */ public function getPaymentHistory() { $paymentHistory = array(); foreach (array_keys($this->_websiteList) as $websiteId) { $paymentExport = Oara_Utilities::cloneArray($this->_exportPaymentParameters); $urls = array(); $urls[] = new Oara_Curl_Request('http://www.clixgalore.co.uk/AffiliatePaymentDetail.aspx?', array()); $exportReport = $this->_client->post($urls); $dom = new Zend_Dom_Query($exportReport[0]); $results = $dom->query('input[type="hidden"]'); $count = count($results); foreach ($results as $result) { $hiddenName = $result->attributes->getNamedItem("name")->nodeValue; $hiddenValue = $result->attributes->getNamedItem("value")->nodeValue; $paymentExport[] = new Oara_Curl_Parameter($hiddenName, $hiddenValue); } $paymentExport[] = new Oara_Curl_Parameter('AffProgramDropDown1$aff_program_list', $websiteId); $urls = array(); $urls[] = new Oara_Curl_Request('http://www.clixgalore.co.uk/AffiliatePaymentDetail.aspx', $paymentExport); $exportReport = $this->_client->post($urls); $dom = new Zend_Dom_Query($exportReport[0]); $results = $dom->query('#dg_payments'); $count = count($results); if ($count == 1) { $exportData = self::htmlToCsv(self::DOMinnerHTML($results->current())); for ($j = 1; $j < count($exportData) - 1; $j++) { $paymentExportArray = str_getcsv($exportData[$j], ";"); $obj = array(); $paymentDate = new Zend_Date($paymentExportArray[0], "MMM d yyyy", "en"); $obj['date'] = $paymentDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['pid'] = $paymentDate->toString("yyyyMMdd"); $obj['method'] = 'BACS'; if (preg_match("/[-+]?[0-9]*,?[0-9]*\\.?[0-9]+/", $paymentExportArray[2], $matches)) { $obj['value'] = Oara_Utilities::parseDouble($matches[0]); } else { throw new Exception("Problem reading payments"); } $paymentHistory[] = $obj; } } } return $paymentHistory; }
/** * (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); $urls = array(); $valuesFormExport[] = new Oara_Curl_Parameter('DateFrom', $dStartDate->toString("yyyy-MM-dd")); $valuesFormExport[] = new Oara_Curl_Parameter('DateTo', $dEndDate->toString("yyyy-MM-dd")); $urls[] = new Oara_Curl_Request('http://affiliate.paidonresults.com/api/transactions?', $valuesFormExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); for ($i = 1; $i < $num; $i++) { $transactionExportArray = str_getcsv($exportData[$i], ","); if (in_array($transactionExportArray[0], $merchantList)) { $transaction = array(); $transaction['merchantId'] = $transactionExportArray[0]; $transactionDate = new Zend_Date($transactionExportArray[1], "dd/MM/yyyy HH:mm:ss"); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); if ($transactionExportArray[3] != null) { $transaction['custom_id'] = $transactionExportArray[3]; } $transaction['amount'] = (double) $transactionExportArray[4]; $transaction['commission'] = (double) $transactionExportArray[5]; if ($transactionExportArray[6] == 'VALIDATED') { $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { if ($transactionExportArray[6] == 'PENDING') { $transaction['status'] = Oara_Utilities::STATUS_PENDING; } else { if ($transactionExportArray[6] == 'VOID') { $transaction['status'] = Oara_Utilities::STATUS_DECLINED; } } } $totalTransactions[] = $transaction; } } return $totalTransactions; }
private function getOverviewReportRecursive($transactionArray, $id, $dStartDate, $dEndDate) { $overviewArray = array(); $overviewExport = Oara_Utilities::cloneArray($this->_exportOverviewParameters); $overviewExport[] = new Oara_Curl_Parameter('startDay', $dStartDate->toString("d")); $overviewExport[] = new Oara_Curl_Parameter('startMonth', (int) $dStartDate->toString("M") - 1); $overviewExport[] = new Oara_Curl_Parameter('startYear', $dStartDate->toString("yyyy")); $overviewExport[] = new Oara_Curl_Parameter('endDay', $dEndDate->toString("d")); $overviewExport[] = new Oara_Curl_Parameter('endMonth', (int) $dEndDate->toString("M") - 1); $overviewExport[] = new Oara_Curl_Parameter('endYear', $dEndDate->toString("yyyy")); $overviewExport[] = new Oara_Curl_Parameter('idbox_store_id', $id); $urls = array(); $urls[] = new Oara_Curl_Request($this->_networkServer . "/gp/associates/network/reports/report.html?", $overviewExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\n"); $num = count($exportData); for ($j = 2; $j < $num; $j++) { $overviewExportArray = str_getcsv($exportData[$j], "\t"); $obj = array(); $obj['merchantId'] = 1; $overviewDate = new Zend_Date($overviewExportArray[0], "yyyy/MM/dd HH:mm:ss"); $obj['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss"); $obj['impression_number'] = 0; if (!isset($overviewExportArray[1])) { throw new Exception("Request failed"); } $obj['click_number'] = $overviewExportArray[1]; $obj['transaction_number'] = 0; $obj['transaction_confirmed_commission'] = 0; $obj['transaction_confirmed_value'] = 0; $obj['transaction_pending_commission'] = 0; $obj['transaction_pending_value'] = 0; $obj['transaction_declined_commission'] = 0; $obj['transaction_declined_value'] = 0; $transactionDateArray = Oara_Utilities::getDayFromArray($obj['merchantId'], $transactionArray, $overviewDate); unset($overviewDate); foreach ($transactionDateArray as $transaction) { $obj['transaction_number']++; if ($transaction['status'] == Oara_Utilities::STATUS_CONFIRMED) { $obj['transaction_confirmed_value'] += $transaction['amount']; $obj['transaction_confirmed_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_PENDING) { $obj['transaction_pending_value'] += $transaction['amount']; $obj['transaction_pending_commission'] += $transaction['commission']; } else { if ($transaction['status'] == Oara_Utilities::STATUS_DECLINED) { $obj['transaction_declined_value'] += $transaction['amount']; $obj['transaction_declined_commission'] += $transaction['commission']; } } } } if (Oara_Utilities::checkRegister($obj)) { $overviewArray[] = $obj; } } return $overviewArray; }
/** * (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(); $startDate = $dStartDate->toString('dd/MM/yyyy'); $endDate = $dEndDate->toString('dd/MM/yyyy'); $valueIndex = 9; $commissionIndex = 16; $statusIndex = 17; if ($this->_serverUrl == "https://mats.brandconversions.com/") { $valueIndex = 11; $commissionIndex = 17; $statusIndex = 18; } $valuesFormExport = Oara_Utilities::cloneArray($this->_exportTransactionParameters); //$valuesFormExport[] = new Oara_Curl_Parameter('merchant', '0'); $valuesFormExport[] = new Oara_Curl_Parameter('datefrom', $startDate); $valuesFormExport[] = new Oara_Curl_Parameter('dateto', $endDate); $urls = array(); $urls[] = new Oara_Curl_Request($this->_serverUrl . 'reports/remote.aspx?', $valuesFormExport); $exportReport = $this->_client->get($urls); $exportData = str_getcsv($exportReport[0], "\r\n"); $num = count($exportData); for ($i = 1; $i < $num; $i++) { $transactionExportArray = str_getcsv($exportData[$i], ","); if (in_array((int) $transactionExportArray[4], $merchantList)) { $transaction = array(); $transaction['unique_id'] = $transactionExportArray[0]; $transaction['merchantId'] = $transactionExportArray[4]; $transactionDate = new Zend_Date($transactionExportArray[2], "dd/MM/YY HH:mm:ss"); $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss"); if ($transactionExportArray[7] != null) { $transaction['custom_id'] = $transactionExportArray[7]; } if (preg_match('/Unpaid Confirmed/', $transactionExportArray[$statusIndex]) || preg_match('/Paid Confirmed/', $transactionExportArray[$statusIndex])) { $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED; } else { if (preg_match('/Unpaid Unconfirmed/', $transactionExportArray[$statusIndex])) { $transaction['status'] = Oara_Utilities::STATUS_PENDING; } else { if (preg_match('/Unpaid Rejected/', $transactionExportArray[$statusIndex])) { $transaction['status'] = Oara_Utilities::STATUS_DECLINED; } else { throw new Exception("No Status supported " . $transactionExportArray[$statusIndex]); } } } $transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[$valueIndex]); $transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[$commissionIndex]); $totalTransactions[] = $transaction; } } return $totalTransactions; }
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; }