/**
  * @return string
  */
 protected function renderEditableFirstValueContent()
 {
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("EditableDateElement");
     $cClipWidget->widget('application.core.widgets.ZurmoJuiDatePicker', array('value' => DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->model->value), 'htmlOptions' => $this->getHtmlOptionsForFirstValue()));
     $cClipWidget->endClip();
     $inputContent = $cClipWidget->getController()->clips['EditableDateElement'];
     $inputContent = ZurmoHtml::tag('div', array('class' => 'has-date-select'), $inputContent);
     $error = $this->form->error($this->model, 'value', array('inputID' => $this->getFirstValueEditableInputId()));
     return $inputContent . $error;
 }
コード例 #2
0
 public function testValidAndInvalidDateDateTimeValidation()
 {
     $language = Yii::app()->getLanguage();
     $this->assertEquals($language, 'en');
     $this->assertEquals(false, CDateTimeParser::parse('04:04:1980', DatabaseCompatibilityUtil::getDateFormat()));
     $this->assertEquals(null, DateTimeUtil::resolveValueForDateLocaleFormattedDisplay('04:04:1980'));
     $model = new DateDateTime();
     $model->aDate = '04:04:1980';
     $model->aDateTime = 'notATimeStamp';
     $saved = $model->save();
     $this->assertFalse($saved);
     $compareData = array('aDate' => array('A Date must be date.'), 'aDateTime' => array('A Date Time must be datetime.'));
     $this->assertEquals($compareData, $model->getErrors());
     //Now test setting an integer for dateTime which is wrong
     $model = new DateDateTime();
     $model->aDate = '1981-07-05';
     $model->aDateTime = 1241341412421;
     $saved = $model->save();
     $this->assertFalse($saved);
     $compareData = array('aDateTime' => array('A Date Time must be datetime.'));
     $this->assertEquals($compareData, $model->getErrors());
     //Now test a successful validation.
     $this->assertEquals('M/d/yy', DateTimeUtil::getLocaleDateFormat());
     $model = new DateDateTime();
     $model->aDate = '1981-07-05';
     $model->aDateTime = '1981-07-05 04:04:04';
     $saved = $model->save();
     $this->assertEquals(array(), $model->getErrors());
     $this->assertTrue($saved);
     $this->assertNull($model->aDateTime2);
     //now set DateTime2 and test if you save and then clear it that it is behaving properly.
     $model->aDateTime2 = '1981-07-05 04:04:04';
     $saved = $model->save();
     $this->assertTrue($saved);
     $this->assertEquals('1981-07-05 04:04:04', $model->aDateTime2);
     $model->aDateTime2 = null;
     $saved = $model->save();
     $this->assertTrue($saved);
     $id = $model->id;
     $model->forget();
     $model = DateDateTime::getById($id);
     $this->assertNull($model->aDateTime2);
 }
 /**
  * @param string $date
  * @return null
  */
 protected static function resolveAbbreviatedDayMonthDisplayLabel($date)
 {
     assert('is_string($date)');
     return DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($date, DateTimeUtil::DISPLAY_FORMAT_ABBREVIATED_MONTH_AND_DAY_WIDTH);
 }
コード例 #4
0
ファイル: DateElement.php プロジェクト: sandeep1027/zurmo_
 /**
  * Renders the attribute from the model.
  * @return The element's content.
  */
 protected function renderControlNonEditable()
 {
     return DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->model->{$this->attribute});
 }
 private function getDisplayLabel($date, $groupingBy)
 {
     $dateForLabel = $date;
     $format = DateTimeUtil::DISPLAY_FORMAT_ABBREVIATED_MONTH_AND_DAY_WIDTH;
     if ($groupingBy == MarketingOverallMetricsForm::GROUPING_TYPE_WEEK) {
         $date = new DateTime($date);
         $date->modify('Sunday' == $date->format('l') ? 'Monday last week' : 'Monday this week');
         $dateForLabel = $date->format('Y-m-d');
     } elseif ($groupingBy == MarketingOverallMetricsForm::GROUPING_TYPE_MONTH) {
         $format = DateTimeUtil::DISPLAY_FORMAT_ABBREVIATED_MONTH_ONLY_WIDTH;
     }
     $displayLabel = DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($dateForLabel, $format);
     return $displayLabel;
 }
