protected static function renderExpirationDateTimeContent(GameReward $gameReward)
 {
     if (!DateTimeUtil::isDateTimeStringNull($gameReward->expirationDateTime)) {
         $content = Zurmo::t('ZurmoModule', 'Until') . ' ';
         return $content . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($gameReward->expirationDateTime);
     }
 }
Пример #2
0
 /**
  * Renders the attribute from the model.
  * @return The element's content.
  */
 protected function renderControlNonEditable()
 {
     if ($this->model->{$this->attribute} != null) {
         $content = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->{$this->attribute});
         return ZurmoHtml::encode($content);
     }
 }
Пример #3
0
 /**
  * Renders and returns string content of summary content for the given model.
  * @param RedBeanModel $model
  * @param mixed $redirectUrl
  * @param string $ownedByFilter
  * @param string $viewModuleClassName
  * @return string content
  */
 public static function renderItemAndCommentsContent(SocialItem $model, $redirectUrl, $renderToUserString)
 {
     assert('is_string($redirectUrl) || $redirectUrl == null');
     $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $model->owner->id));
     $content = '<div class="social-item">';
     $avatarImage = $model->owner->getAvatarImage(50);
     $content .= '<div class="comment model-details-summary clearfix">';
     $content .= '<span class="user-details">' . ZurmoHtml::link($avatarImage, $userUrl);
     $content .= '</span>';
     $userLink = ZurmoHtml::link(strval($model->owner), $userUrl, array('class' => 'user-link'));
     $content .= '<div class="comment-content"><p>';
     if ($model->toUser->id > 0 && $renderToUserString) {
         $toUserUrl = Yii::app()->createUrl('/users/default/details', array('id' => $model->toUser->id));
         $toUserLink = ZurmoHtml::link(strval($model->toUser), $toUserUrl, array('class' => 'user-link'));
         $content .= Zurmo::t('SocialItemsModule', '{postedFromUser} to {postedToUser}', array('{postedFromUser}' => $userLink, '{postedToUser}' => $toUserLink));
     } else {
         $content .= $userLink;
     }
     $content .= '</p>';
     $content .= self::renderModelDescription($model) . '</div>';
     $content .= self::renderAfterDescriptionContent($model);
     $content .= self::renderItemFileContent($model);
     $content .= '<span class="comment-details"><strong>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($model->createdDateTime, 'long', null) . '</strong>';
     if ($model->canUserDelete(Yii::app()->user->userModel)) {
         $content .= ' · <span class="delete-comment">' . self::renderDeleteLinkContent($model) . '</span></span>';
     }
     $content .= '</div>';
     $content .= self::renderCommentsContent($model);
     $content .= self::renderCreateCommentContent($model);
     $content .= '</div>';
     self::registerListColumnScripts();
     return $content;
 }
