本文整理汇总了PHP中Zend_Date::subHour方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::subHour方法的具体用法?PHP Zend_Date::subHour怎么用?PHP Zend_Date::subHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::subHour方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($lastRunDt = null)
{
$config = Zend_Registry::get('config');
$checkDtStart = new Zend_Date($this->_lastRunDt);
$checkDtStart->subHour($config->user->numHoursEvaluationReminder->val);
$checkDtEnd = new Zend_Date();
$checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val);
$event = new Event();
$events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
$location = new Location();
$workshop = new Workshop();
$instructor = new Event_Instructor();
$attendee = new Event_Attendee();
$eu = new Evaluation_User();
foreach ($events as $e) {
$startDt = strtotime($e->date . ' ' . $e->startTime);
$endDt = strtotime($e->date . ' ' . $e->endTime);
if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
$evalAvailableDt = new Zend_Date($endDt);
$evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val);
if ($evalAvailableDt->getTimestamp() > time()) {
$taken = $eu->getCompleted($e->eventId);
$thisLocation = $location->find($e->locationId);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('msg-error-noLocation');
}
$thisWorkshop = $workshop->find($e->workshopId);
if (is_null($thisWorkshop)) {
throw new Ot_Exception_Data('msg-error-noWorkshop');
}
$instructors = $instructor->getInstructorsForEvent($e->eventId);
$instructorNames = array();
$instructorEmails = array();
foreach ($instructors as $i) {
$instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
$instructorEmails[] = $i['emailAddress'];
}
$data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
$attending = $attendee->getAttendeesForEvent($e->eventId, 'attending');
foreach ($attending as $a) {
if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) {
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
$trigger->accountId = $a['accountId'];
$trigger->studentEmail = $a['emailAddress'];
$trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
$trigger->studentUsername = $a['username'];
$trigger->dispatch('Event_Evaluation_Reminder');
}
}
}
}
}
}
示例2: cancelarAction
public function cancelarAction()
{
$agenda_id = $this->getRequest()->getParam('id');
$agenda_id = $this->getRequest()->getParam('id');
if (!$agenda_id) {
$this->_helper->flashMessenger->addMessage(array('danger' => "Agendamento não encontrado!"));
$this->_redirect("cliente/");
}
/**
* busca dados do agendamento
*/
$modelAgenda = new Model_DbTable_Agenda();
$agenda = $modelAgenda->getById($agenda_id);
/**
* Verifica se o agendamento e do usuario logado
*/
if ($agenda->usuario_id !== Zend_Auth::getInstance()->getIdentity()->usuario_id) {
$this->_helper->flashMessenger->addMessage(array('danger' => "<strong>Acesso negado!</strong> Você não pode alterar este agendamento!"));
$this->_redirect("cliente/");
}
/**
* verifica se pode alterar a data
*/
$modelConfig = new Model_DbTable_Config();
$prazoCancelamento = $modelConfig->getBySlug('prazo_alterar_agendamento');
$zendDateNow = new Zend_Date();
$zendDateAgenda = new Zend_Date($agenda->agenda_data);
if (!$zendDateNow->isEarlier($zendDateAgenda->subHour($prazoCancelamento->config_valor))) {
$this->_helper->flashMessenger->addMessage(array('warning' => "<strong>Atenção!</strong> O prazo para alterar este agendamento já expirou!"));
$this->_redirect("cliente/");
}
$this->view->agenda = $agenda;
/**
* form de motivo
*/
$formMotivo = new Form_Salao_AgendaManualCancelamento();
$formMotivo->submit->setLabel("Cancelar Agendamento");
$this->view->formMotivo = $formMotivo;
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost();
if ($formMotivo->isValid($data)) {
$agenda_cancelado_motivo = $formMotivo->getValue('agenda_cancelado_motivo');
try {
Zend_Db_Table_Abstract::getDefaultAdapter()->beginTransaction();
$update = array('agenda_cancelado' => 1, 'agenda_cancelado_autor' => 'Cliente', 'agenda_cancelado_usuario' => 1, 'agenda_cancelado_motivo' => $agenda_cancelado_motivo, 'agenda_cancelado_data' => Zend_Date::now()->get('YYYY-MM-dd H:m'));
$modelAgenda->updateById($update, $agenda_id);
/**
* envia o email de confirmacao (cliente)
*/
$pluginMail = new Plugin_Mail();
$pluginMail->setDataMail('agenda', $agenda);
$pluginMail->setDataMail('agenda_cancelado_motivo', $agenda_cancelado_motivo);
$pluginMail->send('cliente-agendamento-cancelar.phtml', 'Agendamento Cancelado', Zend_Auth::getInstance()->getIdentity()->usuario_email);
/**
* envia o email de confirmacao (salao)
*/
$pluginMail2 = new Plugin_Mail();
$pluginMail2->setDataMail('agenda', $agenda);
$pluginMail2->setDataMail('agenda_cancelado_motivo', $agenda_cancelado_motivo);
$pluginMail2->send('salao-agendamento-cancelar.phtml', 'Agendamento Cancelado', $agenda->salao_email);
Zend_Db_Table_Abstract::getDefaultAdapter()->commit();
// retira a cobranca do salao
$pluginCobranca = new Plugin_Cobranca($agenda);
$pluginCobranca->retirar();
$this->_helper->flashMessenger->addMessage(array('success' => 'Agendamento cancelado com sucesso.'));
$this->_redirect("cliente/");
} catch (Zend_Mail_Exception $ex) {
Zend_Db_Table_Abstract::getDefaultAdapter()->commit();
$this->_helper->flashMessenger->addMessage(array('success' => 'Agendamento cancelado com sucesso.'));
$this->_helper->flashMessenger->addMessage(array('warning' => 'Não foi possível enviar o e-mail de confirmação.'));
$this->_redirect("cliente/");
} catch (Exception $ex) {
Zend_Db_Table_Abstract::getDefaultAdapter()->rollBack();
$this->_helper->flashMessenger->addMessage(array('danger' => 'Não foi possível cancelar o agendamento. Tente novamente mais tarde. - ' . $ex->getMessage()));
$this->_redirect("cliente/");
}
}
}
}
示例3: testLoose
//.........这里部分代码省略.........
// 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) {
// success
}
try {
$date->subMinute(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
// success
}
try {
$date->compareMinute(null);
$this->fail();
} catch (Zend_Date_Exception $e) {
示例4: execute
public function execute($lastRunDt = null)
{
$config = Zend_Registry::get('config');
$event = new Event();
$events = $event->getEvents(null, null, null, time(), null, 'open');
$location = new Location();
$workshop = new Workshop();
$instructor = new Event_Instructor();
$attendees = new Event_Attendee();
$lastRunDt = new Zend_Date($this->_lastRunDt);
$currentDt = new Zend_Date();
foreach ($events as $e) {
$startDt = strtotime($e->date . ' ' . $e->startTime);
$endDt = strtotime($e->date . ' ' . $e->endTime);
$firstDt = new Zend_Date($startDt);
$firstDt->subHour($config->user->numHoursFirstReminder->val);
$finalDt = new Zend_Date($startDt);
$finalDt->subHour($config->user->numHoursFinalReminder->val);
$notification = null;
if ($firstDt->getTimestamp() > $lastRunDt->getTimestamp() && $firstDt->getTimestamp() < $currentDt->getTimestamp()) {
$notification = 'first';
}
if ($finalDt->getTimestamp() > $lastRunDt->getTimestamp() && $finalDt->getTimestamp() < $currentDt->getTimestamp()) {
$notification = 'final';
}
if (!is_null($notification)) {
$thisLocation = $location->find($e->locationId);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('msg-error-noLocation');
}
$thisWorkshop = $workshop->find($e->workshopId);
if (is_null($thisWorkshop)) {
throw new Ot_Exception_Data('msg-error-noWorkshop');
}
$instructors = $instructor->getInstructorsForEvent($e->eventId);
$instructorNames = array();
$instructorEmails = array();
foreach ($instructors as $i) {
$instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
$instructorEmails[] = $i['emailAddress'];
}
$data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
$attending = $attendees->getAttendeesForEvent($e->eventId, 'attending');
foreach ($attending as $a) {
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
$trigger->accountId = $a['accountId'];
$trigger->studentEmail = $a['emailAddress'];
$trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
if ($notification == 'final') {
$trigger->dispatch('Event_Attendee_Final_Reminder');
} else {
$trigger->dispatch('Event_Attendee_First_Reminder');
}
}
$trigger = new Ot_Trigger();
$trigger->setVariables($data);
if ($notification == 'final') {
$trigger->dispatch('Event_Instructor_Final_Reminder');
} else {
$trigger->dispatch('Event_Instructor_First_Reminder');
}
}
}
}
示例5: searchOrdersForReview
/**
* search for orders to review per website
*/
private function searchOrdersForReview()
{
$websites = $this->_helper->getwebsites(true);
foreach ($websites as $website) {
$apiEnabled = $this->_helper->isEnabled($website);
if ($apiEnabled && $this->_helper->getWebsiteConfig(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, $website) && $this->_reviewHelper->getOrderStatus($website) && $this->_reviewHelper->getDelay($website)) {
$storeIds = $website->getStoreIds();
if (empty($storeIds)) {
continue;
}
$orderStatusFromConfig = $this->_reviewHelper->getOrderStatus($website);
$delayInDays = $this->_reviewHelper->getDelay($website);
$campaignCollection = $this->_campaignCollection->create()->addFieldToFilter('event_name', 'Order Review')->load();
$campaignOrderIds = $campaignCollection->getColumnValues('order_increment_id');
$fromTime = new \Zend_Date();
$fromTime->subDay($delayInDays);
$toTime = clone $fromTime;
$to = $toTime->toString('YYYY-MM-dd HH:mm:ss');
$from = $fromTime->subHour(2)->toString('YYYY-MM-dd HH:mm:ss');
$created = array('from' => $from, 'to' => $to, 'date' => true);
$collection = $this->_orderCollection->create()->addFieldToFilter('main_table.status', $orderStatusFromConfig)->addFieldToFilter('main_table.created_at', $created)->addFieldToFilter('main_table.store_id', array('in' => $storeIds));
if (!empty($campaignOrderIds)) {
$collection->addFieldToFilter('main_table.increment_id', array('nin' => $campaignOrderIds));
}
//process rules on collection
$collection = $this->_rulesFactory->create()->process($collection, \Dotdigitalgroup\Email\Model\Rules::REVIEW, $website->getId());
if ($collection->getSize()) {
$this->_reviewCollection[$website->getId()] = $collection;
}
}
}
}
示例6: getRecentordercountGraphValues
public function getRecentordercountGraphValues()
{
$return = array();
$connection = $this->getReadConnection();
$oneHourAgo = new Zend_Date();
$oneHourAgo->subHour(1);
$oneHourAgo = $this->getResource()->formatDate($oneHourAgo);
foreach ($this->_getWebsites() as $website) {
$sql = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('created_at', array('from' => $oneHourAgo))->addFieldToFilter('store_id', array('in' => $website->getStoreIds()))->getSelectCountSql();
$recentOrderCount = $connection->fetchOne($sql);
$subArray = array('' => $recentOrderCount);
foreach ($website->getStoreCollection() as $store) {
$sql = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('created_at', array('from' => $oneHourAgo))->addFieldToFilter('store_id', $store->getId())->getSelectCountSql();
$recentOrderCount = $connection->fetchOne($sql);
$subArray['store_' . $store->getCode() . '.value'] = $recentOrderCount;
}
$return['website_' . $website->getCode() . '.value'] = $subArray;
}
return $return;
}
示例7: getEventsForUser
public function getEventsForUser($accountId)
{
$config = Zend_Registry::get('config');
$attendee = new Event_Attendee();
$instructor = new Event_Instructor();
$location = new Location();
$document = new Workshop_Document();
$account = new Ot_Account();
$eu = new Evaluation_User();
$stayOpen = new Zend_Date();
$stayOpen->subHour($config->user->numHoursEvaluationAvailability->val);
$locationCache = array();
$reservations = $attendee->getEventsForAttendee($accountId);
$time = time();
foreach ($reservations as &$r) {
$r['active'] = false;
// we determine if the class is open
$startDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['startTime']));
$endDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['endTime']));
$endDt->addHour($config->user->numHoursEvaluationAvailability->val);
$r['evaluatable'] = $this->isEvaluatable($r['eventId']);
// checks to see if its possible that the class is open for evaluation
if ($r['evaluatable'] && !$eu->hasCompleted($accountId, $r['eventId'])) {
$r['active'] = true;
} elseif ($startDt->getTimestamp() > $time) {
$r['active'] = true;
}
$r = array_merge(array('startDt' => $startDt->getTimestamp()), $r);
$r['hasHandouts'] = false;
$documents = $document->getDocumentsForWorkshop($r['workshopId']);
if (count($documents) > 0) {
$r['hasHandouts'] = true;
}
$r['cancelable'] = false;
if ($r['active']) {
$startDt->subHour($config->user->numHoursEventCancel->val);
$r['cancelable'] = $startDt->getTimestamp() > $time;
if ($r['status'] == 'waitlist') {
$waiting = $attendee->getAttendeesForEvent($r['eventId'], 'waitlist');
$position = 1;
foreach ($waiting as $w) {
if ($accountId == $w['accountId']) {
break;
}
$position++;
}
$r['waitlistPosition'] = $position;
}
}
}
// Get presently taught classes
$teaching = $instructor->getEventsForInstructor($accountId);
foreach ($teaching as &$t) {
$startDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['startTime']));
$endDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['endTime']));
$endDt->addHour($config->user->numHoursEvaluationAvailability->val);
$t = array_merge(array('startDt' => $startDt->getTimestamp()), $t);
$t['active'] = false;
// checks to see if its possible that the class is open for evaluation
if ($endDt->getTimestamp() > $time) {
$t['active'] = true;
}
$t['status'] = 'instructor';
}
$events = array_merge($reservations, $teaching);
// sort by event order
$eDates = array();
foreach ($events as $key => $value) {
$eDates[$key] = $value['startDt'];
}
asort($eDates);
$newEvents = array();
foreach (array_keys($eDates) as $key) {
$newEvents[] = $events[$key];
}
$events = $newEvents;
$currentEvents = array();
$pastEvents = array();
foreach ($events as $e) {
$where = $instructor->getAdapter()->quoteInto('eventId = ?', $e['eventId']);
$instructors = $instructor->fetchAll($where);
$instructorIds = array();
foreach ($instructors as $i) {
$instructorIds[] = $i->accountId;
}
if (count($instructorIds) != 0) {
$accounts = $account->fetchAll($account->getAdapter()->quoteInto('accountId IN (?)', $instructorIds), array('lastName', 'firstName'));
foreach ($accounts as $a) {
$e['instructors'][] = $a->firstName . ' ' . $a->lastName;
}
}
if (isset($locationCache[$e['locationId']])) {
$e['location'] = $locationCache[$e['locationId']];
} else {
$thisLocation = $location->find($e['locationId']);
if (is_null($thisLocation)) {
throw new Ot_Exception_Data('Location not found');
}
$e['location'] = $thisLocation->toArray();
$locationCache[$e['locationId']] = $e['location'];
//.........这里部分代码省略.........
示例8: getPredefinedRange
/**
* 取得某个预定义时间段
*
* @static
* @param integer $interval
* @param string $forceUnit
* @param integer $timestamp
* @return array
*/
public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
{
if (empty($timestamp)) {
$timestamp = time();
}
$start = new Zend_Date($timestamp);
$end = new Zend_Date($timestamp);
switch ($interval) {
case self::TODAY:
$start->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::HOUR;
break;
case self::YESTODAY:
$start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::TOMORROW:
$start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::THIS_MONTH:
$start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_YEAR:
$start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_SEASON:
$start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
case self::RECENT_24HOUR:
$start->subHour(24);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_48HOUR:
$start->subHour(48);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_1WEEK:
$start->subWeek(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_1MONTH:
$start->subMonth(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_24MONTH:
$start->subMonth(24);
$unit = Zend_Date::DAY;
break;
case self::LAST_1MONTH:
$start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addMonth(1);
$unit = Zend_Date::DAY;
break;
case self::LAST_1YEAR:
$start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addYear(1);
$unit = Zend_Date::DAY;
break;
case self::ENTIRE_DAY:
$start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
$end->addDay(1);
$unit = Zend_Date::DAY;
break;
default:
$unit = Zend_Date::SECOND;
}
if (!empty($forceUnit)) {
$unit = $forceUnit;
}
$start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
$end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
return compact('start', 'end', 'unit');
}