本文整理汇总了PHP中Zend_Date::setMinute方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setMinute方法的具体用法?PHP Zend_Date::setMinute怎么用?PHP Zend_Date::setMinute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::setMinute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTransactionList
/**
* (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();
$urls = array();
$exportParams = array(new Oara_Curl_Parameter('agentcode', $this->_credentials['user']), new Oara_Curl_Parameter('pword', $this->_credentials['password']), new Oara_Curl_Parameter('fromdate', $dStartDate->toString("dd-MM-yyyy")), new Oara_Curl_Parameter('todate', $dEndDate->toString("dd-MM-yyyy")), new Oara_Curl_Parameter('rqtype', "report"));
$urls[] = new Oara_Curl_Request('https://www.parkandgo.co.uk/agents/', $exportParams);
$exportReport = $this->_client->post($urls);
$today = new Zend_Date();
$today->setHour(0);
$today->setMinute(0);
$exportData = str_getcsv($exportReport[0], "\n");
$num = count($exportData);
for ($i = 1; $i < $num; $i++) {
$transactionExportArray = str_getcsv($exportData[$i], ",");
$arrivalDate = new Zend_Date($transactionExportArray[3], 'yyyy-MM-dd 00:00:00', 'en');
$transaction = array();
$transaction['merchantId'] = 1;
$transaction['unique_id'] = $transactionExportArray[0];
$transactionDate = new Zend_Date($transactionExportArray[2], 'yyyy-MM-dd 00:00:00', 'en');
$transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
unset($transactionDate);
$transaction['status'] = Oara_Utilities::STATUS_PENDING;
if ($today > $arrivalDate) {
$transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
}
$transaction['amount'] = Oara_Utilities::parseDouble($transactionExportArray[6]);
$transaction['commission'] = Oara_Utilities::parseDouble($transactionExportArray[7]);
$totalTransactions[] = $transaction;
}
return $totalTransactions;
}
示例2: getTransactionList
/**
* (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();
$report = $this->_adsense->reports->generate($dStartDate->toString("YYYY-MM-dd"), $dEndDate->toString("YYYY-MM-dd"), array("dimension" => "DATE", "metric" => array("PAGE_VIEWS", "CLICKS", "EARNINGS"), "sort" => "DATE"));
$firstDayMonth = new Zend_Date();
$firstDayMonth->setDay(1);
$firstDayMonth->setHour("00");
$firstDayMonth->setMinute("00");
$firstDayMonth->setSecond("00");
if (isset($report["rows"])) {
foreach ($report["rows"] as $row) {
$obj = array();
$obj['merchantId'] = 1;
$tDate = new Zend_Date($row[0], "yyyy-MM-dd");
$tDate->setHour("00");
$tDate->setMinute("00");
$tDate->setSecond("00");
$obj['date'] = $tDate->toString("yyyy-MM-dd HH:mm:ss");
$obj['impression_number'] = (int) Oara_Utilities::parseDouble($row[1]);
$obj['click_number'] = Oara_Utilities::parseDouble($row[2]);
if ($firstDayMonth->compare($tDate) <= 0) {
$obj['amount'] = Oara_Utilities::parseDouble($row[3]);
$obj['commission'] = Oara_Utilities::parseDouble($row[3]);
$obj['status'] = Oara_Utilities::STATUS_PENDING;
} else {
$obj['amount'] = Oara_Utilities::parseDouble($row[3]);
$obj['commission'] = Oara_Utilities::parseDouble($row[3]);
$obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
}
$totalTransactions[] = $obj;
}
}
return $totalTransactions;
}
示例3: _convertDate
protected function _convertDate($date, $locale)
{
$dateObj = new Zend_Date();
//set begining of day
$dateObj->setHour(00);
$dateObj->setMinute(00);
$dateObj->setSecond(00);
//set date with applying timezone of store
$dateObj->set($date, Zend_Date::DATE_SHORT, $locale);
return $dateObj;
}
示例4: _prepareProduct
/**
* Prepare product and its configuration to be added to some products list.
* Perform standard preparation process and then add Configurable specific options.
*
* @param Varien_Object $buyRequest
* @param Mage_Catalog_Model_Product $product
* @param string $processMode
* @return array|string
*/
protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
{
if (!$product->getAwSarpEnabled()) {
return;
}
Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
$Period = Mage::getModel('sarp/period');
/* We should add custom options that doesn't exist */
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
$product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
if ((empty($options['aw_sarp_subscription_start']['month']) || empty($options['aw_sarp_subscription_start']['day']) || empty($options['aw_sarp_subscription_start']['year'])) && $buyRequest->getAwSarpSubscriptionType() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE) {
$date = new Zend_Date();
$buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
}
if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start']) && $buyRequest->getAwSarpSubscriptionType() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE && !empty($options['aw_sarp_subscription_start']['month']) && !empty($options['aw_sarp_subscription_start']['day']) && !empty($options['aw_sarp_subscription_start']['year'])) {
$subscriptionStart = $options['aw_sarp_subscription_start'];
$date = new Zend_Date();
$date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
$buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
}
if (!is_null($buyRequest->getAwSarpSubscriptionStart()) && $Period->getId()) {
$start = $buyRequest->getAwSarpSubscriptionStart();
if (!empty($start)) {
$date = new Zend_Date($start, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
} else {
$date = $Period->getNearestAvailableDay();
}
$performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
$today = new Zend_Date();
if (!$this->isVirtual($product)) {
$today->addDayOfYear($Period->getPaymentOffset());
}
if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
$date = $Period->getNearestAvailableDay();
}
} else {
$date = Mage::app()->getLocale()->date();
}
$product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
$_result = parent::_prepareProduct($buyRequest, $product, $processMode);
if (is_array($_result)) {
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->getId()) {
$_result[0]->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
$_result[0]->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
return $_result;
}
return $this->getSpecifyOptionMessage();
}
示例5: getDateRange
public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
{
$dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$dateStart = clone $dateEnd;
// go to the end of a day
$dateEnd->setHour(23);
$dateEnd->setMinute(59);
$dateEnd->setSecond(59);
$dateStart->setHour(0);
$dateStart->setMinute(0);
$dateStart->setSecond(0);
switch ($range) {
case '24h':
$dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$dateEnd->addHour(1);
$dateStart = clone $dateEnd;
$dateStart->subDay(1);
break;
case '7d':
// substract 6 days we need to include
// only today and not hte last one from range
$dateStart->subDay(6);
break;
case '1m':
$dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
break;
case 'custom':
$dateStart = $customStart ? $customStart : $dateEnd;
$dateEnd = $customEnd ? $customEnd : $dateEnd;
break;
case '1y':
case '2y':
$startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
$startMonth = isset($startMonthDay[0]) ? (int) $startMonthDay[0] : 1;
$startDay = isset($startMonthDay[1]) ? (int) $startMonthDay[1] : 1;
$dateStart->setMonth($startMonth);
$dateStart->setDay($startDay);
if ($range == '2y') {
$dateStart->subYear(1);
}
break;
}
if ($returnObjects) {
return array($dateStart, $dateEnd);
} else {
return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
}
}
示例6: getDateRange
public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
{
$dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$dateStart = clone $dateEnd;
// go to the end of a day
$dateEnd->setHour(23);
$dateEnd->setMinute(59);
$dateEnd->setSecond(59);
$dateStart->setHour(0);
$dateStart->setMinute(0);
$dateStart->setSecond(0);
switch ($range) {
case '24h':
$dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$dateEnd->addHour(1);
$dateStart = clone $dateEnd;
$dateStart->subDay(1);
break;
case '7d':
// substract 6 days we need to include
// only today and not hte last one from range
$dateStart->subDay(6);
break;
case '1m':
$dateStart->setDay(1);
break;
case 'custom':
$dateStart = $customStart ? $customStart : $dateEnd;
$dateEnd = $customEnd ? $customEnd : $dateEnd;
break;
case '1y':
$dateStart->setMonth(1);
$dateStart->setDay(1);
break;
case '2y':
$dateStart->setMonth(1);
$dateStart->setDay(1);
$dateStart->subYear(1);
break;
}
if ($returnObjects) {
return array($dateStart, $dateEnd);
} else {
return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
}
}
示例7: getTransactionList
/**
* (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();
$today = new Zend_Date();
$today->setHour(0);
$today->setMinute(0);
$urls = array();
$exportParams = array(new Oara_Curl_Parameter('data[query][agent]', $this->_agent), new Oara_Curl_Parameter('data[query][date1]', $dStartDate->toString("yyyy-MM-dd")), new Oara_Curl_Parameter('data[query][date2]', $dEndDate->toString("yyyy-MM-dd")), new Oara_Curl_Parameter('data[query][api_key]', $this->_apiKey));
$urls[] = new Oara_Curl_Request('http://www.skyparksecure.com/api/v4/jsonp/getSales?', $exportParams);
$exportReport = $this->_client->get($urls);
$report = substr($exportReport[0], 1, strlen($exportReport[0]) - 3);
$exportData = json_decode($report);
foreach ($exportData->result as $booking) {
$transaction = array();
$transaction['merchantId'] = 1;
$transaction['unique_id'] = $booking->booking_ref;
$transaction['metadata'] = $booking->product_name;
$transaction['custom_id'] = $booking->custom_id;
$transactionDate = new Zend_Date($booking->booking_date, 'yyyy.MMM.dd HH:mm:00', 'en');
$pickupDate = new Zend_Date($booking->dateA, 'yyyy.MMM.dd HH:mm:00', 'en');
$transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
$transaction['metadata'] = $booking->product_id;
if ($booking->booking_mode == "Booked" || $booking->booking_mode == "Amended") {
$transaction['status'] = Oara_Utilities::STATUS_PENDING;
if ($today > $pickupDate) {
$transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
}
} else {
if ($booking->booking_mode == "Cancelled") {
$transaction['status'] = Oara_Utilities::STATUS_DECLINED;
} else {
throw new Exception("New status found");
}
}
$transaction['amount'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $booking->sale_price)) / 1.2;
$transaction['commission'] = Oara_Utilities::parseDouble(preg_replace('/[^0-9\\.,]/', "", $booking->commission_affiliate)) / 1.2;
$totalTransactions[] = $transaction;
}
return $totalTransactions;
}
示例8: getShippingCostsAction
/**
* Returns all Shipping Costs
*
* @return array
*/
public function getShippingCostsAction()
{
$dispatchID = $this->Request()->getParam('dispatchID', null);
$limit = $this->Request()->getParam('limit', 20);
$offset = $this->Request()->getParam('start', 0);
$sort = $this->Request()->getParam('sort', array(array('property' => 'dispatch.name', 'direction' => 'ASC')));
$filter = $this->Request()->getParam('filter', null);
if (is_array($filter) && isset($filter[0]['value'])) {
$filter = $filter[0]['value'];
}
$query = $this->getRepository()->getShippingCostsQuery($dispatchID, $filter, $sort, $limit, $offset);
$shippingCosts = $query->getArrayResult();
$shippingCostsResult = array();
foreach ($shippingCosts as $shippingCost) {
if (!empty($shippingCost['bindTimeFrom'])) {
$date = new Zend_Date();
$date->setMinute(0);
$date->setHour(0);
$date->setSecond(0);
$shippingCost['bindTimeFrom'] = $date->addSecond($shippingCost['bindTimeFrom'])->toString("HH:mm");
}
if (!empty($shippingCost['bindTimeTo'])) {
$date = new Zend_Date();
$date->setMinute(0);
$date->setHour(0);
$date->setSecond(0);
$shippingCost['bindTimeTo'] = $date->addSecond($shippingCost['bindTimeTo'])->toString("HH:mm");
}
$shippingCostsResult[] = $shippingCost;
}
//returns the total count of the query
$totalResult = $this->getManager()->getQueryCount($query);
$this->View()->assign(array('success' => true, 'data' => $shippingCostsResult, 'total' => $totalResult));
}
示例9: prepareForCart
/**
* Prepares product for cart according to buyRequest.
*
* @param Varien_Object $buyRequest
* @param object $product [optional]
* @return
*/
public function prepareForCart(Varien_Object $buyRequest, $product = null, $old = false)
{
if (!$product->getAwSarpEnabled()) {
if (!$old) {
return parent::prepareForCart($buyRequest, $product);
}
return;
}
Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
/*
* For creating order from admin
* If product is added to cart from admin, we doesn't add sart custom options to it.
*/
$Period = Mage::getModel('sarp/period');
if ($product->getAwSarpPeriod()) {
if (count(explode(",", $product->getAwSarpPeriod())) === 1) {
$date = Mage::getModel('sarp/period')->load($product->getAwSarpPeriod())->getNearestAvailableDay();
$product->setAwSarpSubscriptionType($product->getAwSarpPeriod());
$product->setAwSarpSubscriptionStart($date->toString(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
}
}
/* We should add custom options that doesnt exist */
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
$product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
} else {
if ($product->getAwSarpSubscriptionType()) {
$buyRequest->setAwSarpSubscriptionType($product->getAwSarpSubscriptionType());
$product->addCustomOption('aw_sarp_subscription_type', $product->getAwSarpSubscriptionType());
$Period->setId($product->getAwSarpSubscriptionStart());
}
}
if ($this->requiresSubscriptionOptions($product) && !$Period->getId()) {
$date = Mage::app()->getLocale()->date();
}
$options = $buyRequest->getOptions();
if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start']) && !empty($options['aw_sarp_subscription_start']['day']) && !empty($options['aw_sarp_subscription_start']['month']) && !empty($options['aw_sarp_subscription_start']['year'])) {
$subscriptionStart = $options['aw_sarp_subscription_start'];
$date = new Zend_Date();
$date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
$buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
}
if (!is_null($buyRequest->getAwSarpSubscriptionStart()) && $Period->getId()) {
$start = $buyRequest->getAwSarpSubscriptionStart();
if (!empty($start)) {
$date = new Zend_Date($start, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
} else {
$date = $Period->getNearestAvailableDay();
}
// Check date
// Never check if start date
//$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
$performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
$today = new Zend_Date();
if (!$this->isVirtual($product)) {
$today->addDayOfYear($Period->getPaymentOffset());
}
if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
$date = $Period->getNearestAvailableDay();
}
} else {
$date = Mage::app()->getLocale()->date();
}
$product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
if (!$old) {
return parent::prepareForCart($buyRequest, $product);
}
}
示例10: getOverviewList
/**
* (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);
$affjetNetClickDao = Dao_Factory_Doctrine::createDoctrineDaoInstance('AffjetNetClick');
$criteriaList = array();
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Select('AffjetNetUserRAffjetNetMerchant->AffjetNetMerchant->id', "_merchantId");
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Select('date', "_date");
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Select('COUNT(*)', "_clickNumber", true);
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_In('AffjetNetUserRAffjetNetMerchant->AffjetNetMerchant->id', $merchantList, false);
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Eq('AffjetNetUserRAffjetNetMerchant->AffjetNetMerchant->AffjetNetPartner->id', $this->_partnerId);
if (!$this->_isAdmin) {
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Eq('AffjetNetUserRAffjetNetMerchant->AffjetNetUser->id', $this->_userId);
}
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Ge('date', $dStartDate->toString("yyyy-MM-dd HH:mm:ss"));
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Le('date', $dEndDate->toString("yyyy-MM-dd HH:mm:ss"));
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Groupby('AffjetNetUserRAffjetNetMerchant->AffjetNetMerchant->id');
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Groupby('date', 'DAY');
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Groupby('date', 'MONTH');
$criteriaList[] = new Dao_Doctrine_Criteria_Restriction_Groupby('date', 'YEAR');
$affjetNetClickList = $affjetNetClickDao->findBy($criteriaList);
foreach ($affjetNetClickList as $affjetNetClick) {
$overview = array();
$overviewDate = new Zend_Date($affjetNetClick->_date, "yyyy-MM-dd HH:mm:ss");
$overviewDate->setHour(0);
$overviewDate->setMinute(0);
$overviewDate->setSecond(0);
$overview['merchantId'] = $affjetNetClick->_merchantId;
$overview['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss");
$overview['click_number'] = $affjetNetClick->_clickNumber;
$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;
$transactionList = Oara_Utilities::getDayFromArray($affjetNetClick->_merchantId, $transactionArray, $overviewDate);
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'];
}
}
}
}
$totalOverviews[] = $overview;
}
return $totalOverviews;
}
示例11: realpath
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_ENV', 'development');
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../vendor/ZendFramework/library'), get_include_path())));
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();
// the needed resources
$frontController = $application->getBootstrap()->getResource('FrontController');
$view = $application->getBootstrap()->getResource('View');
// init request
$request = new Zend_Controller_Request_Http();
$request->setControllerName('partner-usage');
$request->setActionName('export-csv');
$fromDate = new Zend_Date();
$fromDate->setHour(0);
$fromDate->setMinute(0);
$fromDate->setSecond(0);
$fromDate->setDay(1);
$fromDate->addMonth(-1);
$request->setParam('from_date', $fromDate->getTimestamp());
// beginning of last month
$toDate = new Zend_Date($fromDate);
$toDate->addMonth(1);
$toDate->addSecond(-1);
$request->setParam('to_date', $toDate->getTimestamp());
// end of last month
// init response
$response = new Zend_Controller_Response_Cli();
// dispatch
$frontController->getDispatcher()->dispatch($request, $response);
// send mail
示例12: setStartDate
/**
* Set the start date for this event
*
* @param Zend_Date $date
* @param boolean $wholeDay
* @return Zym_Calendar_Event
*/
public function setStartDate(Zend_Date $date, $wholeDay = false)
{
if ($wholeDay) {
$date->setHour(0);
$date->setMinute(0);
$date->setSecond(0);
$date->setMilliSecond(0);
$endDate = clone $date;
$endDate->setHour(23);
$endDate->setMinute(59);
$endDate->setSecond(59);
$this->setEndDate($endDate);
}
$this->_startDate = $date;
return $this;
}
示例13: calcDate
/**
* Calculate date
*
* @param number $value
* @param string $unit
* @param number $roundDate
* @return Zend_Date
*/
public function calcDate($value, $unit, $roundDate = null, $sign = '-')
{
// validate unit
if (!key_exists($unit, $this->getTimeUnitOptions())) {
return null;
}
$timestamp = strtotime("{$sign}{$value} {$unit}");
if ($timestamp) {
// don't calculate with extrem high numbers (preformance)
$timestamp = min(max($timestamp, 0), 10000000000.0);
$date = new Zend_Date();
$date->setTimestamp($timestamp);
if ($roundDate === self::DAY_START) {
$date->setHour(0);
$date->setMinute(0);
$date->setSecond(0);
} else {
if ($roundDate === self::DAY_END) {
$date->setHour(23);
$date->setMinute(59);
$date->setSecond(59);
}
}
return $date;
}
return null;
}
示例14: getOverviewList
/**
* (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;
}
示例15: prepareForCartAdvanced
public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode = null)
{
Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
$Period = Mage::getModel('sarp/period');
/* We should add custom options that doesnt exist */
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
$product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
$options = $buyRequest->getOptions();
if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start'])) {
$subscriptionStart = $options['aw_sarp_subscription_start'];
$date = new Zend_Date();
$date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
$buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
}
if ($buyRequest->getAwSarpSubscriptionStart() && $Period->getId()) {
$date = new Zend_Date($buyRequest->getAwSarpSubscriptionStart(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
// Check date
// Never check if start date
//$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
$performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
$today = new Zend_Date();
if (!$this->isVirtual($product)) {
$today->addDayOfYear($Period->getPaymentOffset());
}
if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected date is not valid for specified period"));
}
} else {
$date = Mage::app()->getLocale()->date();
}
$product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
if ($attributes = $buyRequest->getSuperAttribute()) {
$result = Mage_Catalog_Model_Product_Type_Abstract::prepareForCartAdvanced($buyRequest, $product);
if (is_array($result)) {
$product = $this->getProduct($product);
/**
* $attributes = array($attributeId=>$attributeValue)
*/
if ($subProduct = $this->getProductByAttributes($attributes, $product)) {
$product->addCustomOption('attributes', serialize($attributes));
$product->addCustomOption('product_qty_' . $subProduct->getId(), 1, $subProduct);
$product->addCustomOption('simple_product', $subProduct->getId(), $subProduct);
$_result = $subProduct->getTypeInstance(true)->prepareForCartAdvanced($buyRequest, $subProduct);
if (is_string($_result) && !is_array($_result)) {
return $_result;
}
if (!isset($_result[0])) {
return Mage::helper('checkout')->__('Can not add item to shopping cart');
}
/**
* Adding parent product custom options to child product
* to be sure that it will be unique as its parent
*/
if ($optionIds = $product->getCustomOption('option_ids')) {
$optionIds = explode(',', $optionIds->getValue());
foreach ($optionIds as $optionId) {
if ($option = $product->getCustomOption('option_' . $optionId)) {
$_result[0]->addCustomOption('option_' . $optionId, $option->getValue());
}
}
}
if ($buyRequest->getAwSarpSubscriptionType()) {
if ($Period->getId()) {
$_result[0]->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
$_result[0]->addCustomOption('aw_sarp_subscription_type', $Period->getId());
}
}
$_result[0]->setParentProductId($product->getId())->addCustomOption('parent_product_id', $product->getId())->setCartQty(1);
$result[] = $_result[0];
return $result;
}
}
}
return $this->getSpecifyOptionMessage();
}