Пример #4
0
 /**
  * @param Meeting $meeting
  * @param string $link
  * @return string
  */
 public static function renderDaySummaryContent(Meeting $meeting, $link)
 {
     $content = null;
     $content .= '<h3>' . $meeting->name . '<span>' . $link . '</span></h3>';
     $content .= DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($meeting->startDateTime);
     $localEndDateTime = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($meeting->endDateTime);
     if ($localEndDateTime != null) {
         $content .= ' - ' . $localEndDateTime;
     }
     $content .= '<br/>';
     $content .= self::renderActivityItemsContentsExcludingContacts($meeting);
     if (count($meeting->activityItems) > 0) {
         $contactsContent = null;
         $contactLabels = self::getExistingContactRelationsLabels($meeting->activityItems);
         foreach ($contactLabels as $label) {
             if ($contactsContent != null) {
                 $contactsContent .= ', ';
             }
             $contactsContent .= $label;
         }
         $content .= $contactsContent . '<br/>';
     }
     if ($meeting->description != null) {
         $content .= '<br/>';
         $content .= Zurmo::t('MeetingsModule', 'Description') . ':<br/>';
         $content .= $meeting->description;
     }
     return $content;
 }
 /**
  * Runs a query to get all the dates for meetings based on SearchAttributeData.  Then the data is processed
  * and @returns a data array of dates and quantity.  Quantity stands for how many meetings in a given date.
  * (non-PHPdoc)
  * @see CalendarDataProvider::getData()
  */
 public function getData()
 {
     $sql = $this->makeSqlQuery();
     $rows = ZurmoRedBean::getAll($sql);
     $data = array();
     foreach ($rows as $row) {
         $localTimeZoneAdjustedDate = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($row['startdatetime'], 'medium', null);
         if (isset($data[$localTimeZoneAdjustedDate])) {
             $data[$localTimeZoneAdjustedDate]['quantity'] = $data[$localTimeZoneAdjustedDate]['quantity'] + 1;
         } else {
             $data[$localTimeZoneAdjustedDate] = array('date' => $localTimeZoneAdjustedDate, 'quantity' => 1, 'dbDate' => $row['startdatetime']);
         }
     }
     foreach ($data as $key => $item) {
         if ($item['quantity'] == 1) {
             $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModuleSingularLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
         } else {
             $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModulePluralLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
         }
         $data[$key]['label'] = $label;
         if ($item['quantity'] > 5) {
             $quantityClassSuffix = 6;
         } else {
             $quantityClassSuffix = $item['quantity'];
         }
         $data[$key]['className'] = 'calendar-events-' . $quantityClassSuffix;
     }
     return $data;
 }
 protected function renderDescriptionContent()
 {
     $innerContent = '<b>' . $this->model->getAttributeLabel('sendOnDateTime') . ':</b> ';
     $innerContent .= DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->sendOnDateTime);
     $innerContent .= "</BR><b>" . $this->model->getAttributeLabel('subject') . ':</b> ';
     $innerContent .= $this->model->subject;
     $content = ZurmoHtml::tag('div', array('class' => static::DESCRIPTION_CLASS), $innerContent);
     return $content;
 }
 /**
  * @depends testInlineCreateCommentFromAjax
  */
 public function testUpdateDueDateTimeViaAjax()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $tasks = Task::getByName('aTest');
     $task = $tasks[0];
     $taskId = $task->id;
     $this->setGetArray(array('id' => $task->id, 'dateTime' => '7/23/13 12:00 am'));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/updateDueDateTimeViaAjax', true);
     $task = Task::getById($taskId);
     $displayDateTime = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($task->dueDateTime);
     $this->assertEquals('7/23/13 12:00 AM', $displayDateTime);
 }
 /**
  * @return string
  */
 protected function renderEditableFirstValueContent()
 {
     $value = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->value);
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("EditableDateTimeElement");
     $cClipWidget->widget('application.core.widgets.ZurmoJuiDateTimePicker', array('value' => $value, 'htmlOptions' => $this->getHtmlOptionsForFirstValue()));
     $cClipWidget->endClip();
     $inputContent = $cClipWidget->getController()->clips['EditableDateTimeElement'];
     $inputContent = ZurmoHtml::tag('div', array('class' => 'has-date-select'), $inputContent);
     $error = $this->form->error($this->model, 'value', array('inputID' => $this->getFirstValueEditableInputId()));
     return $inputContent . $error;
 }
 public function testGetImageSummary()
 {
     $imageFileModel = new ImageFileModel();
     $imageFileModel->name = 'test.gif';
     $imageFileModel->width = 100;
     $imageFileModel->height = 300;
     $imageFileModel->type = 'image/gif';
     $imageFileModel->save();
     $createdDateTime = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($imageFileModel->createdDateTime);
     $expectedContent = '<div class="builder-image-details"><strong>test.gif</strong><br />0 · 100 × 300 · Created by (Unnamed) on ' . $createdDateTime . '</div>';
     $this->assertContains($expectedContent, ImageFileModelUtil::getImageSummary($imageFileModel));
     $expectedContent = $createdDateTime . ' by (Unnamed) 100 × 300';
     $this->assertContains($expectedContent, ImageFileModelUtil::getImageSummary($imageFileModel, "{createdTime} by {creator} {dimensions}"));
 }
 /**
  * Combines the 'user' with the 'datetime stamp'
  * into a single string
  * @return The element's content.
  */
 protected function renderNonEditableContent($attributeName)
 {
     assert('$attributeName == "created"  || $attributeName == "modified"');
     $userModelName = $attributeName . 'ByUser';
     $dateTimeAttributeName = $attributeName . 'DateTime';
     assert('$this->model->isAttribute($dateTimeAttributeName)');
     if (empty($this->model->{$dateTimeAttributeName})) {
         return Zurmo::t('Core', 'Unknown');
     }
     $content = ZurmoHtml::encode(DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->{$dateTimeAttributeName}));
     if ($this->model->{$userModelName}->id > 0) {
         $content .= '&#160;' . Zurmo::t('Core', 'by') . '&#160;' . Yii::app()->format->text($this->model->{$userModelName});
     }
     return $content;
 }
