本文整理汇总了PHP中Zend_Date::setHour方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setHour方法的具体用法?PHP Zend_Date::setHour怎么用?PHP Zend_Date::setHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::setHour方法的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: _beforeSave
/**
* Prepare object data for saving
*
* @param Mage_Core_Model_Abstract $object
*/
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getFromDate()) {
$date = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$date->setHour(0)->setMinute(0)->setSecond(0);
$object->setFromDate($date);
}
$object->setFromDate($object->getFromDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
if (!$object->getToDate()) {
$object->setToDate(new Zend_Db_Expr('NULL'));
} else {
$object->setToDate($object->getToDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
}
parent::_beforeSave($object);
}
示例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: createNew
public static function createNew($rule, $startFrom = null)
{
$date = new Zend_Date();
$date->addDay((int) $rule->getCouponExpireDays());
$date->setHour(0)->setMinute(0)->setSecond(0);
if (!is_null($startFrom)) {
$date->addDay((int) $startFrom);
}
$coupon = Mage::getModel('followupemail/coupons');
$salesRule = Mage::getModel('salesrule/rule')->load($rule->getCouponSalesRuleId());
if ($salesRule->getData()) {
$_usagePerCustomer = $salesRule->getUsesPerCustomer() && is_numeric($salesRule->getUsesPerCustomer()) ? $salesRule->getUsesPerCustomer() : 1;
$coupon->setRuleId($rule->getCouponSalesRuleId())->setExpirationDate($date)->setCode(Mage::helper('followupemail/coupon')->generateCode($rule->getId(), $rule->getCouponPrefix()))->setUsagePerCustomer($_usagePerCustomer)->setUsageLimit($_usagePerCustomer);
$coupon->save();
}
return $coupon;
}
示例7: 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);
}
}
示例8: filterListQuery
/**
* Filters the displayed fields by the passed filter value.
*
* @param \Doctrine\ORM\QueryBuilder $builder
* @param array|null $filters
* @return \Doctrine\ORM\QueryBuilder
*/
protected function filterListQuery(\Doctrine\ORM\QueryBuilder $builder, $filters = null)
{
$expr = Shopware()->Models()->getExpressionBuilder();
if (!empty($filters)) {
foreach ($filters as $filter) {
if (empty($filter['property']) || $filter['value'] === null || $filter['value'] === '') {
continue;
}
switch ($filter['property']) {
case "free":
$builder->andWhere($expr->orX($expr->like('orders.number', '?1'), $expr->like('orders.invoiceAmount', '?1'), $expr->like('orders.transactionId', '?1'), $expr->like('payment.description', '?1'), $expr->like('dispatch.name', '?1'), $expr->like('orderStatus.description', '?1'), $expr->like('paymentStatus.description', '?1'), $expr->like('orders.orderTime', '?2'), $expr->like('billing.company', '?3'), $expr->like('customer.email', '?3'), $expr->like('billing.lastName', '?3'), $expr->like('billing.firstName', '?3'), $expr->like('shop.name', '?3'), $expr->like('orders.comment', '?3'), $expr->like('orders.customerComment', '?3'), $expr->like('orders.internalComment', '?3')));
$builder->setParameter(1, $filter['value'] . '%');
$builder->setParameter(2, '%' . $filter['value']);
$builder->setParameter(3, '%' . $filter['value'] . '%');
break;
case "from":
$tmp = new \DateTime($filter['value']);
$builder->andWhere($expr->gte('orders.orderTime', $tmp->format('Ymd')));
break;
case "to":
$tmp = new \Zend_Date($filter['value']);
$tmp->setHour('23');
$tmp->setMinute('59');
$tmp->setSecond('59');
$builder->andWhere('orders.orderTime <= :orderTimeTo');
$builder->setParameter('orderTimeTo', $tmp->get('yyyy-MM-dd HH:mm:ss'));
break;
case 'details.articleNumber':
$builder->andWhere('details.articleNumber LIKE :articleNumber');
$builder->setParameter('articleNumber', $filter['value'] . "%");
break;
case 'customer.groupKey':
$builder->andWhere($expr->eq($filter['property'], "'" . $filter['value'] . "'"));
break;
default:
$builder->andWhere($expr->eq($filter['property'], $filter['value']));
}
}
}
return $builder;
}
示例9: testSetHour
/**
* Test for setTime
*/
public function testSetHour()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1234567890, null, $locale);
$this->assertSame($date->get(Zend_Date::W3C), '2009-02-14T00:31:30+01:00');
for ($i = 23; $i >= 0; $i--) {
$date->setHour($i);
$hour = $i;
if ($i < 10) {
$hour = '0' . $hour;
}
$this->assertSame($date->get(Zend_Date::W3C), "2009-02-14T{$hour}:31:30+01:00");
}
}
示例10: 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;
}
示例11: exportOrdersAction
/**
* Export orders
*/
public function exportOrdersAction()
{
$this->Front()->Plugins()->Json()->setRenderer(false);
$format = strtolower($this->Request()->getParam('format', 'csv'));
/** @var \Shopware\Models\Order\Repository $repository */
$repository = $this->getManager()->getRepository('Shopware\\Models\\Order\\Order');
/** @var \Shopware\Components\Model\ModelRepository $currencyRepostiroy */
$currencyRepository = $this->getManager()->getRepository('Shopware\\Models\\Shop\\Currency');
$builder = $repository->createQueryBuilder('orders');
$orderState = $this->Request()->getParam('orderstate');
if (is_numeric($orderState)) {
$builder->andWhere('orders.status = :orderstate');
$builder->setParameter('orderstate', $orderState);
}
$paymentState = $this->Request()->getParam('paymentstate');
if (is_numeric($paymentState)) {
$builder->andWhere('orders.cleared = :paymentstate');
$builder->setParameter('paymentstate', $paymentState);
}
$orderNumberFrom = $this->Request()->getParam('ordernumberFrom');
if (is_numeric($orderNumberFrom)) {
$builder->andWhere('orders.number > :orderNumberFrom');
$builder->setParameter('orderNumberFrom', $orderNumberFrom);
}
$dateFrom = $this->Request()->getParam('dateFrom');
if ($dateFrom) {
$dateFrom = new \DateTime($dateFrom);
$builder->andWhere('orders.orderTime >= :dateFrom');
$builder->setParameter('dateFrom', $dateFrom);
}
$dateTo = $this->Request()->getParam('dateTo');
if ($dateTo) {
$dateTo = new Zend_Date($dateTo);
$dateTo->setHour('23');
$dateTo->setMinute('59');
$dateTo->setSecond('59');
$builder->andWhere('orders.orderTime <= :dateTo');
$builder->setParameter('dateTo', $dateTo->get('yyyy-MM-dd HH:mm:ss'));
}
if ($format == 'xml') {
$selectFields = array('orders', 'details', 'documents', 'payment', 'customer', 'shipping', 'billing', 'billingCountry', 'shippingCountry', 'shop', 'dispatch', 'paymentStatus', 'orderStatus', 'documentType');
}
if ($format == 'csv' || $format == 'excel') {
$selectFields = array('orders.id as orderId', 'orders.number as ordernumber', 'orders.orderTime as ordertime', 'orders.customerId as customerID', 'orders.paymentId as paymentID', 'orders.transactionId as transactionID', 'orders.partnerId as partnerID', 'orders.cleared as clearedID', 'orders.status as statusID', 'dispatch.id as dispatchID', 'orders.shopId as subshopID', 'orders.invoiceAmount as invoice_amount', 'orders.invoiceAmountNet as invoice_amount_net', 'orders.invoiceShipping as invoice_shipping', 'orders.invoiceShippingNet as invoice_shipping_net', 'orders.net as netto', 'paymentStatus.description as cleared_description', 'orderStatus.description as status_description', 'payment.description as payment_description', 'dispatch.description as dispatch_description', 'orders.id as currency_description', 'orders.referer as referer', 'orders.clearedDate as cleareddate', 'orders.trackingCode as trackingcode', 'orders.languageIso as language', 'orders.currency as currency', 'orders.currencyFactor as currencyFactor', 'orders.id as count_positions', 'details.id as orderdetailsID', 'details.articleId as articleID', 'details.articleNumber as articleordernumber', 'details.articleName as name', 'details.price as price', 'details.quantity as quantity', 'details.ean as ean', 'details.unit as unit', 'details.packUnit as packUnit', 'details.price * details.quantity as invoice', 'details.releaseDate as releasedate', 'taxes.tax as tax', 'details.esdArticle as esd', 'details.mode as modus', 'customerBilling.number as customernumber', 'billing.company as billing_company', 'billing.department as billing_department', 'billing.salutation as billing_salutation', 'billing.firstName as billing_firstname', 'billing.lastName as billing_lastname', 'billing.street as billing_street', 'billing.streetNumber as billing_streetnumber', 'billing.zipCode as billing_zipcode', 'billing.city as billing_city', 'billingCountry.name as billing_country', 'billingCountry.isoName as billing_countryen', 'billingCountry.iso as billing_countryiso', 'shipping.company as shipping_company', 'shipping.department as shipping_department', 'shipping.salutation as shipping_salutation', 'shipping.firstName as shipping_firstname', 'shipping.lastName as shipping_lastname', 'shipping.street as shipping_street', 'shipping.streetNumber as shipping_streetnumber', 'shipping.zipCode as shipping_zipcode', 'shipping.city as shipping_city', 'shippingCountry.name as shipping_country', 'shippingCountry.isoName as shipping_countryen', 'shippingCountry.iso as shipping_countryiso', 'billing.vatId as ustid', 'billing.phone as phone', 'billing.fax as fax', 'customer.email as email', 'customer.groupKey as customergroup', 'customer.newsletter as newsletter', 'customer.affiliate as affiliate');
$builder->addGroupBy('orderdetailsID');
}
$builder->select($selectFields);
$builder->leftJoin('orders.details', 'details')->leftJoin('details.tax', 'taxes')->leftJoin('orders.documents', 'documents')->leftJoin('documents.type', 'documentType')->leftJoin('orders.payment', 'payment')->leftJoin('orders.paymentStatus', 'paymentStatus')->leftJoin('orders.orderStatus', 'orderStatus')->leftJoin('orders.customer', 'customer')->leftJoin('customer.billing', 'customerBilling')->leftJoin('orders.billing', 'billing')->leftJoin('billing.country', 'billingCountry')->leftJoin('orders.shipping', 'shipping')->leftJoin('orders.shop', 'shop')->leftJoin('orders.dispatch', 'dispatch')->leftJoin('shipping.country', 'shippingCountry');
$builder->addOrderBy('orders.orderTime');
$query = $builder->getQuery();
$result = $query->getArrayResult();
$updateStateId = $this->Request()->getParam('updateOrderstate');
if (!empty($updateStateId)) {
$orderIds = array();
if ($format == 'csv' || $format == 'excel') {
foreach ($result as $item) {
$orderIds[] = $item['orderId'];
}
$orderIds = array_unique($orderIds);
}
if ($format == 'xml') {
foreach ($result as $item) {
$orderIds[] = $item['id'];
}
}
$this->updateOrderStatus($orderIds, $updateStateId);
}
if ($format == 'csv' || $format == 'excel') {
$builder = $repository->createQueryBuilder('orders');
$builder->select(array('count(details.id) as count_positions'));
$builder->leftJoin('orders.details', 'details')->andWhere('details.orderId = :orderId')->groupBy('orders.id');
foreach ($result as &$item) {
$builder->setParameter('orderId', $item['orderId']);
try {
$item['count_positions'] = $builder->getQuery()->getSingleScalarResult();
} catch (\Exception $e) {
$item['count_positions'] = 0;
}
$currencyModel = $currencyRepository->findOneBy(array('currency' => $item['currency']));
if ($currencyModel) {
$item['currency_description'] = $currencyModel->getName();
} else {
$item['currency_description'] = '';
}
// Format tax
$item['tax'] = (double) $item['tax'];
}
array_walk_recursive($result, function (&$value) {
if ($value instanceof DateTime) {
$value = $value->format('Y-m-d H:i:s');
}
});
if ($format === 'excel') {
$this->Response()->setHeader('Content-Type', 'application/vnd.ms-excel;charset=UTF-8');
$this->Response()->setHeader('Content-Disposition', 'attachment; filename="export.orders.' . date("Y.m.d") . '.xls"');
$this->Response()->setHeader('Content-Transfer-Encoding', 'binary');
$excel = new Shopware_Components_Convert_Excel();
//.........这里部分代码省略.........
示例12: testLoose
//.........这里部分代码省略.........
// success
}
try {
$date->compareWeekday(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareDayOfYear(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setHour(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addHour(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->subHour(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareHour(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->setMinute(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->addMinute(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
示例13: 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);
示例14: _processFilter
/**
* @param $filter
*
* @return mixed
*/
protected function _processFilter($filter)
{
$period = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS;
if (array_key_exists('period', $filter)) {
$period = intval($filter['period']);
}
$filter['period'] = $period;
$fromDate = new Zend_Date();
$toDate = new Zend_Date();
$fromDate->setHour(23)->setMinute(59)->setSecond(59);
$toDate->setHour(23)->setMinute(59)->setSecond(59);
switch ($period) {
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_TODAY:
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_YESTERDAY:
$fromDate->subDay(1);
$toDate->subDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_WEEK:
$firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
if ($firstDayOfWeek === 0) {
$firstDayOfWeek = 7;
}
$fromDate->setWeekday($firstDayOfWeek);
if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
$fromDate->subWeek(1);
}
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_WEEK:
$fromDate->subWeek(1);
$toDate->subWeek(1);
$firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
if ($firstDayOfWeek === 0) {
$firstDayOfWeek = 7;
}
$fromDate->setWeekday($firstDayOfWeek);
if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
$fromDate->subWeek(1);
}
$lastDayOfWeek = $firstDayOfWeek - 1;
if ($lastDayOfWeek < 1) {
$lastDayOfWeek = 7;
}
$toDate->setWeekday($lastDayOfWeek);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_MONTH:
$fromDate->setDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_MONTH:
$fromDate->subMonth(1)->setDay(1);
$toDate->setDay(1)->subDay(1);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SIX_MONTHS:
$fromDate->subMonth(6);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_CUSTOM:
$_reversed = false;
$_now = new Zend_Date(null, 'dd/MM/y');
try {
$_fromDate = new Zend_Date($filter['from_date'], 'dd/MM/y');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "From" date value'));
$_fromDate = clone $_now;
}
try {
$_toDate = new Zend_Date($filter['to_date'], 'dd/MM/y');
if ($_fromDate->compare($_toDate) > 0) {
$_reversed = true;
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "To" date value'));
$_toDate = clone $_now;
}
if ($_reversed) {
$fromDate = $_toDate;
$toDate = $_fromDate;
} else {
$fromDate = $_fromDate;
$toDate = $_toDate;
}
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SEVEN_DAYS:
$fromDate->subDay(6);
break;
case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS:
$fromDate->subDay(29);
break;
}
$filter['from_date'] = $fromDate;
$filter['to_date'] = $toDate;
if (!array_key_exists('group', $filter)) {
$filter['group'] = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::GROUP_BY_WEEK;
}
if (!array_key_exists('agents[]', $filter)) {
$filter['agents[]'] = $this->_getAgentIds();
//.........这里部分代码省略.........
示例15: storeDate
/**
* Create Zend_Date object with date converted to store timezone and store Locale
*
* This method from Mage_Core_Model_Locale.
* This need for backward compatibility with older magento versions which not have 4th parameter in this method
*
* @param mixed $store Information about store
* @param string|integer|Zend_Date|array|null $date date in UTC
* @param boolean $includeTime flag for including time to date
* @param string|null $format
* @return Zend_Date
*/
public function storeDate($store = null, $date = null, $includeTime = false, $format = null)
{
$timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
$date = new Zend_Date($date, $format, Mage::app()->getLocale()->getLocale());
$date->setTimezone($timezone);
if (!$includeTime) {
$date->setHour(0)->setMinute(0)->setSecond(0);
}
return $date;
}