Change UI, update query see BT#12723

pull/2487/head
jmontoyaa 9 years ago
parent ab08b53e8f
commit 4d88a2f4f7
  1. 18
      plugin/studentfollowup/post.php
  2. 4
      plugin/studentfollowup/posts.php
  3. 56
      plugin/studentfollowup/view/post.html.twig
  4. 2
      plugin/studentfollowup/view/posts.html.twig

@ -35,34 +35,43 @@ if ($showPrivate == false) {
$criteria->andWhere(Criteria::expr()->eq('id', $postId));
$qb
->select('p')
->select('distinct p')
->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p')
->addCriteria($criteria)
->setMaxResults(1)
;
$query = $qb->getQuery();
/** @var CarePost $post */
$post = $query->getOneOrNullResult();
// Get related posts (post with same parent)
$relatedPosts = [];
if ($post && !empty($post->getParent())) {
if ($post) {
$qb = $em->createQueryBuilder();
$criteria = Criteria::create();
if ($showPrivate == false) {
$criteria->andWhere(Criteria::expr()->eq('private', false));
}
$criteria->andWhere(Criteria::expr()->eq('parent', $post->getParent()));
$criteria->andWhere(Criteria::expr()->neq('id', $post->getId()));
if (!empty($post->getParent())) {
$criteria->andWhere(Criteria::expr()->eq('parent', $post->getParent()));
}
$criteria->andWhere(Criteria::expr()->eq('parent', $post->getId()));
$criteria->orWhere(Criteria::expr()->eq('id', $post->getId()));
$qb
->select('p')
->distinct()
->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p')
->addCriteria($criteria)
->orderBy('p.createdAt', 'desc')
;
$query = $qb->getQuery();
//var_dump($query->getSQL());
$relatedPosts = $query->getResult();
}
//var_dump($post->getTitle());
$tpl = new Template($plugin->get_lang('plugin_title'));
$tpl->assign('post', $post);
@ -77,6 +86,7 @@ $tpl->assign(
)
);
$tpl->assign('information_icon', Display::return_icon('info.png'));
$tpl->assign('student_info', api_get_user_info($studentId));
$content = $tpl->fetch('/'.$plugin->get_name().'/view/post.html.twig');
// Assign into content

@ -36,6 +36,7 @@ $pageSize = 2;
$qb
->select('p')
->distinct()
->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p')
->addCriteria($criteria)
->setFirstResult($pageSize * ($currentPage - 1))
@ -48,6 +49,7 @@ $posts = new Paginator($query, $fetchJoinCollection = true);
$totalItems = count($posts);
$pagesCount = ceil($totalItems / $pageSize);
$pagination = '';
$url = api_get_self().'?student_id='.$studentId;
if ($totalItems > 1) {
@ -70,7 +72,7 @@ $tpl->assign('current_url', $url);
$url = api_get_path(WEB_PLUGIN_PATH).'studentfollowup/post.php?student_id='.$studentId;
$tpl->assign('post_url', $url);
$tpl->assign('information_icon', Display::return_icon('info.png'));
$tpl->assign('student_info', api_get_user_info($studentId));
$tpl->assign('pagination', $pagination);
$content = $tpl->fetch('/'.$plugin->get_name().'/view/posts.html.twig');
// Assign into content

@ -20,25 +20,24 @@
{% endif %}
{% if post.parent %}
<h3>Parent</h3>
<a href="{{ post_url }}&post_id={{ post.parent.id }}">
{{ post.parent.title }}
</a>
{% endif %}
{% endif %}
{% if type == 'all' %}
{% if related_posts %}
<h3>Related</h3>
{% for post in related_posts %}
<p>
<a href="{{ post_url }}&post_id={{ post.id }}">
{{ post.title }}
</a>
</p>
{% endfor %}
{% endif %}
{% endif %}
{#{% if type == 'all' %}#}
{#{% if related_posts %}#}
{#<h3>Related</h3>#}
{#{% for post in related_posts %}#}
{#<p>#}
{#<a href="{{ post_url }}&post_id={{ post.id }}">#}
{#{{ post.title }}#}
{#</a>#}
{#</p>#}
{#{% endfor %}#}
{#{% endif %}#}
{#{% endif %}#}
</div>
<div class="col-md-4">
@ -60,15 +59,15 @@
</div>
</div>
</div>
{% if post.children.count %}
{% for child in post.children %}
{{ _self.post_template('all', child) }}
{#<a href="{{ post_url }}&post_id={{ child.id }}">#}
{#{{ child.title }}#}
{#</a>#}
{% endfor %}
{% endif %}
{#{% if type == 'all' %}#}
{#{% if post.children.count %}#}
{#{% for child in post.children %}#}
{#{% if child.id != post.id %}#}
{#{{ _self.post_template('all', child) }}#}
{#{% endif %}#}
{#{% endfor %}#}
{#{% endif %}#}
{#{% endif %}#}
{% endif %}
{% endmacro %}
@ -78,6 +77,15 @@
{{ back_link }}
</div>
<h2 class="text-center">Care detail view</h2>
<h2 class="text-center">
Care detail view - {{ student_info.complete_name }} - {{ post.title }}
{% if post.parent %}
{{ post.parent.title }}
{% endif %}
</h2>
{% for post in related_posts %}
{{ template.post_template('all', post, information_icon, post_url, current_url) }}
{% endfor %}
{{ template.post_template('all', post, information_icon, post_url, current_url, related_posts) }}
{#{{ template.post_template('all', post, information_icon, post_url, current_url, related_posts) }}#}

@ -1,6 +1,6 @@
{% import 'studentfollowup/view/post.html.twig' as template %}
<h2 class="text-center">Care detail view</h2>
<h2 class="text-center">Care detail view - {{ student_info.complete_name }}</h2>
{% if posts %}
{% for post in posts %}
{{ template.post_template('simple', post, information_icon, post_url, current_url) }}

Loading…
Cancel
Save