コード例 #6
0
 public function testResolveValueForDateLocaleFormattedDisplay()
 {
     $displayValue = DateTimeUtil::resolveValueForDateLocaleFormattedDisplay('2007-07-01');
     $this->assertEquals('7/1/07', $displayValue);
     //other locales
     Yii::app()->setLanguage('de');
     $displayValue = DateTimeUtil::resolveValueForDateLocaleFormattedDisplay('2007-07-01');
     $this->assertEquals('01.07.07', $displayValue);
 }
コード例 #7
0
 /**
  * @param DisplayAttributeForReportForm $displayAttribute
  * @param mixed $value
  * @return mixed
  * @throws NotSupportedException if the currencyConversionType is invalid or null, when the displayAttribute
  * is a currency type
  */
 protected function formatValue(DisplayAttributeForReportForm $displayAttribute, $value)
 {
     if ($displayAttribute->isATypeOfCurrencyValue()) {
         if ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_ACTUAL) {
             return Yii::app()->numberFormatter->formatDecimal((double) $value);
         } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_BASE) {
             return Yii::app()->numberFormatter->formatCurrency((double) $value, Yii::app()->currencyHelper->getBaseCode());
         } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_SPOT) {
             return Yii::app()->numberFormatter->formatCurrency((double) $value * $this->report->getFromBaseToSpotRate(), $this->report->getSpotConversionCurrencyCode());
         } else {
             throw new NotSupportedException();
         }
     } elseif ($displayAttribute->getDisplayElementType() == 'Decimal') {
         return Yii::app()->numberFormatter->formatDecimal((double) $value);
     } elseif ($displayAttribute->getDisplayElementType() == 'Integer') {
         return Yii::app()->numberFormatter->formatDecimal((int) $value);
     } elseif ($displayAttribute->getDisplayElementType() == 'Date') {
         return DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($value);
     } elseif ($displayAttribute->getDisplayElementType() == 'DateTime') {
         return DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($value);
     } else {
         return $value;
     }
 }
コード例 #8
0
 protected function renderEditableSecondDateContent($disabled = null)
 {
     assert('$disabled === null || $disabled = "disabled"');
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("EditableDateElement");
     $cClipWidget->widget('application.core.widgets.ZurmoJuiDatePicker', array('attribute' => $this->attribute, 'value' => DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->getValueSecondDate()), 'htmlOptions' => array('id' => $this->getValueSecondDateEditableInputId(), 'name' => $this->getValueSecondDateEditableInputName(), 'disabled' => $disabled)));
     $cClipWidget->endClip();
     $content = $cClipWidget->getController()->clips['EditableDateElement'];
     return ZurmoHtml::tag('div', array('class' => 'has-date-select'), $content);
 }
コード例 #9
0
 /**
  * @return string
  */
 protected function renderConfigureElementsContent()
 {
     $dateRangeContent = DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->resolveForm()->beginDate) . ' - ' . DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->resolveForm()->endDate);
     $content = ZurmoHtml::tag('div', array(), $dateRangeContent);
     $content .= $this->renderGroupByConfigurationForm();
     return $content;
 }
コード例 #10
0
 protected function renderEditableSecondDateContent()
 {
     $themePath = Yii::app()->baseUrl . '/themes/' . Yii::app()->theme->name;
     $value = $this->model->{$this->attribute};
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("EditableDateElement");
     $cClipWidget->widget('ext.zurmoinc.framework.widgets.JuiDatePicker', array('attribute' => $this->attribute, 'value' => DateTimeUtil::resolveValueForDateLocaleFormattedDisplay(ArrayUtil::getArrayValue($value, 'secondDate')), 'language' => YiiToJqueryUIDatePickerLocalization::getLanguage(), 'htmlOptions' => array('id' => $this->getEditableInputId($this->attribute, 'secondDate'), 'name' => $this->getEditableInputName($this->attribute, 'secondDate')), 'options' => array('showOn' => 'both', 'buttonText' => ZurmoHtml::tag('span', array(), '<!--Date-->'), 'showButtonPanel' => true, 'buttonImageOnly' => false, 'dateFormat' => YiiToJqueryUIDatePickerLocalization::resolveDateFormat(DateTimeUtil::getLocaleDateFormat()))));
     $cClipWidget->endClip();
     $content = $cClipWidget->getController()->clips['EditableDateElement'];
     return ZurmoHtml::tag('div', array('class' => 'has-date-select'), $content);
 }