Example #1
0
 /**
  * 
  * @param array $data
  * @return int
  * @throws Exception
  */
 protected function _saveContract($data)
 {
     $dateStart = new Zend_Date($data['date_start']);
     $dateFinish = new Zend_Date($data['date_finish']);
     // Check if the initial date is later than finish date
     if ($dateStart->isLater($dateFinish)) {
         $message = 'Data loron keta liu data remata.';
         $this->_message->addMessage($message);
         $this->addFieldError('date_start')->addFieldError('date_finish');
         throw new Exception($message);
     }
     // If there is no contract yet
     if (empty($data['fk_id_fefop_contract'])) {
         $dataContract = array('module' => Fefop_Model_Mapper_Module::DRH, 'district' => $data['fk_id_adddistrict']);
         $mapperFefopContract = new Fefop_Model_Mapper_Contract();
         $data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
     }
     $data['date_start'] = $dateStart->toString('yyyy-MM-dd');
     $data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
     $dataForm = $data;
     $this->_data = $data;
     // Save the contract
     $dataForm['id_drh_contract'] = parent::_simpleSave($this->_dbTable, false);
     // Save budget category
     $this->_saveExpenses($dataForm);
     if (empty($data['id_drh_contract'])) {
         $history = 'REJISTU KONTRAKTU DRH: %s';
     } else {
         $history = 'ATUALIZA KONTRAKTU DRH: %s';
     }
     $history = sprintf($history, $dataForm['id_drh_contract']);
     $this->_sysAudit($history);
     return $dataForm['id_drh_contract'];
 }
Example #2
0
 public function testSetWhenDefaultsToCurrentTime()
 {
     $entry = new Zend_Feed_Writer_Deleted();
     $entry->setWhen();
     $dateNow = new Zend_Date();
     $this->assertTrue($dateNow->isLater($entry->getWhen()) || $dateNow->equals($entry->getWhen()));
 }
Example #3
0
 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;
 }
Example #4
0
 public static function checkDateConstraint($dateTime, $limit)
 {
     $dateStr = $dateTime->format('Y-m-d H:i:s');
     $date = new Zend_Date($dateStr, 'yyyy-MM-dd HH:mm:ss');
     $now = new Zend_Date();
     $date->add($limit, Zend_Date::DAY);
     return $date->isLater($now);
 }
Example #5
0
 /** Has the token expired?
  *
  * @param string $access_token_expiry
  */
 private function hasExpired($access_token_expiry)
 {
     $now = new Zend_Date(NULL, 'yyyy-MM-dd HH:mm:ss');
     $tokenDate = new Zend_Date($access_token_expiry, 'YYYY-MM-dd HH:mm:ss');
     $difference = $tokenDate->isLater($now);
     if ($now > $tokenDate) {
         return true;
     } else {
         return false;
     }
 }
Example #6
0
 public function isValid($data)
 {
     $valid = parent::isValid($data);
     $date1 = new Zend_Date($data['valid_since']);
     $date2 = new Zend_Date($data['valid_until']);
     if ($date1->isLater($date2)) {
         $this->addError('Nieprawidłowy przedział dat.');
         $valid = false;
     }
     return $valid;
 }
