diff --git a/main/cron/import_csv.php b/main/cron/import_csv.php index 2ea0ef3915..76c3cb4285 100755 --- a/main/cron/import_csv.php +++ b/main/cron/import_csv.php @@ -2141,11 +2141,9 @@ class ImportCsv $criteria = [ 'externalCareId' => $row['External_care_id'] ]; - var_dump($criteria); $post = $em->getRepository('ChamiloPluginBundle:StudentFollowUp\CarePost')->findOneBy($criteria); if (empty($post)) { - var_dump('empty'); $post = new CarePost(); } diff --git a/plugin/studentfollowup/Entity/CarePost.php b/plugin/studentfollowup/Entity/CarePost.php index 97851aad0d..8cf003f8b6 100644 --- a/plugin/studentfollowup/Entity/CarePost.php +++ b/plugin/studentfollowup/Entity/CarePost.php @@ -7,8 +7,14 @@ use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; /** + * * CarePost * + * When installing the plugin, this fill will be move inside: + * src/Chamilo/PluginBundle/Entity/StudentFollowUp/ + * in order that Chamilo/Doctrine register it before using + * + * * @ORM\Table(name="sfu_post") * @ORM\Entity * @Gedmo\Tree(type="nested") @@ -106,7 +112,7 @@ class CarePost /** * @ORM\OneToMany(targetEntity="CarePost", mappedBy="parent") - * @ORM\OrderBy({"lft" = "ASC"}) + * @ORM\OrderBy({"createdAt" = "DESC"}) */ private $children; @@ -420,7 +426,4 @@ class CarePost return $this; } - - - } diff --git a/plugin/studentfollowup/post.php b/plugin/studentfollowup/post.php index 61c419ffa4..8e63a40c81 100644 --- a/plugin/studentfollowup/post.php +++ b/plugin/studentfollowup/post.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Doctrine\Common\Collections\Criteria; -use Doctrine\ORM\Tools\Pagination\Paginator; +use Chamilo\PluginBundle\Entity\StudentFollowUp\CarePost; require_once __DIR__.'/../../main/inc/global.inc.php'; @@ -40,12 +40,35 @@ $qb ->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())) { + $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())); + $qb + ->select('p') + ->from('ChamiloPluginBundle:StudentFollowUp\CarePost', 'p') + ->addCriteria($criteria) + ->orderBy('p.createdAt', 'desc') + ; + $query = $qb->getQuery(); + $relatedPosts = $query->getResult(); + +} + + $tpl = new Template($plugin->get_lang('plugin_title')); $tpl->assign('post', $post); +$tpl->assign('related_posts', $relatedPosts); $url = api_get_path(WEB_PLUGIN_PATH).'/studentfollowup/post.php?student_id='.$studentId; $tpl->assign('post_url', $url); $tpl->assign( diff --git a/plugin/studentfollowup/view/post.html.twig b/plugin/studentfollowup/view/post.html.twig index 222d280408..9898e6cc90 100644 --- a/plugin/studentfollowup/view/post.html.twig +++ b/plugin/studentfollowup/view/post.html.twig @@ -1,4 +1,4 @@ -{% macro post_template(post, information_icon, post_url, current_url) %} +{% macro post_template(type, post, information_icon, post_url, current_url, related_posts) %} {% if post %}
{{ post.content }}
@@ -22,29 +22,45 @@ {% set countElements = post.hasParent + post.children.count %} {% if countElements %} - {% if countElements > 1%} -{{ information_icon }} + {{ countElements }}
+ + {% if countElements > 1 %} + {{ information_icon }} + {{ countElements }} {% else %} -{{ information_icon }}
+ {{ information_icon }} {% endif %} - {% endif %} - - {% if post.parent %} -
-
- {{ child.title }}
+
+ {% if type == 'all' %}
+ {% if post.parent %}
+ Parent
+
+ {{ post.parent.title }}
-