public function isValid($value) { $front = Zend_Controller_Front::getInstance()->getRequest(); $action = $front->action; if ($action == "edit-evento") { return true; } if (!isset($value) or empty($value)) { return false; } //date_default_timezone_set( 'America/Sao_Paulo' ); // Zend_Registry::get('logger')->log("valor=", Zend_Log::INFO); // Zend_Registry::get('logger')->log($value, Zend_Log::INFO); $date = new Zend_Date(); $data = new Zend_Date($date->toString('dd/MM/YYYY')); $data2 = new Zend_Date($value); $comparacao = $data->isLater($data2); $comparacao2 = $data->isEarlier($data2); $comparacao3 = $data->equals($data2); // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO); // Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO); // Zend_Registry::get('logger')->log($comparacao3, Zend_Log::INFO); if ($comparacao3 || $comparacao2) { Zend_Registry::get('logger')->log("data igual ou maior", Zend_Log::INFO); } else { $this->_setValue($value); // Zend_Registry::get('logger')->log("data menor", Zend_Log::INFO); $this->_error(self::INVALID); return false; } // $comparacao= $data->compare($date2); // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO); // Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO); return true; }
public function isValid($data) { $isValid = parent::isValid($data); if (empty($data['phone_number']) && empty($data['sms_id']) && (empty($data['date_until']) || empty($data['date_from']))) { $this->addErrorMessage('"Data do" i "Data od" sa wymagane jeżeli nie podasz "SMS ID" lub Numeru telefonu'); return false; } if (empty($data['sms_id']) && empty($data['phone_number'])) { try { $dateCheck = new Zend_Date($data['date_from']); if (!$dateCheck->isEarlier($data['date_until']) and 0 != strcmp($data['date_from'], $data['date_until'])) { $isValid = false; $this->addErrorMessage('"Data do" nie może być wcześniejsza niż "Data od"!'); } $dateSub = new Zend_Date($data['date_until']); $config = Zend_Registry::get('config'); if ($dateSub->sub($dateCheck)->toValue('DD') > $config['search']['mail']['filter']['interval']) { $isValid = false; $this->addErrorMessage('Maksymalny okres z jakiego można wyszukiwać dane to ' . $config['search']['sms']['filter']['interval'] . ' dni'); } } catch (Exception $ex) { $this->addErrorMessage($ex->getMessage()); $isValid = false; } } return $isValid; }
/** * Set current attribute to entry (for specified product) * * @param Mage_Catalog_Model_Product $product * @param Varien_Gdata_Gshopping_Entry $entry * @return Varien_Gdata_Gshopping_Entry */ public function convertAttribute($product, $entry) { $effectiveDateFrom = $this->getGroupAttributeSalePriceEffectiveDateFrom(); $fromValue = $effectiveDateFrom->getProductAttributeValue($product); $effectiveDateTo = $this->getGroupAttributeSalePriceEffectiveDateTo(); $toValue = $effectiveDateTo->getProductAttributeValue($product); $from = $to = null; if (!empty($fromValue) && Zend_Date::isDate($fromValue, Zend_Date::ATOM)) { $from = new Zend_Date($fromValue, Zend_Date::ATOM); } if (!empty($toValue) && Zend_Date::isDate($toValue, Zend_Date::ATOM)) { $to = new Zend_Date($toValue, Zend_Date::ATOM); } $dateString = null; // if we have from an to dates, and if these dates are correct if (!is_null($from) && !is_null($to) && $from->isEarlier($to)) { $dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM); } // if we have only "from" date, send "from" day if (!is_null($from) && is_null($to)) { $dateString = $from->toString('YYYY-MM-dd'); } // if we have only "to" date, use "now" date for "from" if (is_null($from) && !is_null($to)) { $from = new Zend_Date(); // if "now" date is earlier than "to" date if ($from->isEarlier($to)) { $dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM); } } if (!is_null($dateString)) { $this->_setAttribute($entry, 'sale_price_effective_date', self::ATTRIBUTE_TYPE_TEXT, $dateString); } return $entry; }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { // Check if there is already a campaign with the title defined $row = $this->_checkTitleCampaign(); if (!empty($row)) { $this->_message->addMessage(sprintf('Iha kampanha tiha ona ho naran %', $this->_data['campaign_title'])); return false; } $dataForm = $this->_data; // Check if the campaign was scheduled to validated and format the date if (!empty($this->_data['date_scheduled'])) { $date = new Zend_Date($this->_data['date_scheduled']); if ($date->isEarlier(Zend_Date::now())) { $this->_message->addMessage('Keta rejistu data atu haruka uluk data ohin'); $this->addFieldError('date_scheduled'); return false; } $this->_data['date_scheduled'] = $date->toString('yyyy-MM-dd'); } if (empty($this->_data['id_campaign'])) { $mapperSmsConfig = new Admin_Model_Mapper_SmsConfig(); $config = $mapperSmsConfig->getConfig(); $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser; $this->_data['fk_id_sms_config'] = $config->id_sms_config; $this->_data['status'] = empty($this->_data['date_scheduled']) ? self::STATUS_STOPPED : self::STATUS_SCHEDULED; $history = 'INSERE KAMPANHA SMS: %s'; } else { $history = 'ALTERA KAMPANHA SMS: %s'; $this->_data['status'] = empty($this->_data['date_scheduled']) ? self::STATUS_STOPPED : self::STATUS_SCHEDULED; } // Save the campaign $id = parent::_simpleSave(); // Save the campaign log if (empty($dataForm['id_campaign'])) { $this->saveLog('KAMPANHA HALOT', $id); } else { $this->saveLog('KAMPANHA ALTERADA', $id); } $dataForm['id_campaign'] = $id; // Save the groups for the campaign $this->_saveCampaignGroups($dataForm); $history = sprintf($history, $id); $this->_sysAudit($history); $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
/** * Checks if subscription has been expired * @return boolean */ public function isExpired() { if (!empty($this->expires_date)) { $oExpiredDate = new Zend_Date($this->expires_date); $oNowDate = new Zend_Date(); if ($oExpiredDate->isEarlier($oNowDate)) { $this->delete(); return true; } } return false; }
/** * Is this current time before the edit deadline? * * @return boolean */ public function isBeforeEditDeadline() { $conference = Zend_Registry::get('conference'); if (!isset($conference['review_start'])) { return true; } $now = new Zend_Date(); if ($now->isEarlier($conference['review_start'])) { return true; } return false; }
/** * Is feedback open? Feedback is open when the feedback codes are sent and the * feedback closing date has not passed * * @return mixed boolean on false or Zend_Date on true */ public function isFeedbackOpen() { $eventlogModel = new Core_Model_Eventlog(); if (false === ($feedbackSent = $eventlogModel->getTimestampByType('Core_FeedbackController::mailallAction'))) { return false; } $date = new Zend_Date(); if ($date->isLater($feedbackSent) && $date->isEarlier($this->_conference['feedback_end'], Zend_Date::ISO_8601)) { return $date; } return false; }
public function getFirstDate() { $firstDate = \Zend_Date::now(); $this->rewind(); while ($requisition = $this->read()) { $requisitionDate = new \Zend_Date($requisition->getDate(), 'yyyy-MM-dd HH:mm:ss'); if ($requisitionDate->isEarlier($firstDate)) { $firstDate = $requisitionDate; } } $this->rewind(); return $firstDate->get("yyyy-MM-dd HH:mm:ss"); }
public function isDateBetween($target, $from, $to) { if (is_null($from) && is_null($to)) { return true; } $target = new Zend_Date($target); $from = new Zend_Date($from); $to = new Zend_Date($to); if ($target->isEarlier($to) && $target->isLater($from)) { return true; } return false; }
/** * Is this current time before the edit deadline? * * Assumes config directive core.presentation.deadline * * @return boolean */ public function isBeforeEditDeadline() { $config = Zend_Registry::get('config'); $tStart = $this->getTable()->getAdapter()->fetchOne("select tstart from vw_sessions left join vw_session_presentations sp" . " ON (vw_sessions.session_id = sp.session_id) where presentation_id=:presentation_id", array(':presentation_id' => $this->presentation_id)); if ($tStart) { $now = new Zend_Date(); $tStart = new Zend_Date($tStart, Zend_Date::ISO_8601); $deadline = $tStart->sub($config->core->presentation->deadline, Zend_Date::SECOND); if ($now->isEarlier($deadline)) { return true; } } return false; }
public function getbookdetailsAction() { self::createModel(); $request = $this->getRequest(); $acc_no = $request->getParam('acc_no'); $objIsbn = new Lib_Model_DbTable_Isbn(); $objIssueReturn = new Lib_Model_DbTable_IssueReturn(); $book = array(); if (isset($acc_no)) { $bookInfo = Lib_Model_DbTable_Book::getBookInfo($acc_no); if (isset($bookInfo['isbn_id'])) { $book = $objIsbn->getIsbnDetails($bookInfo['isbn_id']); $bookIssued = $objIssueReturn->getIssuedBookInfo($acc_no); //$this->_helper->logger($bookIssued); if ($bookIssued) { $issueDate = new Zend_Date($bookIssued['issue_date'], Zend_Date::ISO_8601); $book['member_id'] = $bookIssued['member_id']; $member_limit = Lib_Model_DbTable_MembershipLimit::getMemberLimit($book['member_id'], $bookInfo['document_type_id']); if (isset($_SESSION['dateFormat'])) { $dateFormat = $_SESSION['dateFormat']; } else { $dateFormat = 'dd/MMM/yyyy'; } $book['issue_date'] = $issueDate->toString($dateFormat); $exp_return_date = $issueDate->addDay($member_limit['day_limit']); $day_late = 0; $objtoday = new Zend_Date(Zend_Date::now(), $dateFormat); if ($exp_return_date->isToday() || $objtoday->isEarlier($exp_return_date)) { $day_late = 0; } else { $objtoday->sub($exp_return_date); $day_late = $objtoday->get(Zend_Date::DAY) - 2; } $book['exp_return_date'] = $exp_return_date->toString($dateFormat); $book['day_late'] = $day_late; $bookStatus = 1; } $book['bookInfo'] = $bookInfo; $this->_helper->json($book); //echo Zend_Json::encode($book); } else { $this->getResponse()->setHttpResponseCode(400); echo 'Either the Acc No "' . $acc_no . '" or its corrosponding ISBN is invalid.'; } } else { $this->getResponse()->setHttpResponseCode(400); echo 'Parameters are insufficient to process.'; } }
/** * Is this session in progress? * * @return mixed Zend_Date on success, false on failure */ public function isNow() { //$date = new Zend_Date(array( // 'year' => 2011, // 'month' => 5, // 'day' => 16, // 'hour' => 14, // 'minute' => 10, // 'second' => 10)); $date = new Zend_Date(); if ($date->isLater($this->tstart, Zend_Date::ISO_8601) && $date->isEarlier($this->tend, Zend_Date::ISO_8601)) { return $date; } return false; }
public function isValid($value, $context = null) { $this->_setValue($value); if ($value['tstart'] == '' || $value['tend'] == '') { $this->_error(self::NOT_EMPTY); return false; } $start = new Zend_Date($value['tstart']); $end = new Zend_Date($value['tend']); if ($end->isEarlier($start)) { $this->_error(self::DATE_MISMATCH); return false; } return true; }
/** * Defined by Zend_Validate_Interface * * Returns true if $value is a valid date of the format YYYY-MM-DD * If optional $format or $locale is set the date format is checked * according to Zend_Date, see Zend_Date::isDate() * * @param string $value * @return boolean */ public function isValid($value) { $result = true; $date_validator = new Zend_Validate_Date($this->_format); if (!$date_validator->isValid($value['from']) || !$date_validator->isValid($value['to'])) { $this->_error(self::NOT_YYYY_MM_DD); $result = false; } $from_date = new Zend_Date($value['from']); $to_date = new Zend_Date($value['to']); if ($to_date->isEarlier($from_date)) { $this->_error(self::END_DATE_EARLIER); $result = false; } return $result; }
public function baseInit() { $this->datee(false, 'date_for', "Data od:", true); $this->date_for->addValidator('Callback', false, array('callback' => function ($value) { $date = new Zend_Date(); $date->setDate($value, 'YYYY-MM-dd'); return $date->isEarlier(new Zend_date()) || $date->isToday(); }, 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => "Data od nie może być datą przyszłą"))); $this->datee(false, 'date_to', "Data do:", true); $this->date_to->addValidator('Callback', false, array('callback' => function ($value) { $date = new Zend_Date(); $date->setDate($value, 'YYYY-MM-dd'); return $date->isEarlier(new Zend_date()) || $date->isToday(); }, 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => "Data do nie może być datą przyszłą"))); $this->submit(false, 'create_raport', 'Generuj raport'); }
public function getisvaliddateAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout()->disableLayout(); $dateText = $this->getRequest()->getParam('dateText'); $objSelectedDate = new Zend_Date($dateText, Zend_Date::ISO_8601); $objTodayDate = new Zend_Date(Zend_Date::now(), Zend_Date::ISO_8601); if ($objSelectedDate->isToday($dateText)) { echo 1; return; } if ($objSelectedDate->isEarlier($objTodayDate) || $objSelectedDate->isDate($dateText)) { echo 0; return; } echo 1; }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $date = new Zend_Date($this->_data['date_appointment']); $date->set($this->_data['time_appointment'], Zend_Date::TIME_SHORT); $dataForm = $this->_data; $today = new Zend_Date(); $this->_data['date_appointment'] = $date->toString('yyyy-MM-dd HH:mm'); if (empty($this->_data['id_appointment'])) { if ($date->isEarlier($today)) { $this->_message->addMessage('Erro: Data no Oras ba audiensia uluk data ohin.', App_Message::ERROR); $this->addFieldError('date_appointment')->addFieldError('time_appointment'); return false; } $mapperCase = new Client_Model_Mapper_Case(); $case = $mapperCase->detailCase($this->_data['fk_id_action_plan']); $this->_data['fk_id_perdata'] = $case->fk_id_perdata; $this->_data['appointment_active'] = 1; $this->_data['appointment_filled'] = 0; } // Save the Note $id = parent::_simpleSave(); // Delete and insert all objetives $dbAppointmentObjective = App_Model_DbTable_Factory::get('Appointment_has_Objective'); $where = array($dbAdapter->quoteInto('fk_id_appointment = ?', $id)); $dbAppointmentObjective->delete($where); // Insert the news objectives foreach ($dataForm['objective'] as $objective) { $row = $dbAppointmentObjective->createRow(); $row->fk_id_appointment = $id; $row->fk_id_appointment_objective = $objective; $row->save(); } $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
public function isValidMandate($checkSignatureDate = null) { if (is_null($checkSignatureDate)) { $checkSignatureDate = new Zend_Date(); } if (!$this->__get('signature_date')) { return false; } if ($this->__get('mandate_state') != 'CONFIRMED') { return false; } if ($this->__get('is_valid') != 1) { return false; } $signatureDate = new Zend_Date($this->__get('signature_date')); if ($checkSignatureDate->isEarlier($signatureDate)) { return false; } return true; }
/** * Set current attribute to entry (for specified product) * * @param Mage_Catalog_Model_Product $product * @param Google_Service_ShoppingContent_Product $shoppingProduct * * @return Google_Service_ShoppingContent_Product */ public function convertAttribute($product, $shoppingProduct) { $sp = $this->_dispatch('gshoppingv2_attribute_salepriceeffectivedate', $product, $shoppingProduct); if ($sp !== null) { return $sp; } $effectiveDateFrom = $this->getGroupAttributeSalePriceEffectiveDateFrom(); $fromValue = $effectiveDateFrom->getProductAttributeValue($product); $effectiveDateTo = $this->getGroupAttributeSalePriceEffectiveDateTo(); $toValue = $effectiveDateTo->getProductAttributeValue($product); $from = $to = null; if (!empty($fromValue) && Zend_Date::isDate($fromValue, Zend_Date::ATOM)) { $from = new Zend_Date($fromValue, Zend_Date::ATOM); } if (!empty($toValue) && Zend_Date::isDate($toValue, Zend_Date::ATOM)) { $to = new Zend_Date($toValue, Zend_Date::ATOM); } $dateString = null; // if we have from an to dates, and if these dates are correct if (!is_null($from) && !is_null($to) && $from->isEarlier($to)) { $dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM); } // if we have only "from" date, send "from" day if (!is_null($from) && is_null($to)) { $dateString = $from->toString('YYYY-MM-dd'); } // if we have only "to" date, use "now" date for "from" if (is_null($from) && !is_null($to)) { $from = new Zend_Date(); // if "now" date is earlier than "to" date if ($from->isEarlier($to)) { $dateString = $from->toString(Zend_Date::ATOM) . '/' . $to->toString(Zend_Date::ATOM); } } if (!is_null($dateString)) { $shoppingProduct->setSalePriceEffectiveDate($dateString); } return $shoppingProduct; }
/** * Prepare given time to fit the first timestamp of given intervall. * * E.g. INTERVALL_TYPE_MONTH, '2011-01-12 10:06:23' => '2011-01-01 00:00:00' * * Filter date if not in usable range: * too early => set datetime to first flattened datetime value of measured data * in range => ok * too late => set datetime to last datetime value of measured data * AND call this method recursively for flattening this datetime to e.g. Monday 00:00 * * @param Diagram_Model_IntervallMapper::INTERVALL_TYPE_* $intervallType * @param string|timestamp|Zend_Date $intervallStart * @return Zend_Date */ public static function getPreparedStartDate($intervallType, $intervallStart) { /* @var $date Zend_Date */ $date = null; if ($intervallStart instanceof Zend_Date) { $date = clone $intervallStart; } else { $date = new Zend_Date($intervallStart); } if ($date->isEarlier(self::getFirstMeasurementDate())) { $firstStartDate = new Zend_Date(self::getFirstMeasurementDate(), null, $date->getLocale()); $date = self::getPreparedStartDate($intervallType, $firstStartDate); } elseif ($date->isLater(self::getLastMeasurementDate())) { $lastEndDate = new Zend_Date(self::getLastMeasurementDate(), null, $date->getLocale()); $date = self::getPreparedStartDate($intervallType, $lastEndDate); } switch ($intervallType) { case self::INTERVALL_TYPE_YEAR: $date->setMonth(1); case self::INTERVALL_TYPE_MONTH: $date->setDay(1); case self::INTERVALL_TYPE_DAY: $date->setHour(0); case self::INTERVALL_TYPE_HOUR: $date->setMinute(0); $date->setSecond(0); break; // Doesn't fit with the others. Therefore handle separately. // Doesn't fit with the others. Therefore handle separately. case self::INTERVALL_TYPE_WEEK: // 1 == monday $date->setWeekday(1); $date->setHour(0); $date->setMinute(0); $date->setSecond(0); } return $date; }
/** * Is the submit live? * * @return mixed boolean on false or Zend_Date on true */ public function isSubmitLive() { $date = new Zend_Date(); if (!isset($this->_conference['submit_start']) || !isset($this->_conference['submit_end'])) { return false; } if ($date->isLater($this->_conference['submit_start'], Zend_Date::ISO_8601) && $date->isEarlier($this->_conference['submit_end'], Zend_Date::ISO_8601)) { return $date; } return false; }
private function atualizaStatus() { $modelProposta = new Model_DbTable_Proposta(); $where = "proposta_status = 'Aguardando resposta'"; $propostas = $modelProposta->fetchAll($where); $zendDateNow = new Zend_Date(); foreach ($propostas as $proposta) { $zendDateVencimento = new Zend_Date($proposta->proposta_vencimento); if ($zendDateVencimento->isEarlier($zendDateNow)) { // atualiza o status $update = array('proposta_status' => self::STATUS_VENCIDA); try { $modelProposta->updateById($update, $proposta->proposta_id); } catch (Exception $ex) { continue; } } } }
/** * @ZF-7912 */ public function testPhpFormatWithIsEmpty() { Zend_Date::setOptions(array('format_type' => 'php')); $date1 = new Zend_Date(); $date2 = clone $date1; $date2->add(1, 'd'); $this->assertTrue($date1->isEarlier($date2, 'd.M.y')); $this->assertFalse($date2->isEarlier($date1, 'd.M.y')); $this->assertFalse($date1->isLater($date2, 'd.M.y')); $this->assertTrue($date2->isLater($date1, 'd.M.y')); }
/** * test looseBehaviour */ public function testLoose() { $date = new Zend_Date(0, 'de'); try { $date->set(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } $date->set(10, 'de'); $this->assertEquals($date->getTimestamp(), 10); try { $date->add(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } $date->add(10, 'de'); $this->assertEquals($date->getTimestamp(), 20); try { $date->sub(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } $date->sub(10, 'de'); $this->assertEquals($date->getTimestamp(), 10); try { $date->compare(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->equals(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->isEarlier(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->isLater(null, Zend_Date::YEAR); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setTime(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addTime(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subTime(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareTime(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setDate(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addDate(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subDate(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareDate(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setIso(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addIso(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subIso(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareIso(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setArpa(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addArpa(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subArpa(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareArpa(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setYear(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addYear(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subYear(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareYear(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setMonth(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addMonth(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subMonth(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareMonth(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setDay(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addDay(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subDay(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareDay(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setWeekday(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addWeekday(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subWeekday(null); $this->fail(); } catch (Zend_Date_Exception $e) { // 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) { // success } try { $date->subMinute(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareMinute(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setSecond(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addSecond(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subSecond(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareSecond(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->setWeek(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->addWeek(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->subWeek(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } try { $date->compareWeek(null); $this->fail(); } catch (Zend_Date_Exception $e) { // success } }
public function isProductNew($label_new = null) { if (is_null($label_new)) { $label_new = self::$theme_config_helper->getThemeConfigResultByAliase('product_label_new'); } if ($label_new) { $from = new Zend_Date($this->getNewsFromDate()); $to = new Zend_Date($this->getNewsToDate()); $now = new Zend_Date(Mage::getModel('core/date')->timestamp(time())); return $from->isEarlier($now) && $to->isLater($now); } return false; }
public function processAction() { $initId = Zend_Filter::filterStatic($this->getRequest()->getParam('id'), 'StripTags'); $sDate = Zend_Filter::filterStatic($this->getRequest()->getParam('sdate'), 'StripTags'); $eDate = Zend_Filter::filterStatic($this->getRequest()->getParam('edate'), 'StripTags'); $sTime = Zend_Filter::filterStatic($this->getRequest()->getParam('stime'), 'StripTags'); $eTime = Zend_Filter::filterStatic($this->getRequest()->getParam('etime'), 'StripTags'); $sum = Zend_Filter::filterStatic($this->getRequest()->getParam('sum'), 'StripTags'); $format = Zend_Filter::filterStatic($this->getRequest()->getParam('format'), 'StripTags'); $offset = Zend_Filter::filterStatic($this->getRequest()->getParam('offset'), 'StripTags'); $limit = Zend_Filter::filterStatic($this->getRequest()->getParam('limit'), 'StripTags'); $params = array(); if (isset($initId) && ctype_digit($initId)) { if (empty($format) || !in_array($format, $this->_formats)) { $format = 'cal'; } $params['format'] = $format; $params['offset'] = !empty($offset) && ctype_digit($offset) ? (int) $offset : 0; $params['limit'] = !empty($limit) && ctype_digit($limit) ? (int) $limit : Globals::getQsDbLimit(); if (!empty($sDate)) { $sDate = explode("T", strtoupper($sDate)); $yr = substr($sDate[0], 0, 4); $month = substr($sDate[0], 4, 2); $day = substr($sDate[0], 6, 2); if (ctype_digit($yr) && ctype_digit($month) && ctype_digit($day)) { $sDate = new Zend_Date(array('year' => $yr, 'month' => $month, 'day' => $day)); $params['sDate'] = $sDate->get(Zend_Date::ISO_8601); } } if (!empty($eDate)) { $eDate = explode("T", strtoupper($eDate)); $yr = substr($eDate[0], 0, 4); $month = substr($eDate[0], 4, 2); $day = substr($eDate[0], 6, 2); if (ctype_digit($yr) && ctype_digit($month) && ctype_digit($day)) { $eDate = new Zend_Date(array('year' => $yr, 'month' => $month, 'day' => $day)); if (is_object($sDate) && $eDate->isEarlier($sDate)) { $this->view->error = 'End date must come after start date.'; $this->_forward("errorxhr", "error"); } else { $params['eDate'] = $eDate->get(Zend_Date::ISO_8601); } } } if (!empty($sTime) && ctype_digit($sTime) && (int) $sTime > 0 && (int) $sTime < 2400) { $sTime = str_pad($sTime, 4, '0', STR_PAD_LEFT); $params['sTimeH'] = substr($sTime, 0, 2); $params['sTimeM'] = substr($sTime, 2, 2); } if (!empty($eTime) && ctype_digit($eTime) && (int) $eTime >= 0 && (int) $eTime < 2359) { $sTime = str_pad($eTime, 4, '0', STR_PAD_LEFT); $params['eTimeH'] = substr($sTime, 0, 2); $params['eTimeM'] = substr($sTime, 2, 2); } try { $qModel = new QueryModel($initId); if ($this->_getParam('service') == 'debugsessions') { $qModel->bySessions($params); $this->view->qModel = $qModel; $this->view->offset = $params['offset']; $this->view->nextOffset = $params['offset'] + $params['limit']; $this->view->prevOffset = $params['offset'] - $params['limit'] > 0 ? $params['offset'] - $params['limit'] : 0; $this->view->id = $initId; $this->render('debugsessions'); } else { if ($this->_getParam('service') == 'debugcounts') { $qModel->byCounts($params); $this->view->qModel = $qModel; $this->view->offset = $params['offset']; $this->view->nextOffset = $params['offset'] + $params['limit']; $this->view->prevOffset = $params['offset'] - $params['limit'] > 0 ? $params['offset'] - $params['limit'] : 0; $this->view->id = $initId; $this->render('debugcounts'); } else { $sum = strtolower($sum) === 'true' ? true : false; if ($this->_getParam('service') == 'sessions') { $qModel->bySessions($params); $trans = TransformerFactory::factory($this->_transformers[$format], false, $sum); } else { $qModel->byCounts($params); $trans = TransformerFactory::factory($this->_transformers[$format], true, $sum); } $trans->setInitMetadata($qModel->getInitMetadata()); $trans->setInitLocs($qModel->getInitLocs()); $trans->setInitActs($qModel->getInitActs()); $trans->setInitActGroups($qModel->getInitActGroups()); while ($row = $qModel->getNextRow()) { $trans->addRow($row); } if ($qModel->hasMore()) { $trans->setHasMore(true, $params['offset'] + $params['limit']); } $this->view->trans = $trans; } } } catch (Exception $e) { $this->view->error = $e->getMessage(); $this->_forward("error"); } } else { $this->view->error = 'Initiative ID must be numeric'; Globals::getLog()->err('INVALID INITIATIVE ID - QueryController id: ' . $initId); $this->_forward("error"); } }
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/"); } } } }
/** * Test for isEarlier */ public function testIsEarlier() { $locale = new Zend_Locale('de_AT'); $date = new Zend_Date(0, null, $locale); $d2 = new Zend_Date(1010101010, null, $locale); $retour = $date->set(1234567890); $this->assertSame((string) $retour, '1234567890'); $this->assertSame($date->isEarlier(1234567890), false); $this->assertSame($date->isEarlier(1234567800), false); $this->assertSame($date->isEarlier(1234567899), true); $date->set($d2); $this->assertSame($date->isEarlier(3, Zend_Date::DAY), false); $this->assertSame($date->isEarlier(4, Zend_Date::DAY), false); $this->assertSame($date->isEarlier(5, Zend_Date::DAY), true); }
/** * Check if saved data is right. * Please note: restrictions applied here are not validators: any exception * thrown below indicates incorrect usage of model, i.e., an application bug. * * @throws Doctrine_Record_Exception * @see Doctrine_Record::preSave() */ public function preSave($event) { $invoker = $event->getInvoker(); $created_at = new Zend_Date($invoker->created_at); // Activation timestamp restrictions if ($invoker->activated_at !== null) { $activated_at = new Zend_Date($invoker->activated_at); // Make sure a date when book is received is later than a date when book was requested if ($activated_at->isEarlier($created_at, Zend_Date::DATES) === true) { throw new Doctrine_Record_Exception("The date of activation is earlier than the date of creation", Doctrine_Core::ERR_CONSTRAINT); } } // Logging in timestamp restrictions if ($invoker->log_date !== null) { $logged_at = new Zend_Date($invoker->log_date); // Make sure a date when book is received is later than a date when book was requested if ($logged_at->isEarlier($created_at, Zend_Date::DATES) === true) { throw new Doctrine_Record_Exception("The date of logging in is earlier than the date of creation", Doctrine_Core::ERR_CONSTRAINT); } } }
/** * Returns true if and only if $value meets the validation requirements * * If $value fails validation, then this method returns false, and * getMessages() will return an array of messages that explain why the * validation failed. * * @param mixed $value * @return boolean * @throws \Zend_Valid_Exception If validation of $value is impossible */ public function isValid($value, $context = null) { if (null === $this->_afterDate) { $this->_afterDate = new \Zend_Date(); } if ($this->_afterDate instanceof \Zend_Date) { $after = $this->_afterDate; } elseif (isset($context[$this->_afterDate])) { if (empty($context[$this->_afterDate])) { $this->_error(self::NO_VALIDFROM); return false; } $after = new \Zend_Date($context[$this->_afterDate], $this->getDateFormat()); } elseif (\Zend_Date::isDate($this->_afterDate, $this->getDateFormat())) { $after = new \Zend_Date($this->_afterDate, $this->getDateFormat()); } else { // No date specified, return true return true; } $this->_afterValue = $after->toString($this->getDateFormat()); $check = new \Zend_Date($value, $this->getDateFormat()); if ($check->isEarlier($after)) { $this->_error(self::NOT_AFTER); return false; } return true; }