Пример #11
0
 protected function renderMissionContent()
 {
     $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $this->model->createdByUser->id));
     $content = '<div class="comment model-details-summary">';
     $content .= ZurmoHtml::link($this->model->createdByUser->getAvatarImage(100), $userUrl);
     $content .= '<span class="user-details">';
     $content .= ZurmoHtml::link(strval($this->model->createdByUser), $userUrl, array('class' => 'user-link'));
     $content .= '</span>';
     $element = new TextAreaElement($this->model, 'description');
     $element->nonEditableTemplate = '<div class="comment-content">{content}</div>';
     $content .= $element->render();
     if ($this->model->reward != null) {
         $element = new TextElement($this->model, 'reward');
         $element->nonEditableTemplate = '<div class="comment-content">' . Zurmo::t('MissionsModule', 'Reward') . ': {content}</div>';
         $content .= $element->render();
     }
     if ($this->model->takenByUser->id > 0) {
         $element = new UserElement($this->model, 'takenByUser');
         $element->nonEditableTemplate = '<div class="comment-content">' . Zurmo::t('MissionsModule', 'Taken By') . ': {content}</div>';
         $content .= $element->render();
     }
     if (!DateTimeUtil::isDateTimeValueNull($this->model, 'dueDateTime')) {
         $element = new DateTimeElement($this->model, 'dueDateTime');
         $element->nonEditableTemplate = '<div class="comment-content">' . Zurmo::t('MissionsModule', 'Due') . ': {content}</div>';
         $content .= $element->render();
     }
     $date = '<span class="comment-details"><strong>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->createdDateTime, 'long', null) . '</strong></span>';
     $content .= $date;
     if ($this->model->files->count() > 0) {
         $element = new FilesElement($this->model, 'null');
         $element->nonEditableTemplate = '<div>{content}</div>';
         $content .= '<div><strong>' . Zurmo::t('MissionsModule', 'Attachments') . '</strong></div>';
         $content .= $element->render();
     }
     $element = new MissionStatusElement($this->model, 'status');
     $element->nonEditableTemplate = '<div class="comment-content">' . Zurmo::t('MissionsModule', 'Status') . ': {content}</div>';
     $content .= $element->render();
     $content .= '</div>';
     return ZurmoHtml::tag('div', array('id' => 'ModelDetailsSummaryView'), $content);
 }