Example #7
0
 public function isValid($value, $context = null)
 {
     $value = (string) $value;
     $this->_setValue($value);
     $endDate = new Zend_Date($value);
     if (isset($context[$this->_field]) && $endDate->isLater($context[$this->_field])) {
         return true;
     } else {
         $this->_error();
         return false;
     }
 }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dateStart = new Zend_Date($this->_data['date_start']);
         $dateFinish = new Zend_Date($this->_data['date_finish']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_RI);
         // Check if the initial date is later than finish date
         if ($dateStart->isLater($dateFinish)) {
             $this->_message->addMessage('Data loron keta liu data remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => Fefop_Model_Mapper_Module::RI, 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['date_start'] = $dateStart->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_ri_contract'] = parent::_simpleSave();
         // Save budget category
         $this->_saveExpenses($dataForm);
         if (empty($this->_data['id_ri_contract'])) {
             $history = 'REJISTU KONTRAKTU RI: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU RI: %s';
         }
         $history = sprintf($history, $dataForm['id_ri_contract']);
         $this->_sysAudit($history);
         if ($this->_data['amount'] > self::LIMIT_AMOUNT) {
             $this->_sendWarningAmount($dataForm['id_ri_contract']);
         }
         $diff = $dateFinish->sub($dateStart);
         $measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::SECOND);
         $diffMonth = preg_replace('/[^0-9.]/i', '', $measure->convertTo(Zend_Measure_Time::MONTH, 0));
         if ((double) $diffMonth > self::MOUNTH_LIMIT) {
             $this->_sendWarningDuration($dataForm['id_ri_contract']);
         }
         $dbAdapter->commit();
         return $dataForm['id_ri_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Example #10
0
 protected function _getDate($timeAmount, Zend_Date $date)
 {
     $nowDate = new Zend_Date();
     $dateWithTimeAmount = $date->addHour($timeAmount);
     if ($timeAmount == 0) {
         $date = $date->addMinute(1);
     } elseif ($timeAmount < 0 && $nowDate->isLater($dateWithTimeAmount)) {
         $date = $nowDate->addMinute(1);
     } else {
         $date = $dateWithTimeAmount;
     }
     return $date;
 }
Example #11
0
 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;
 }
 /**
  * This assertion should receive the actual Submission objects.
  *
  * @param Zend_Acl $acl
  * @param Zend_Acl_Role_Interface $user
  * @param Zend_Acl_Resource_Interface $model
  * @param $privilege
  * @return bool
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $user = null, Zend_Acl_Resource_Interface $model = null, $privilege = null)
 {
     $conference = Zend_Registry::get('conference');
     if (!isset($conference['review_visible'])) {
         return true;
     }
     $now = new Zend_Date();
     // perform check
     if ($now->isLater($conference['review_visible'])) {
         return true;
     }
     return false;
 }
Example #13
0
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     if (!empty($data['date_for']) && !empty($data['date_to'])) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->setDate($data['date_for'], 'YYYY-MM-dd')->getTimestamp();
         $date2->setDate($data['date_to'], 'YYYY-MM-dd')->getTimestamp();
         if ($date->isLater($date2)) {
             $isValid = false;
             $this->getElement('date_to')->addError("Data do nie może być wcześniejsza niż data od");
         }
     }
     return $isValid;
 }
Example #14
0
 public function getProductLabels($product)
 {
     $html = '';
     if (Mage::getStoreConfig('meigee_indigo_general/productlabels/labelnew')) {
         $from = $product->getNewsFromDate();
         $to = new Zend_Date($product->getNewsToDate());
         $now = new Zend_Date(Mage::getModel('core/date')->timestamp(time()));
         if (isset($from) && $to->isLater($now)) {
             $html .= '<span class="label-new">' . $this->__('New') . '</span>';
         }
     }
     if (Mage::getStoreConfig('meigee_indigo_general/productlabels/labelonsale') and $this->isOnSale($product)) {
         $html .= '<span class="label-sale">' . $this->__('Sale') . '</span>';
     }
     return $html;
 }
Example #15
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dateStart = new Zend_Date($this->_data['date_start']);
         $dateFinish = new Zend_Date($this->_data['date_finish']);
         $mapperExpense = new Fefop_Model_Mapper_Expense();
         $item = $mapperExpense->getModuleToItem($this->_data['fk_id_fefop_modules']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, $item);
         // Check if the initial date is later than finish date
         if ($dateStart->isLater($dateFinish)) {
             $this->_message->addMessage('Data loron keta liu data remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => $this->_data['fk_id_fefop_modules'], 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['date_start'] = $dateStart->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_per_contract'] = parent::_simpleSave();
         $dataForm['fk_id_per_contract'] = $dataForm['id_per_contract'];
         // Save budget category
         $this->_saveExpenses($dataForm);
         if (empty($this->_data['id_per_contract'])) {
             $history = 'REJISTU KONTRAKTU PER: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU PER: %s';
         }
         $history = sprintf($history, $dataForm['id_per_contract']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_per_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Example #16
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $dateIni = new Zend_Date($dataForm['date_start']);
         $dateFin = new Zend_Date($dataForm['date_finish']);
         // Check if the start date is later than finish date
         if ($dateIni->isLater($dateFin)) {
             $this->_message->addMessage('Loron inisiu la bele liu loron remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // Check to see if either start date or finish date are within the year defined
         if (!in_array($dataForm['year_planning'], array($dateIni->toString('yyyy')))) {
             $this->_message->addMessage(sprintf('Loron inisiu tenki iha laran Tinan: %s.', $dataForm['year']));
             $this->addFieldError('date_start');
             return false;
         }
         $this->_data = $dataForm;
         $this->_data['total_cost'] = App_General_String::toFloat($this->_data['total_cost']);
         // Save the annual planning
         $this->_data['fk_id_annual_planning'] = $this->_saveAnnualPlanning($this->_data);
         $this->_data['date_start'] = $dateIni->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFin->toString('yyyy-MM-dd');
         $dbPlanningCourse = App_Model_DbTable_Factory::get('FPPlanningCourse');
         $id = parent::_simpleSave($dbPlanningCourse);
         // Update the totals
         $dbAnnualPlanning = App_Model_DbTable_Factory::get('FPAnnualPlanning');
         $totals = $this->_getTotalsAnnualPlanning($this->_data['fk_id_annual_planning']);
         $row = $dbAnnualPlanning->fetchRow(array('id_annual_planning = ?' => $this->_data['fk_id_annual_planning']));
         $row->total_students = $totals->total_students;
         $row->total_cost = $totals->total_cost;
         $row->save();
         $history = sprintf('REJISTU PLANU FORMASAUN: %s BA ANNUAL PLANNING: %s', $id, $this->_data['fk_id_annual_planning']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Example #17
0
 protected function getDiff(Zend_Date $timeThen, $timeNow = null)
 {
     if (!$timeNow instanceof Zend_Date) {
         $timeNow = new Zend_Date();
     }
     $difference = $timeNow->isLater($timeThen) ? $timeNow->sub($timeThen) : $timeThen->sub($timeNow);
     //$difference = $timeNow->sub($timeThen);
     $measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
     if ($measure->compare(new Zend_Measure_Time(0)) == 0) {
         return $measure->convertTo(Zend_Measure_Time::SECOND, 0);
     }
     $units = array('SECOND' => array('1', 's'), 'MINUTE' => array('60', 'min'), 'HOUR' => array('3600', 'h'), 'DAY' => array('86400', 'day'), 'WEEK' => array('604800', 'week'), 'MONTH' => array('2628600', 'month'), 'YEAR' => array('31536000', 'year'));
     foreach ($units as $unitId => $unit) {
         if (is_array($unit) && $unit[0] / abs($measure->getValue(-1)) > 1) {
             break;
         }
         $convertTo = $unitId;
     }
     return $measure->convertTo($convertTo, 0);
 }
Example #18
0
 public static function getCurrentSessionHolidays()
 {
     $session_startdate = Core_Model_DbTable_AcademicSession::getSessionStartDate();
     $session_enddate = Core_Model_DbTable_AcademicSession::getSessionEndDate();
     $sql = self::getDefaultAdapter()->select()->from('holiday', array('date_from', 'date_upto', 'purpose'))->where('date_from >= ? ', $session_startdate)->where('date_from <= CURRENT_DATE() ');
     $holiday = $sql->query()->fetchAll();
     $dates = array();
     $cnt = 0;
     foreach ($holiday as $key => $value) {
         $start_date = $value['date_from'];
         $end_date = $value['date_upto'];
         $objstart = new Zend_Date($start_date, Zend_Date::ISO_8601);
         $objenddate = new Zend_Date($end_date, Zend_Date::ISO_8601);
         while (!$objstart->isLater($objenddate)) {
             $dates[$cnt++] = $objstart->get(Zend_date::YEAR) . '-' . $objstart->get(Zend_date::MONTH) . '-' . $objstart->get(Zend_date::DAY) . '-' . $value['purpose'];
             $objstart->addDay(1);
         }
         $objstart = NULL;
         $objenddate = NULL;
     }
     return $dates;
 }
Example #19
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $dataForm, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_DRH_PLAN);
         $dateIni = new Zend_Date($dataForm['date_start']);
         $dateFin = new Zend_Date($dataForm['date_finish']);
         // Check if the start date is later than finish date
         if ($dateIni->isLater($dateFin)) {
             $this->_message->addMessage('Loron inisiu la bele liu loron remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         $this->_data['date_start'] = $dateIni->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFin->toString('yyyy-MM-dd');
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['amount_expenses'] = App_General_String::toFloat($this->_data['amount_expenses']);
         // Save the training plan
         $dataForm['id_drh_trainingplan'] = parent::_simpleSave();
         //if ( $this->_data['amount'] > self::LIMIT_AMOUNT )
         //$this->_sendWarningAmount( $dataForm['id_drh_trainingplan'] );
         // Save beneficiaries
         $this->_saveBeneficiaries($dataForm);
         // Save Expenses
         $this->_saveExpenses($dataForm);
         $history = sprintf('REJISTU PLANU FORMASAUN DRH: %s', $dataForm['id_drh_trainingplan']);
         $this->_sysAudit($history);
         $this->_checkTravelInsurance($dataForm);
         $dbAdapter->commit();
         return $dataForm['id_drh_trainingplan'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Example #20
0
 public function getProductLabels($_product, $type)
 {
     switch ($type) {
         case 'new':
             if (Mage::getStoreConfig('meigee_blacknwhite_general/productlabels/labelnew')) {
                 $from = $_product->getNewsFromDate();
                 $to = new Zend_Date($_product->getNewsToDate());
                 $now = new Zend_Date(Mage::getModel('core/date')->timestamp(time()));
                 if (isset($from) && $to->isLater($now)) {
                     return '<span class="label-new">' . $this->__('New') . '</span>';
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
             break;
         case 'sale':
             if (Mage::getStoreConfig('meigee_blacknwhite_general/productlabels/labelonsale')) {
                 $_finalPrice = MAGE::helper('tax')->getPrice($_product, $_product->getFinalPrice());
                 $_regularPrice = MAGE::helper('tax')->getPrice($_product, $_product->getPrice());
                 if ($_regularPrice != $_finalPrice) {
                     if (Mage::getStoreConfig('meigee_blacknwhite_general/productlabels/salepercentage')) {
                         $getpercentage = number_format($_finalPrice / $_regularPrice * 100, 2);
                         $finalpercentage = 100 - $getpercentage;
                         return '<div class="label-sale percentage">' . number_format($finalpercentage, 0) . '% <span>' . $this->__('off') . '</span></div>';
                     } else {
                         return '<div class="label-sale">' . $this->__('Sale') . '</div>';
                     }
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
             break;
     }
 }
Example #21
0
 /**
  * test looseBehaviour
  */
 public function testLoose()
 {
     $date = new Zend_Date(0, 'de_DE');
     try {
         $date->set(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->set(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->add(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->add(10, 'de_DE');
     $this->assertEquals(20, $date->getTimestamp());
     try {
         $date->sub(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->sub(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     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
     }
 }
Example #22
0
 public function testSetLastBuildDateDefaultsToCurrentTime()
 {
     $writer = new Zend_Feed_Writer_Feed();
     $writer->setLastBuildDate();
     $dateNow = new Zend_Date();
     $this->assertTrue($dateNow->isLater($writer->getLastBuildDate()) || $dateNow->equals($writer->getLastBuildDate()));
 }
Example #23
0
 /**
  * Checks if from date is before until date.
  *
  * @param mixed $from
  * @param mixed $until
  * @return boolean
  */
 private function _validateFromUntilRange($from, $until)
 {
     $result = $this->_validateFrom($from);
     if (false === $result) {
         return false;
     }
     $result = $this->_validateUntil($until);
     if (false === $result) {
         return $result;
     }
     $result = true;
     $untilDate = new Zend_Date($until, $this->_dateFormat);
     $isEqual = $untilDate->equals($from, $this->_dateFormat);
     $isLater = $untilDate->isLater($from, $this->_dateFormat);
     if (false === $isEqual and false === $isLater) {
         $this->setErrorCode(Oai_Model_Error::BADARGUMENT);
         $this->setErrorMessage('Date "' . $from . '" is later than date "' . $until . '".');
         $result = false;
     }
     return $result;
 }
Example #24
0
 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;
 }
Example #25
0
 /**
  * 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;
 }
Example #26
0
 /** Determine whether a date is earlier or later
  * 
  * @param date $date
  */
 public function expiredjob($date)
 {
     $today = new Zend_Date(NULL, 'YYYY-MM-dd');
     $difference = $today->isLater(new Zend_Date($date, 'YYYY-MM-dd'));
     return $difference;
 }
Example #27
0
	public function dataValidator($formData,$formType)
	{
		$errorMsg = null;
		$trigger = 0;

		if($formData['contactId'] == null)
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_vehicle_contact_notFound."<br/>".$errorMsg;
			}
		$dateStart = new Zend_Date($formData['startDate'],'YYYY-MM-DD');
		$dateEnd = new Zend_Date($formData['endDate'],'YYYY-MM-DD');
		
		if($dateStart->isLater($dateEnd))
		{
			$trigger = 1;
			$errorMsg = General_Models_Text::$text_date_startEndError."<br/>".$errorMsg;
			}
			
		$array['trigger'] = $trigger;
		$array['errorMsg'] = $errorMsg;
		return $array;
	}
Example #28
0
 /**
  * Test for isLater
  */
 public function testIsLater()
 {
     $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->isLater(1234567890), false);
     $this->assertSame($date->isLater(1234567800), true);
     $this->assertSame($date->isLater(1234567899), false);
     $date->set($d2);
     $this->assertSame($date->isLater(3, Zend_Date::DAY), true);
     $this->assertSame($date->isLater(4, Zend_Date::DAY), false);
     $this->assertSame($date->isLater(5, Zend_Date::DAY), false);
 }
Example #29
0
 /**
  * 
  * @return int|bool
  */
 public function saveInformation()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $dateBirth = new Zend_Date($this->_data['birth_date']);
         $age = App_General_Date::getAge($dateBirth);
         if ($age < 14) {
             $this->_message->addMessage('Erro: Kliente iha jovem liu ba heta rejistrasaum.', App_Message::ERROR);
             $this->addFieldError('birth_date');
             return false;
         }
         if ($age > 110) {
             $this->_message->addMessage('Erro: Kliente iha katuas liu ba heta rejistrasaum.', App_Message::ERROR);
             $this->addFieldError('birth_date');
             return false;
         }
         if (!$this->_validateName()) {
             $this->_message->addMessage('Erro: Kliente naran tiha ona.', App_Message::ERROR);
             $this->addFieldError('first_name')->addFieldError('last_name');
             return false;
         }
         if (empty($this->_data['id_perdata'])) {
             $dateRegistration = new Zend_Date($this->_data['date_registration']);
             $dateNow = new Zend_Date();
             if ($dateRegistration->isLater($dateNow)) {
                 $this->_message->addMessage('Erro: Data Rejistu depois ho data ohin', App_Message::ERROR);
                 $this->addFieldError('date_registration');
                 return false;
             }
             $districtMapper = new Register_Model_Mapper_AddDistrict();
             $district = $districtMapper->fetchRow($this->_data['fk_id_adddistrict']);
             $this->_data['num_year'] = date('y');
             $this->_data['num_district'] = $district->acronym;
             $this->_data['num_servicecode'] = 'BU';
             $this->_data['num_sequence'] = str_pad($this->_getNumSequence($this->_data), 4, '0', STR_PAD_LEFT);
             $this->_data['date_registration'] = $dateRegistration->toString('yyyy-MM-dd');
             $history = 'REJISTRU KLIENTE: %s HAKAT 1 - REJISTRU DADOS OBRIGATORIU HUSI KLIENTE';
             // Prepare the data to the history
             $dataHistory = array('action' => 'KLIENTE HALO REJISTRU CEOP', 'description' => 'REJISTRU DADOS OBRIGATORIU HUSI KLIENTE');
         } else {
             unset($this->_data['date_registration'], $this->_data['fk_id_adddistrict'], $this->_data['num_subdistrict']);
             $history = 'ATUALIZA KLIENTE: %s DADUS PRINCIPAL - ATUALIZA DADOS OBRIGATORIU HUSI KLIENTE';
             // Prepare the data to the history
             $dataHistory = array('action' => 'ATUALIZA KLIENTE DADUS PRINCIPAL', 'description' => 'ATUALIZA DADOS OBRIGATORIU HUSI KLIENTE');
         }
         $this->_data['birth_date'] = $dateBirth->toString('yyyy-MM-dd');
         // Save the Client
         $id = parent::_simpleSave();
         // If it is inserting the client and it has document
         if (empty($dataForm['id_perdata']) && !empty($dataForm['fk_id_pertypedocument'])) {
             $dataForm['fk_id_perdata'] = $id;
             $this->_saveDocument($dataForm);
         }
         // Set the missing data to the history
         $dataHistory['fk_id_perdata'] = $id;
         $dataHistory['fk_id_dec'] = $dataForm['fk_id_dec'];
         // Save the client history
         $this->_saveHistory($dataHistory);
         // Save the audit
         $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;
     }
 }
Example #30
0
	public function dataValidator($formData,$formType)
	{
		$errorMsg = null;
		$trigger = 0;

		if($formData['probStart'] != null && $formData['probEnd'] != null)
		{
			$dateStart = new Zend_Date($formData['probStart'],'YYYY-MM-DD');
			$dateEnd = new Zend_Date($formData['probEnd'],'YYYY-MM-DD');
			
			if($dateStart->isLater($dateEnd))
			{
				$trigger = 1;
				$errorMsg = General_Models_Text::$text_date_startEndError."<br/>".$errorMsg;
				}
			}
			
		$array['trigger'] = $trigger;
		$array['errorMsg'] = $errorMsg;
		return $array;
	}