Skip to content

Commit

Permalink
added notes tab to person view (#1299)
Browse files Browse the repository at this point in the history
resolves #1266
  • Loading branch information
bradgearon authored and DawoudIO committed Nov 9, 2016
1 parent c8e5918 commit 46d8468
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 10 deletions.
52 changes: 52 additions & 0 deletions src/PersonView.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
<li role="presentation"><a href="#groups" aria-controls="groups" role="tab" data-toggle="tab"><?= gettext("Assigned Groups") ?></a></li>
<li role="presentation"><a href="#properties" aria-controls="properties" role="tab" data-toggle="tab"><?= gettext("Assigned Properties") ?></a></li>
<li role="presentation"><a href="#volunteer" aria-controls="volunteer" role="tab" data-toggle="tab"><?= gettext("Volunteer Opportunities") ?></a></li>
<li role="presentation"><a href="#notes" aria-controls="notes" role="tab" data-toggle="tab"><?= gettext("Notes") ?></a></li>
</ul>

<!-- Tab panes -->
Expand Down Expand Up @@ -725,6 +726,57 @@
</div>
</div>
</div>
<div role="tab-pane fade" class="tab-pane" id="notes">
<ul class="timeline">
<!-- note time label -->
<li class="time-label">
<span class="bg-yellow">
<?php echo date_create()->format("Y-m-d") ?>
</span>
</li>
<!-- /.note-label -->

<!-- note item -->
<?php foreach ($timelineService->getNotesForPerson($iPersonID) as $item) { ?>
<li>
<!-- timeline icon -->
<i class="fa <?= $item['style'] ?>"></i>

<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> <?= $item['datetime'] ?></span>

<h3 class="timeline-header">
<?php if (in_array('headerlink', $item)) { ?>
<a href="<?= $item['headerlink'] ?>"><?= $item['header'] ?></a>
<?php } else { ?>
<?= $item['header'] ?>
<?php } ?>
</h3>

<div class="timeline-body">
<?= $item['text'] ?>
</div>

<?php if (($_SESSION['bNotes']) && ($item["editLink"] != "" || $item["deleteLink"] != "")) { ?>
<div class="timeline-footer">
<?php if ($item["editLink"] != "") { ?>
<a href="<?= $item["editLink"] ?>">
<button type="button" class="btn btn-primary"><i class="fa fa-edit"></i></button>
</a>
<?php }
if ($item["deleteLink"] != "") { ?>
<a href="<?= $item["deleteLink"] ?>">
<button type="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
</a>
<?php } ?>
</div>
<?php } ?>
</div>
</li>
<?php } ?>
<!-- END timeline item -->
</ul>
</div>
</div>
</div>
</div>
Expand Down
45 changes: 35 additions & 10 deletions src/Service/TimelineService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,35 @@ function getForFamily($familyID)
return $sortedTimeline;
}

function getForPerson($personID)
{
private function eventsForPerson($personID) {
$timeline = array();
$personNotes = NoteQuery::create()->findByPerId($personID);
foreach ($personNotes as $dbNote) {
$item = $this->noteToTimelineItem($dbNote);
if (!is_null($item)) {
$timeline[$item["key"]] = $item;
}
}

$eventsByPerson = EventAttendQuery::create()->findByPersonId($personID);
foreach ($eventsByPerson as $personEvent) {
$event = $personEvent->getEvent();
$item = $this->createTimeLineItem("cal", $event->getStart('Y-m-d h:i:s'), $event->getTitle(), "",
$event->getDesc(), "", "");
$timeline[$item["key"]] = $item;
}
return $timeline;
}

private function notesForPerson($personID, $noteType) {
$timeline = array();
$personQuery = NoteQuery::create()
->filterByPerId($personID);
if($noteType != null) {
$personQuery->filterByType($noteType);
}
foreach ($personQuery->find() as $dbNote) {
$item = $this->noteToTimelineItem($dbNote);
if (!is_null($item)) {
$timeline[$item["key"]] = $item;
}
}
return $timeline;
}

private function sortTimeline($timeline) {
krsort($timeline);

$sortedTimeline = array();
Expand All @@ -71,6 +81,21 @@ function getForPerson($personID)
return $sortedTimeline;
}

function getNotesForPerson($personID) {
$timeline = $this->notesForPerson($personID, 'note');
return $this->sortTimeline($timeline);
}

function getForPerson($personID)
{
$timeline = array_merge(
$this->notesForPerson($personID, null),
$this->eventsForPerson($personID)
);

return $this->sortTimeline($timeline);
}

/**
* @param $dbNote Note
* @return mixed|null
Expand Down

0 comments on commit 46d8468

Please sign in to comment.