Пример #12
0
 /**
  * Renders and returns string content of summary content for the given model.
  * @param RedBeanModel $model
  * @param mixed $redirectUrl
  * @param string $ownedByFilter
  * @param string $viewModuleClassName
  * @return string content
  */
 public static function renderSummaryContent(RedBeanModel $model, $redirectUrl, $ownedByFilter, $viewModuleClassName)
 {
     assert('is_string($redirectUrl) || $redirectUrl == null');
     assert('is_string($ownedByFilter)');
     assert('is_string($viewModuleClassName)');
     $mashableActivityRules = MashableActivityRulesFactory::createMashableActivityRulesByModel(get_class($model));
     $orderByAttributeName = $mashableActivityRules->getLatestActivitiesOrderByAttributeName();
     $summaryContentTemplate = $mashableActivityRules->getSummaryContentTemplate($ownedByFilter, $viewModuleClassName);
     $content = '<div class="activity-item">';
     //Render icon
     $content .= '<em class="' . get_class($model) . '"></em>';
     //Render date
     $content .= '<strong class="activity-date">' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($model->{$orderByAttributeName}, 'long', null) . '</strong>';
     $data = array();
     $data['modelStringContent'] = self::renderModelStringContent($model, $redirectUrl);
     $data['ownerStringContent'] = self::renderOwnerStringContent($model);
     $data['relatedModelsByImportanceContent'] = $mashableActivityRules->renderRelatedModelsByImportanceContent($model);
     $data['extraContent'] = self::resolveAndRenderExtraContent($model, $mashableActivityRules);
     //Render display content
     $content .= self::resolveContentTemplate($summaryContentTemplate, $data);
     $content .= '</div>';
     return $content;
 }
 /**
  * @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;
     }
 }
Пример #14
0
 public function testConvertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero()
 {
     $timeZone = date_default_timezone_get();
     date_default_timezone_set('GMT');
     $dbValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('6/3/80 12:00 AM');
     $this->assertEquals('1980-06-03 00:00:00', $dbValue);
     //other locales
     Yii::app()->setLanguage('de');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03.06.80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     Yii::app()->setLanguage('it');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03/06/80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     Yii::app()->setLanguage('fr');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03/06/80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     //test null value returns null.
     $displayValue = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay(null);
     $this->assertEquals(null, $displayValue);
     date_default_timezone_set($timeZone);
 }
 protected function renderCommentsContent()
 {
     $content = null;
     $rows = 0;
     foreach (array_reverse($this->commentsData) as $comment) {
         //Skip the first if the page size is smaller than what is returned.
         if (count($this->commentsData) > $this->pageSize && $this->pageSize != null && $rows == 0) {
             $rows++;
             continue;
         }
         $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $comment->createdByUser->id));
         $stringContent = ZurmoHtml::link($comment->createdByUser->getAvatarImage(36), $userUrl);
         $userName = ZurmoHtml::link(strval($comment->createdByUser), $userUrl, array('class' => 'user-link'));
         $element = new TextAreaElement($comment, 'description');
         $element->nonEditableTemplate = '<div class="comment-content"><p>' . $userName . ': {content}</p>';
         $stringContent .= $element->render();
         //attachments
         if ($comment->files->count() > 0) {
             $stringContent .= FileModelDisplayUtil::renderFileDataDetailsWithDownloadLinksContent($comment, 'files', true);
         }
         if ($comment->createdByUser == Yii::app()->user->userModel || $this->relatedModel->createdByUser == Yii::app()->user->userModel || $this->relatedModel instanceof OwnedSecurableItem && $this->relatedModel->owner == Yii::app()->user->userModel) {
             $deleteCommentLink = ' · <span class="delete-comment">' . $this->renderDeleteLinkContent($comment) . '</span>';
             $editCommentLink = ' · <span class="edit-comment">' . $this->renderEditLinkContent($comment) . '</span>';
         } else {
             $deleteCommentLink = null;
             $editCommentLink = null;
         }
         $editCommentLink = null;
         //temporary until edit link is added
         $stringContent .= '<span class="comment-details"><strong>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($comment->createdDateTime, 'long', null) . '</strong></span>' . $editCommentLink . $deleteCommentLink;
         $stringContent .= '</div>';
         $content .= '<div class="comment">' . $stringContent . '</div>';
         $rows++;
     }
     return $content;
 }
 protected function resolveAndRenderTaskCardDetailsDueDateContent(Task $task)
 {
     if ($task->dueDateTime != null) {
         $content = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($task->dueDateTime, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, null);
         return ZurmoHtml::tag('span', array('class' => 'task-due-date'), $content);
     }
 }
Пример #17
0
 public static function getImageSummary(ImageFileModel $imageFileModel, $layout = null)
 {
     $data = array();
     if ($layout == null) {
         $layout = static::getDefaultLayout();
     }
     $imagePath = ImageFileModel::getImageCachePathByFileName($imageFileModel->getImageCacheFileName(), false);
     if (!file_exists($imagePath)) {
         $imageFileModel->createImageCache();
     }
     static::resolveWidthAndHeightAttributesIfTheyAreMissing($imageFileModel);
     $url = static::getUrlForGetImageFromImageFileName($imageFileModel->getImageCacheFileName(), true);
     $urlForPreview = Yii::app()->createAbsoluteUrl('zurmo/imageModel/modalPreview', array('fileName' => $imageFileModel->getImageCacheFileName()));
     $data['{image}'] = ZurmoHtml::image($url, '', array('data-url' => $urlForPreview));
     $data['{name}'] = $imageFileModel->name;
     $data['{size}'] = FileModelDisplayUtil::convertSizeToHumanReadableAndGet((int) $imageFileModel->size);
     $data['{dimensions}'] = $imageFileModel->width . ' × ' . $imageFileModel->height;
     $data['{creator}'] = $imageFileModel->createdByUser;
     $data['{createdTime}'] = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($imageFileModel->createdDateTime);
     $data['{selectLink}'] = static::getSelectLink();
     $data['{editLink}'] = static::getEditLink();
     return strtr($layout, $data);
 }
 protected function renderPopulatedBadgeContent()
 {
     $content = '<ul>' . "\n";
     foreach ($this->badgeData as $badge) {
         $gameBadgeRulesClassName = $badge->type . 'GameBadgeRules';
         $value = $gameBadgeRulesClassName::getItemCountByGrade((int) $badge->grade);
         $badgeDisplayLabel = $gameBadgeRulesClassName::getPassiveDisplayLabel($value);
         $badgeContent = null;
         $badgeIconContent = ZurmoHtml::tag('div', array('class' => 'gloss'), '');
         $badgeIconContent .= ZurmoHtml::tag('strong', array('class' => 'badge-icon', 'title' => $badgeDisplayLabel), '');
         $badgeIconContent .= ZurmoHtml::tag('span', array('class' => 'badge-grade'), (int) $badge->grade);
         $badgeContent .= ZurmoHtml::tag('div', array('class' => 'badge ' . $badge->type), $badgeIconContent);
         $badgeContent .= ZurmoHtml::tag('h3', array(), $badgeDisplayLabel);
         $badgeContent .= ZurmoHtml::tag('span', array(), DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($badge->createdDateTime, 'long', null));
         $content .= ZurmoHtml::tag('li', array(), $badgeContent);
     }
     $content .= '</ul>' . "\n";
     return $content;
 }
 protected function renderConversationContent()
 {
     $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $this->model->createdByUser->id));
     $content = '<div class="comment model-details-summary clearfix">';
     $content .= ZurmoHtml::link($this->model->createdByUser->getAvatarImage(100), $userUrl);
     $content .= '<span class="user-details">';
     $content .= ZurmoHtml::link(strval($this->model->createdByUser), $userUrl, array('class' => 'user-link'));
     $content .= '</span>';
     if ($this->model->description == null) {
         $element = new TextElement($this->model, 'subject');
     } else {
         $element = new TextAreaElement($this->model, 'description');
     }
     $element->nonEditableTemplate = '<div class="comment-content">{content}</div>';
     $content .= $element->render();
     $date = '<span class="comment-details"><strong>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->model->createdDateTime, 'long', null) . '</strong></span>';
     $content .= $date;
     $content .= '</div>';
     return ZurmoHtml::tag('div', array('id' => 'ModelDetailsSummaryView'), $content);
 }
Пример #20
0
 public function run()
 {
     $exportItems = ExportItem::getUncompletedItems();
     if (count($exportItems) > 0) {
         foreach ($exportItems as $exportItem) {
             if (isset($exportItem->exportFileModel)) {
                 //continue;
             }
             $unserializedData = unserialize($exportItem->serializedData);
             if ($unserializedData instanceof RedBeanModelDataProvider) {
                 $formattedData = $unserializedData->getData();
             } else {
                 $formattedData = array();
                 foreach ($unserializedData as $idToExport) {
                     $model = call_user_func(array($exportItem->modelClassName, 'getById'), intval($idToExport));
                     $formattedData[] = $model;
                 }
             }
             if ($exportItem->exportFileType == 'csv') {
                 $headerData = array();
                 foreach ($formattedData as $model) {
                     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
                         $modelToExportAdapter = new ModelToExportAdapter($model);
                         if (count($headerData) == 0) {
                             $headerData = $modelToExportAdapter->getHeaderData();
                         }
                         $data[] = $modelToExportAdapter->getData();
                     }
                 }
                 $output = ExportItemToCsvFileUtil::export($data, $headerData);
                 $fileContent = new FileContent();
                 $fileContent->content = $output;
                 $exportFileModel = new ExportFileModel();
                 $exportFileModel->fileContent = $fileContent;
                 $exportFileModel->name = $exportItem->exportFileName . ".csv";
                 $exportFileModel->type = 'application/octet-stream';
                 $exportFileModel->size = strlen($output);
                 $saved = $exportFileModel->save();
                 if ($saved) {
                     $exportItem->isCompleted = 1;
                     $exportItem->exportFileModel = $exportFileModel;
                     $exportItem->save();
                     $message = new NotificationMessage();
                     $message->htmlContent = Zurmo::t('ExportModule', 'Export of {fileName} requested on {dateTime} is completed. <a href="{url}">Click here</a> to download file!', array('{fileName}' => $exportItem->exportFileName, '{url}' => Yii::app()->createUrl('export/default/download', array('id' => $exportItem->id)), '{dateTime}' => DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($exportItem->createdDateTime, 'long')));
                     $rules = new ExportProcessCompletedNotificationRules();
                     NotificationsUtil::submit($message, $rules);
                 }
             }
         }
     } else {
         return true;
     }
     return true;
 }
 protected static function makeStatusContentByJobInProcess($jobInProcess)
 {
     assert('$jobInProcess instanceof JobInProcess || $jobInProcess == null');
     if ($jobInProcess != null && JobsManagerUtil::isJobInProcessOverThreshold($jobInProcess, $jobInProcess->type)) {
         return Zurmo::t('JobsManagerModule', 'In Process (Stuck)');
     } elseif ($jobInProcess != null) {
         $startedDateTimeContent = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($jobInProcess->createdDateTime);
         return Zurmo::t('JobsManagerModule', 'In Process [Started: {startedDateTime}]', array('{startedDateTime}' => $startedDateTimeContent));
     } else {
         return Zurmo::t('JobsManagerModule', 'Idle');
     }
 }
 protected static function getClickedContentForDrillDown(CampaignItem $campaignItem)
 {
     $typesArray = CampaignItemActivity::getTypesArray();
     $campaignItemActivities = CampaignItemActivity::getByTypeAndModelIdAndPersonIdAndUrl(CampaignItemActivity::TYPE_CLICK, $campaignItem->id, $campaignItem->contact->getClassId('Person'), null, 'latestDateTime');
     $content = null;
     foreach ($campaignItemActivities as $campaignItemActivity) {
         $content .= '<tr>';
         $content .= '<td>' . $typesArray[CampaignItemActivity::TYPE_CLICK] . '</td>';
         $content .= '<td>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($campaignItemActivity->latestDateTime) . '</td>';
         $content .= '<td>' . $campaignItemActivity->quantity . '</td>';
         $content .= '<td>' . $campaignItemActivity->latestSourceIP . '</td>';
         $content .= '<td>' . $campaignItemActivity->emailMessageUrl . '</td>';
         $content .= '</tr>';
     }
     return $content;
 }
Пример #23
0
 /**
  * @param ExportItem $exportItem
  * @throws FailedToSaveModelException
  */
 protected function processCompletedWithSecurityExceptionExportItem(ExportItem $exportItem)
 {
     $exportItem->isCompleted = true;
     $saved = $exportItem->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $message = new NotificationMessage();
     $message->htmlContent = Zurmo::t('ExportModule', 'Export requested on {dateTime} was unable to be completed due to a permissions error.', array('{dateTime}' => DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($exportItem->createdDateTime, 'long')));
     $message->textContent = $message->htmlContent;
     $rules = $this->getExportProcessCompletedNotificationRulesForExportItem($exportItem);
     NotificationsUtil::submit($message, $rules);
 }
 public function renderValue($value)
 {
     return DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($value);
 }
 protected static function getLocalizedDateTimeTimeZoneString()
 {
     $content = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay(DateTimeUtil::convertTimestampToDbFormatDateTime(time()));
     $content .= ' ' . Yii::app()->user->userModel->timeZone;
     return $content;
 }
