本文整理汇总了PHP中Oara_Utilities::monthsOfDifference方法的典型用法代码示例。如果您正苦于以下问题:PHP Oara_Utilities::monthsOfDifference方法的具体用法?PHP Oara_Utilities::monthsOfDifference怎么用?PHP Oara_Utilities::monthsOfDifference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oara_Utilities
的用法示例。
在下文中一共展示了Oara_Utilities::monthsOfDifference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPaymentHistory
/**
* (non-PHPdoc)
* @see Oara/Network/Oara_Network_Base#getPaymentHistory()
*/
public function getPaymentHistory()
{
$paymentHistory = array();
$startDate = new Zend_Date('01-01-2009', 'dd-MM-yyyy');
$endDate = new Zend_Date();
$dateArray = Oara_Utilities::monthsOfDifference($startDate, $endDate);
for ($i = 0; $i < count($dateArray); $i++) {
$dateMonth = $dateArray[$i];
$obj = array();
$obj['date'] = $dateMonth->toString("yyyy-MM-dd HH:mm:ss");
$value = rand(1, 1300);
$obj['value'] = $value;
$obj['method'] = 'BACS';
$obj['pid'] = $dateMonth->toString('yyyyMMdd');
$paymentHistory[] = $obj;
}
return $paymentHistory;
}
示例2: getPaymentHistory
/**
* (non-PHPdoc)
* @see Oara/Network/Oara_Network_Publisher_Base#getPaymentHistory()
*/
public function getPaymentHistory()
{
$paymentHistory = array();
$filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2));
$startDate = new Zend_Date("01-01-2012", "dd-MM-yyyy");
$endDate = new Zend_Date();
$dateList = Oara_Utilities::monthsOfDifference($startDate, $endDate);
foreach ($dateList as $date) {
$monthStartDate = clone $date;
$monthEndDate = null;
$monthEndDate = clone $date;
$monthEndDate->setDay(1);
$monthEndDate->addMonth(1);
$monthEndDate->subDay(1);
$monthEndDate->setHour(23);
$monthEndDate->setMinute(59);
$monthEndDate->setSecond(59);
$valuesFromExport = array();
$valuesFromExport[] = new Oara_Curl_Parameter('Begin_Date', $monthStartDate->toString("MM/dd/yyyy"));
$valuesFromExport[] = new Oara_Curl_Parameter('End_Date', $monthEndDate->toString("MM/dd/yyyy"));
$valuesFromExport[] = new Oara_Curl_Parameter('cd', "c");
$valuesFromExport[] = new Oara_Curl_Parameter('disb', "false");
$valuesFromExport[] = new Oara_Curl_Parameter('coll', "true");
$valuesFromExport[] = new Oara_Curl_Parameter('transactionID', "");
$valuesFromExport[] = new Oara_Curl_Parameter('Begin_DatePN', "");
$valuesFromExport[] = new Oara_Curl_Parameter('Begin_DateCN', "");
$valuesFromExport[] = new Oara_Curl_Parameter('End_DatePN', "");
$valuesFromExport[] = new Oara_Curl_Parameter('End_DateCN', "");
$valuesFromExport[] = new Oara_Curl_Parameter('disbAcctIDRef', "");
$valuesFromExport[] = new Oara_Curl_Parameter('checkNumberID', "");
$valuesFromExport[] = new Oara_Curl_Parameter('paymentNum', "");
$valuesFromExport[] = new Oara_Curl_Parameter('sel_type', "OTH");
$valuesFromExport[] = new Oara_Curl_Parameter('payStatusCat', "ALL_STATUSES");
$valuesFromExport[] = new Oara_Curl_Parameter('amount', "");
$valuesFromExport[] = new Oara_Curl_Parameter('aggregatedCreditAmount', "");
$valuesFromExport[] = new Oara_Curl_Parameter('disbSiteIDManual', "");
$valuesFromExport[] = new Oara_Curl_Parameter('collSiteIDManual', "");
$valuesFromExport[] = new Oara_Curl_Parameter('agencyid', "");
$valuesFromExport[] = new Oara_Curl_Parameter('collbankAccount', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitInvoice', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitAccount', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitCustAccount', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitCustName', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitVendorNumber', "");
$valuesFromExport[] = new Oara_Curl_Parameter('remitVendorName', "");
$urls = array();
$urls[] = new Oara_Curl_Request('https://secure.paymode.com/paymode/payment-DB-search.jsp?dataSource=1', $valuesFromExport);
$exportReport = $this->_client->post($urls);
if (!preg_match("/No payments were found/", $exportReport[0])) {
$dom = new Zend_Dom_Query($exportReport[0]);
$results = $dom->query('form[name="transform"] table');
if (count($results) > 0) {
$tableCsv = self::htmlToCsv(self::DOMinnerHTML($results->current()));
$payment = array();
$paymentArray = str_getcsv($tableCsv[4], ";");
$payment['pid'] = $paymentArray[1];
$dateResult = $dom->query('form[name="collForm"] table');
if (count($dateResult) > 0) {
$dateCsv = self::htmlToCsv(self::DOMinnerHTML($dateResult->current()));
$dateArray = str_getcsv($dateCsv[2], ";");
$paymentDate = new Zend_Date($dateArray[1], 'dd-MMM-yyyy', 'en');
$payment['date'] = $paymentDate->toString("yyyy-MM-dd HH:mm:ss");
$paymentArray = str_getcsv($tableCsv[3], ";");
$payment['value'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $paymentArray[3]));
$payment['method'] = "BACS";
$paymentHistory[] = $payment;
}
} else {
$results = $dom->query('table[cellpadding="2"]');
foreach ($results as $table) {
$tableCsv = self::htmlToCsv(self::DOMinnerHTML($table));
$num = count($tableCsv);
for ($i = 1; $i < $num; $i++) {
$payment = array();
$paymentArray = str_getcsv($tableCsv[$i], ";");
$payment['pid'] = $paymentArray[0];
$paymentDate = new Zend_Date($paymentArray[3], 'MM/dd/yyyy', 'en');
$payment['date'] = $paymentDate->toString("yyyy-MM-dd HH:mm:ss");
$payment['value'] = Oara_Utilities::parseDouble($paymentArray[9]);
$payment['method'] = "BACS";
$paymentHistory[] = $payment;
}
}
}
}
}
return $paymentHistory;
}
示例3: affjetCli
/**
* The affjet cli , read the arguments and build the report requested
* @param array arguments, Map of the cli arguments
* * @param network, the affiliate network
* @return none
*/
public static function affjetCli($arguments, $network)
{
//Start date, the first two months ago
$startDate = new Zend_Date($arguments['s'], "dd/MM/yyyy");
$startDate->setHour(00);
$startDate->setMinute(00);
$startDate->setSecond(00);
//Yesterday, some networks don't give us the data for the same day, then is the safer way to have our data
$endDate = new Zend_Date($arguments['e'], "dd/MM/yyyy");
$endDate->setHour(23);
$endDate->setMinute(59);
$endDate->setSecond(59);
//are we connected?
fwrite(STDERR, "\nAccessing to your account \n\n");
if ($network->checkConnection()) {
fwrite(STDERR, "Connected successfully \n\n");
if (!isset($arguments['t']) || $arguments['t'] == 'payment') {
fwrite(STDERR, "Getting payments, please wait \n\n");
//Get all the payments for this network.
$paymentsList = $network->getPaymentHistory();
fwrite(STDERR, "Number of payments: " . count($paymentsList) . "\n\n");
fwrite(STDERR, "------------------------------------------------------------------------\n");
fwrite(STDERR, "ID\t\t\tDATE\t\t\t\t\tVALUE\n");
fwrite(STDERR, "------------------------------------------------------------------------\n");
foreach ($paymentsList as $payment) {
$paymentDate = new Zend_Date($payment['date'], "yyyy-MM-dd HH:mm:ss");
if ($paymentDate->compare($startDate) >= 0 && $paymentDate->compare($endDate) <= 0) {
fwrite(STDERR, $payment['pid'] . "\t\t\t" . $payment['date'] . "\t\t\t" . $payment['value'] . " \n");
}
}
if (isset($arguments['t']) && $arguments['t'] == 'payment') {
return null;
}
}
//Get all the Merhcants
fwrite(STDERR, "\nGetting merchants, please wait \n\n");
$merchantList = $network->getMerchantList(array());
if (!isset($arguments['t']) || $arguments['t'] == 'merchant') {
fwrite(STDERR, "Number of merchants: " . count($merchantList) . "\n\n");
fwrite(STDERR, "--------------------------------------------------\n");
fwrite(STDERR, "ID\t\t\tNAME\n");
fwrite(STDERR, "--------------------------------------------------\n");
foreach ($merchantList as $merchant) {
fwrite(STDERR, $merchant['cid'] . "\t\t\t" . $merchant['name'] . " \n");
}
if (isset($arguments['t']) && $arguments['t'] == 'merchant') {
return null;
}
}
// Building the array of merchant Id we want to retrieve data from.
$merchantIdList = array();
foreach ($merchantList as $merchant) {
$merchantIdList[] = $merchant['cid'];
}
//If we have joined any merchant
if (!empty($merchantIdList)) {
$merchantMap = array();
foreach ($merchantList as $merchant) {
$merchantMap[$merchant['name']] = $merchant['cid'];
}
//Split the dates monthly, Most of the network don't allow us to retrieve more than a month data
$dateArray = Oara_Utilities::monthsOfDifference($startDate, $endDate);
for ($i = 0; $i < count($dateArray); $i++) {
// Calculating the start and end date for the current month
$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 = $endDate;
}
$monthEndDate->setHour(23);
$monthEndDate->setMinute(59);
$monthEndDate->setSecond(59);
fwrite(STDERR, "\n*Importing data from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n\n");
fwrite(STDERR, "Getting transactions, please wait \n\n");
$transactionList = $network->getTransactionList($merchantIdList, $monthStartDate, $monthEndDate, $merchantMap);
if (!isset($arguments['t']) || $arguments['t'] == 'transaction') {
fwrite(STDERR, "Number of transactions: " . count($transactionList) . "\n\n");
$totalAmount = 0;
$totalCommission = 0;
foreach ($transactionList as $transaction) {
$totalAmount += $transaction['amount'];
$totalCommission += $transaction['commission'];
}
fwrite(STDERR, "--------------------------------------------------\n");
fwrite(STDERR, "TOTAL AMOUNT\t\t{$totalAmount}\n");
fwrite(STDERR, "TOTAL COMMISSION\t{$totalCommission}\n");
fwrite(STDERR, "--------------------------------------------------\n\n");
}
}
//.........这里部分代码省略.........
示例4: paymentTransactions
/**
* 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;
}