Пример #26
0
 public function __toString()
 {
     $modelClassName = $this->modelClassName;
     $s = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->dateTime) . ', ';
     $s .= $this->user . ', ';
     $s .= $this->eventName;
     if ($this->modelClassName !== null) {
         assert('is_string($this->modelClassName) && $this->modelClassName != ""');
         assert('is_numeric($this->modelId)');
         $s .= ', ' . $modelClassName::getModelLabelByTypeAndLanguage('Singular') . '(' . $this->modelId . ')';
     }
     return $s;
 }
Пример #27
0
 /**
  * Gets full calendar item data.
  * @return string
  */
 public function getCalendarItemData()
 {
     $name = $this->name;
     $location = $this->location;
     $startDateTime = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->startDateTime, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true);
     $endDateTime = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($this->endDateTime, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true);
     $language = Yii::app()->languageHelper->getForCurrentUser();
     $translatedAttributeLabels = self::translatedAttributeLabels($language);
     return array($translatedAttributeLabels['name'] => $name, $translatedAttributeLabels['location'] => $location, $translatedAttributeLabels['startDateTime'] => $startDateTime, $translatedAttributeLabels['endDateTime'] => $endDateTime);
 }
 /**
  * Resolve content for sendgrid bounce or spam email activity.
  * @param CampaignItem $campaignItem
  * @param int $type
  * @return string
  */
 protected static function resolveContentForSendGridBounceOrSpamEventActivity(CampaignItem $campaignItem, $type)
 {
     $typesArray = CampaignItemActivity::getTypesArray();
     $campaignItemActivities = CampaignItemActivity::getByTypeAndModelIdAndPersonIdAndUrl($type, $campaignItem->id, $campaignItem->contact->getClassId('Person'), null, 'latestDateTime');
     $content = null;
     foreach ($campaignItemActivities as $campaignItemActivity) {
         $externalMessageActivities = ExternalApiEmailMessageActivity::getByEmailMessageActivity($campaignItemActivity, "sendgrid", false);
         foreach ($externalMessageActivities as $externalMessageActivity) {
             $content .= '<tr>';
             $content .= '<td>' . $typesArray[$externalMessageActivity->type] . '</td>';
             $content .= '<td>' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($campaignItemActivity->latestDateTime) . '</td>';
             $content .= '<td>' . $campaignItemActivity->quantity . '</td>';
             $content .= '<td>' . $campaignItemActivity->latestSourceIP . '</td>';
             $content .= '<td></td>';
             $content .= '</tr>';
         }
     }
     return $content;
 }
Пример #29
0
 /**
  * Renders completion date time content for the task
  * @param Task $task
  * @return string
  */
 public static function renderCompletionDateTime(Task $task)
 {
     if ($task->completedDateTime == null) {
         $task->completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     }
     return '<p>' . Zurmo::t('TasksModule', 'Completed On') . ': ' . DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($task->completedDateTime) . '</p>';
 }