From dfe6a9067330c4893080b441d1b7260c77ee7b2c Mon Sep 17 00:00:00 2001 From: afornerot Date: Tue, 16 Jun 2020 09:09:59 +0200 Subject: [PATCH] indicateurs (ref #156) --- .../CoreBundle/Command/PurgeFileCommand.php | 1 - .../CoreBundle/Command/StatisticCommand.php | 281 ++++++++++++++++++ .../CoreBundle/Controller/GroupController.php | 64 +++- .../Controller/StatisticController.php | 109 +++++++ .../src/Cadoles/CoreBundle/Entity/Group.php | 38 +++ .../Cadoles/CoreBundle/Entity/Statistic.php | 118 ++++++++ .../CoreBundle/Resources/config/routing.yml | 14 +- .../Resources/views/Group/list.html.twig | 9 +- .../Resources/views/Group/statistic.html.twig | 131 ++++++++ .../Resources/views/Statistic/list.html.twig | 263 ++++++++++++++++ .../CronBundle/Command/CronCommand.php | 2 +- .../CronBundle/Command/CronexecCommand.php | 4 +- .../CronBundle/Command/InitDataCommand.php | 19 ++ .../CronBundle/Controller/CronController.php | 22 +- .../CronBundle/Resources/config/routing.yml | 7 +- .../Resources/views/Cron/logs.html.twig | 18 +- tmpl/ninegate-init-01.sql | 12 +- 17 files changed, 1063 insertions(+), 49 deletions(-) create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Command/StatisticCommand.php create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/StatisticController.php create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Statistic.php create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/statistic.html.twig create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Statistic/list.html.twig diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php index 8f449b4e..1e62bac3 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php @@ -48,7 +48,6 @@ class PurgeFileCommand extends Command // Le script est-il executé via Cron:Exec $this->byexec = $input->getArgument('byexec'); if($this->byexec=="") $this->byexec=false; - echo "pouet".$this->byexec; $this->writelnred(''); $this->writelnred('== Core:PurgeFile'); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/StatisticCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/StatisticCommand.php new file mode 100644 index 00000000..a92b7b6f --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/StatisticCommand.php @@ -0,0 +1,281 @@ +setName('Core:Statistic') + ->setDescription('Calculate Statistic') + ->setHelp('This command Calculate Statistic') + ->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job') + ->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron') + ->addArgument('byexec', InputArgument::OPTIONAL, 'By Cron:Exec') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->container = $this->getApplication()->getKernel()->getContainer(); + $this->em = $this->container->get('doctrine')->getEntityManager(); + $this->output = $output; + $this->filesystem = new Filesystem(); + $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/"; + $alias = $this->container->getParameter('alias'); + + // Le script est-il executé via Cron:Exec + $this->byexec = $input->getArgument('byexec'); + if($this->byexec=="") $this->byexec=false; + + $this->writelnred(''); + $this->writelnred('== Core:Statistic'); + $this->writelnred('=========================================================================================================='); + + $now=new \DateTime('now'); + $yesterday=clone $now; + $yesterday->sub(new \DateInterval('P1D')); + $groups=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["fgcanshare"=>true]); + + // totcptvisite + $this->writelnred(''); + $this->writelnred('== totcptvisite'); + + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptvisite"]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("totcptvisite"); + $stat->setValue([]); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('SUM(user.visitecpt) as cpt') + ->from('CadolesCoreBundle:User','user') + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + + // totcptvisitegroup + $this->writelnred(''); + $this->writelnred('== totcptvisitegroup'); + + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptvisitegroup"]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("totcptvisitegroup"); + $stat->setValue([]); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('SUM(usergroup.visitecpt) as cpt') + ->from('CadolesCoreBundle:UserGroup','usergroup') + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + + // totcptmessage + $this->writelnred(''); + $this->writelnred('== totcptmessage'); + + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptmessage"]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("totcptmessage"); + $stat->setValue([]); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(message.id) as cpt') + ->from('CadolesWebsocketBundle:Message','message') + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + + // totcptblogarticle + $this->writelnred(''); + $this->writelnred('== totcptblogarticle'); + + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptblogarticle"]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("totcptblogarticle"); + $stat->setValue([]); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(blogarticle.id) as cpt') + ->from('CadolesPortalBundle:Blogarticle','blogarticle') + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + + // totcptprojecttask + $this->writelnred(''); + $this->writelnred('== totcptprojecttask'); + + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptprojecttask"]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("totcptprojecttask"); + $stat->setValue([]); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(projecttask.id) as cpt') + ->from('CadolesPortalBundle:Projecttask','projecttask') + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + + // groupcptvisite + $this->writelnred(''); + $this->writelnred('== groupcptvisite'); + + foreach($groups as $group) { + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptvisite","group"=>$group]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("groupcptvisite"); + $stat->setValue([]); + $stat->setGroup($group); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select(['SUM(usergroup.visitecpt) as cpt']) + ->from('CadolesCoreBundle:UserGroup','usergroup') + ->Where('usergroup.group=:group') + ->setParameter('group', $group) + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + } + + // groupcptmessage + $this->writelnred(''); + $this->writelnred('== groupcptmessage'); + + foreach($groups as $group) { + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptmessage","group"=>$group]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("groupcptmessage"); + $stat->setValue([]); + $stat->setGroup($group); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(message.id) as cpt') + ->from('CadolesWebsocketBundle:Message','message') + ->Where('message.group=:group') + ->setParameter('group', $group) + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + } + + // groupcptblogarticle + $this->writelnred(''); + $this->writelnred('== groupcptblogarticle'); + + foreach($groups as $group) { + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptblogarticle","group"=>$group]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("groupcptblogarticle"); + $stat->setValue([]); + $stat->setGroup($group); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(blogarticle.id) as cpt') + ->from('CadolesPortalBundle:Blogarticle','blogarticle') + ->from('CadolesPortalBundle:Blog','blog') + ->Where('blogarticle.blog=blog') + ->andwhere(":group MEMBER OF blog.groups") + ->setParameter('group', $group) + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + } + + // groupcptprojecttask + $this->writelnred(''); + $this->writelnred('== groupcptprojecttask'); + + foreach($groups as $group) { + $stat=$this->em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptprojecttask","group"=>$group]); + if(!$stat) { + $stat=new Statistic(); + $stat->setKeyvalue("groupcptprojecttask"); + $stat->setValue([]); + $stat->setGroup($group); + } + $value=$stat->getValue(); + $cpt= $this->em->createQueryBuilder() + ->select('COUNT(projecttask.id) as cpt') + ->from('CadolesPortalBundle:Projecttask','projecttask') + ->from('CadolesPortalBundle:Project','project') + ->Where('projecttask.project=project') + ->andwhere(":group MEMBER OF project.groups") + ->setParameter('group', $group) + ->getQuery()->getOneOrNullResult(); + $value[$now->format("Y-m-d")]=($cpt["cpt"]?$cpt["cpt"]:0); + $stat->setValue($value); + $this->em->persist($stat); + $this->em->flush(); + } + + $this->writeln(''); + return 1; + } + + private function writelnred($string) { + $this->output->writeln(''.$string.''); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + if($this->byexec) $this->filesystem->appendToFile($this->rootlog.'exec.log', $string."\n"); + } + private function writeln($string) { + $this->output->writeln($string); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + if($this->byexec) $this->filesystem->appendToFile($this->rootlog.'exec.log', $string."\n"); + } +} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php index aa69ebe8..67d549bc 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php @@ -127,28 +127,28 @@ class GroupController extends Controller ->setParameter("value", "%".$search["value"]."%"); } switch($order[0]["column"]) { - case 1 : + case 2 : $qb->orderBy('table.label',$order[0]["dir"]); break; - case 2 : + case 3 : $qb->orderBy('table.fgopen',$order[0]["dir"]); break; - case 4 : + case 5 : $qb->orderBy('table.fgcanshare',$order[0]["dir"]); break; - case 5 : + case 6 : $qb->orderBy('table.owner',$order[0]["dir"]); break; - case 6 : + case 7 : $qb->orderBy('table.fgcancreatepage',$order[0]["dir"]); break; - case 7 : + case 8 : $qb->orderBy('table.fgcancreatecalendar',$order[0]["dir"]); break; - case 8 : + case 9 : $qb->orderBy('table.fgcancreateblog',$order[0]["dir"]); break; - case 9 : + case 10 : $qb->orderBy('table.fgcancreateproject',$order[0]["dir"]); break; } @@ -173,7 +173,9 @@ class GroupController extends Controller if($data->getId()>0&&!$data->getFgall()&&!$data->getFgTemplate()&&$this->isGranted('ROLE_ADMIN')) $action.="$data->getId()))."'>"; if(!$data->getFgall()) $action .="$data->getId()))."'>"; - + + if($data->getFgcanshare()) + $action.="$data->getId()))."'>"; } else { $fgproprio=($user==$data->getOwner()); @@ -190,9 +192,11 @@ class GroupController extends Controller $action .="$data->getId()))."'>"; } else { - $action.="$data->getId()))."' data-method='out'>"; + $action.="$data->getId()))."'>"; } + if($data->getFgcanshare()) + $action.="$data->getId()))."'>"; } @@ -200,14 +204,22 @@ class GroupController extends Controller if($this->GetParameter("masteridentity")=="LDAP") $filtre=$data->getLdapfilter(); if($this->GetParameter("masteridentity")=="SSO") $filtre=$data->getAttributes(); + if ($data->getIcon()) + $groupinfo = "getIcon()->getLabel()."' class='avatar' style='background-color:transparent'/>"; + else + $groupinfo = ""; + $userinfo=""; if($data->getOwner()) { $userinfo.="getOwner()->getAvatar()."' class='avatar' style='margin:0px 5px 0px 0px;display:inline-block;'>"; - $userinfo.=$data->getOwner()->getUsername(); + $userinfo.="
".$data->getOwner()->getUsername(); } + + array_push($output["data"],array( $action, + $groupinfo, $data->getLabel(), ($data->getFgopen()?"oui":"non"), $filtre, @@ -1067,6 +1079,36 @@ class GroupController extends Controller return $response; } + public function statisticAction($id,$access) { + $group=$this->getData($id); + $em = $this->getDoctrine()->getManager(); + if(!$group) throw $this->createNotFoundException('Permission denied'); + + if($access!="config") { + $usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$this->getUser(),"group"=>$group]); + if(!$usergroup) throw $this->createNotFoundException('Permission denied'); + } + + $groupcptvisite=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptvisite","group"=>$group]); + $groupcptmessage=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptmessage","group"=>$group]); + $groupcptblogarticle=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptblogarticle","group"=>$group]); + $groupcptprojecttask=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"groupcptprojecttask","group"=>$group]); + + + return $this->render('CadolesCoreBundle:Group:statistic.html.twig',[ + 'useheader' => true, + 'usemenu' => false, + 'usesidebar' => ($access=="config"), + 'access' => $access, + 'group' => $group, + 'groupcptvisite' => $groupcptvisite, + 'groupcptmessage' => $groupcptmessage, + 'groupcptblogarticle' => $groupcptblogarticle, + 'groupcptprojecttask' => $groupcptprojecttask, + + ]); + } + protected function canManager($group,$access) { if($access!="config") { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/StatisticController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/StatisticController.php new file mode 100644 index 00000000..d6a8f1ad --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/StatisticController.php @@ -0,0 +1,109 @@ +getDoctrine()->getManager(); + + $totcptvisite=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptvisite"]); + $totcptvisitegroup=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptvisitegroup"]); + $totcptmessage=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptmessage"]); + $totcptblogarticle=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptblogarticle"]); + $totcptprojecttask=$em->getRepository("CadolesCoreBundle:Statistic")->findOneBy(["keyvalue"=>"totcptprojecttask"]); + + //groupcptvisite + $statistics=$em->getRepository("CadolesCoreBundle:Statistic")->findBy(["keyvalue"=>"groupcptvisite"]); + $groupcptvisite=[]; + foreach($statistics as $statistic) { + $value=$statistic->getValue(); + $tmp=[ + "id" => $statistic->getGroup()->getId(), + "name" => $statistic->getGroup()->getLabel(), + "value" => end($value), + ]; + array_push($groupcptvisite,$tmp); + } + usort($groupcptvisite, function($a, $b) { + return $a['value'] <=> $b['value']; + }); + $topgroupcptvisite = array_slice($groupcptvisite, -20); + + //groupcptmessage + $statistics=$em->getRepository("CadolesCoreBundle:Statistic")->findBy(["keyvalue"=>"groupcptmessage"]); + $groupcptmessage=[]; + foreach($statistics as $statistic) { + $value=$statistic->getValue(); + $tmp=[ + "id" => $statistic->getGroup()->getId(), + "name" => $statistic->getGroup()->getLabel(), + "value" => end($value), + ]; + array_push($groupcptmessage,$tmp); + } + usort($groupcptmessage, function($a, $b) { + return $a['value'] <=> $b['value']; + }); + $topgroupcptmessage = array_slice($groupcptmessage, -20); + + //groupcptblogarticle + $statistics=$em->getRepository("CadolesCoreBundle:Statistic")->findBy(["keyvalue"=>"groupcptblogarticle"]); + $groupcptblogarticle=[]; + foreach($statistics as $statistic) { + $value=$statistic->getValue(); + $tmp=[ + "id" => $statistic->getGroup()->getId(), + "name" => $statistic->getGroup()->getLabel(), + "value" => end($value), + ]; + array_push($groupcptblogarticle,$tmp); + } + usort($groupcptblogarticle, function($a, $b) { + return $a['value'] <=> $b['value']; + }); + $topgroupcptblogarticle = array_slice($groupcptblogarticle, -20); + + //groupcptprojecttask + $statistics=$em->getRepository("CadolesCoreBundle:Statistic")->findBy(["keyvalue"=>"groupcptprojecttask"]); + $groupcptprojecttask=[]; + foreach($statistics as $statistic) { + $value=$statistic->getValue(); + $tmp=[ + "id" => $statistic->getGroup()->getId(), + "name" => $statistic->getGroup()->getLabel(), + "value" => end($value), + ]; + array_push($groupcptprojecttask,$tmp); + } + usort($groupcptprojecttask, function($a, $b) { + return $a['value'] <=> $b['value']; + }); + $topgroupcptprojecttask = array_slice($groupcptprojecttask, -20); + + + + return $this->render('CadolesCoreBundle:Statistic:list.html.twig',[ + 'useheader' => true, + 'usemenu' => false, + 'usesidebar' => true, + 'totcptvisite' => $totcptvisite, + 'totcptvisitegroup' => $totcptvisitegroup, + 'totcptmessage' => $totcptmessage, + 'totcptblogarticle' => $totcptblogarticle, + 'totcptprojecttask' => $totcptprojecttask, + 'groupcptvisite' => $topgroupcptvisite, + 'groupcptmessage' => $topgroupcptmessage, + 'groupcptblogarticle' => $topgroupcptblogarticle, + 'groupcptprojecttask' => $topgroupcptprojecttask, + ]); + } +} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php index e8ac35f7..d6430c7d 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Group.php @@ -176,6 +176,10 @@ class Group */ protected $messages; + /** + * @ORM\OneToMany(targetEntity="Statistic", mappedBy="group", cascade={"persist"}, orphanRemoval=true) + */ + private $statistics; // Champs temporaire protected $nosynconly; @@ -1018,4 +1022,38 @@ class Group { return $this->fgcancreateproject; } + + /** + * Add statistic + * + * @param \Cadoles\CoreBundle\Entity\Statistic $statistic + * + * @return Group + */ + public function addStatistic(\Cadoles\CoreBundle\Entity\Statistic $statistic) + { + $this->statistics[] = $statistic; + + return $this; + } + + /** + * Remove statistic + * + * @param \Cadoles\CoreBundle\Entity\Statistic $statistic + */ + public function removeStatistic(\Cadoles\CoreBundle\Entity\Statistic $statistic) + { + $this->statistics->removeElement($statistic); + } + + /** + * Get statistics + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getStatistics() + { + return $this->statistics; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Statistic.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Statistic.php new file mode 100644 index 00000000..c3a6eea7 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Statistic.php @@ -0,0 +1,118 @@ +id; + } + + /** + * Set keyvalue + * + * @param string $keyvalue + * + * @return Statistic + */ + public function setKeyvalue($keyvalue) + { + $this->keyvalue = $keyvalue; + + return $this; + } + + /** + * Get keyvalue + * + * @return string + */ + public function getKeyvalue() + { + return $this->keyvalue; + } + + /** + * Set value + * + * @param array $value + * + * @return Statistic + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return array + */ + public function getValue() + { + return $this->value; + } + + /** + * Set group + * + * @param \Cadoles\CoreBundle\Entity\Group $group + * + * @return Statistic + */ + public function setGroup(\Cadoles\CoreBundle\Entity\Group $group = null) + { + $this->group = $group; + + return $this; + } + + /** + * Get group + * + * @return \Cadoles\CoreBundle\Entity\Group + */ + public function getGroup() + { + return $this->group; + } +} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 4ea643a1..35f0f9af 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -372,6 +372,10 @@ cadoles_core_config_group_users: path: /config/group/users/{id} defaults: { _controller: CadolesCoreBundle:Group:users, access: config } +cadoles_core_config_group_statistic: + path: /config/group/statistic/{id} + defaults: { _controller: CadolesCoreBundle:Group:statistic, access: config } + cadoles_core_config_group_ajax_usersnotin: path: /config/group/ajax/usersnotin/{id} defaults: { _controller: CadolesCoreBundle:Group:ajaxusersnotin, access: config } @@ -421,6 +425,10 @@ cadoles_core_user_group_users: path: /user/group/users/{id} defaults: { _controller: CadolesCoreBundle:Group:users, access: user } +cadoles_core_user_group_statistic: + path: /user/group/statistic/{id} + defaults: { _controller: CadolesCoreBundle:Group:statistic, access: user } + cadoles_core_user_group_out: path: /user/group/out/{id} defaults: { _controller: CadolesCoreBundle:Group:out, access: user } @@ -471,8 +479,10 @@ cadoles_core_config_whitelist_ajax_list: path: /config/whitelist/ajax/list defaults: { _controller: CadolesCoreBundle:Whitelist:ajaxlist } - - +#== Statistic ============================================================================================================= +cadoles_core_config_statistic: + path: /config/statistic + defaults: { _controller: CadolesCoreBundle:Statistic:list } #== REST ================================================================================================================== cadoles_core_rest_user: diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/list.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/list.html.twig index 967c63bb..1b7b1f8d 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/list.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/list.html.twig @@ -31,13 +31,14 @@ - + + {% if portal_activate %} - + {% if access=="config" %} @@ -57,10 +58,10 @@ {% block localjavascript %} $(document).ready(function() { $('#dataTables').DataTable({ - columnDefs: [ { "targets": 'no-sort', "orderable": false },{ "targets": 'no-visible', "visible": false } ], + columnDefs: [ { "targets": 'no-sort', "orderable": false },{ "targets": 'no-visible', "visible": false },{"targets": "text-center", "className": "text-center"} ], responsive: true, iDisplayLength: 100, - order: [[ 1, "asc" ]], + order: [[ 2, "asc" ]], processing: true, serverSide: true, ajax: "{{ path('cadoles_core_'~access~'_group_ajax_list') }}", diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/statistic.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/statistic.html.twig new file mode 100644 index 00000000..12d43f08 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Group/statistic.html.twig @@ -0,0 +1,131 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +

Statistiques {{ group.label }}

+ Fermer +

+ +
+
+ Compteur de visites journalière +
+ +
+
+
+
+ +
+
+
+
+ Evolution du nombre de message dans les tchat +
+ +
+
+
+
+
+ +
+
+
+ Evolution du nombre d'articles de blog +
+ +
+
+
+
+
+ +
+
+
+ Evolution du nombre de tâches +
+ +
+
+
+
+
+
+ +{% endblock %} + +{% block localjavascript %} + $(document).ready(function() { + groupcptvisite(); + groupcptmessage(); + groupcptblogarticle(); + groupcptprojecttask(); + + $(window).resize(function() { + window.groupcptvisite.redraw(); + window.groupcptmessage.redraw(); + window.groupcptblogarticle.redraw(); + window.groupcptprojecttask.redraw(); + }); + }); + + function groupcptvisite() { + window.groupcptvisite = Morris.Area({ + element: 'groupcptvisite', + data: [ + {% set before = 0 %} + {% for date, cpt in groupcptvisite.value %} + {% set now = cpt - before %} + {% set before = cpt %} + { x: '{{ date }}', a: {{ now }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ['Nombre de visites'] + }); + } + + function groupcptmessage() { + window.groupcptmessage = Morris.Area({ + element: 'groupcptmessage', + data: [ + {% for date, cpt in groupcptmessage.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ['Nombre total de messages tchat'] + }); + } + + function groupcptblogarticle() { + window.groupcptblogarticle = Morris.Area({ + element: 'groupcptblogarticle', + data: [ + {% for date, cpt in groupcptblogarticle.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ["Nombre total d'articles de blog"] + }); + } + + function groupcptprojecttask() { + window.groupcptprojecttask = Morris.Area({ + element: 'groupcptprojecttask', + data: [ + {% for date, cpt in groupcptprojecttask.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ["Nombre total de tâches"] + }); + } +{% endblock %} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Statistic/list.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Statistic/list.html.twig new file mode 100644 index 00000000..ee72eae2 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Statistic/list.html.twig @@ -0,0 +1,263 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} +

Statistiques

+ +
+
+ Compteur de visites journalière +
+ +
+
+
+
+ +
+
+ Compteur de visites journalière des groupes de travail +
+ +
+
+
+
+ +
+
+
+
+ Evolution du nombre de message dans les tchat +
+ +
+
+
+
+
+ +
+
+
+ Evolution du nombre d'articles de blog +
+ +
+
+
+
+
+ +
+
+
+ Evolution du nombre de tâches +
+ +
+
+
+
+
+ +
+
+
+ TOP 20 des groupes les plus visités +
+ +
+
+
+
+
+ +
+
+
+ TOP 20 des groupes avec le plus de messages chat +
+ +
+
+
+
+
+ +
+
+
+ TOP 20 des groupes avec le plus d'articles de blog +
+ +
+
+
+
+
+ +
+
+
+ TOP 20 des groupes avec le plus de tâches +
+ +
+
+
+
+
+
+ +{% endblock %} + +{% block localjavascript %} + $(document).ready(function() { + totcptvisite(); + totcptvisitegroup(); + totcptmessage(); + totcptblogarticle(); + totcptprojecttask(); + groupcptvisite(); + groupcptmessage(); + groupcptblogarticle(); + groupcptprojecttask(); + + $(window).resize(function() { + window.totcptvisite.redraw(); + window.totcptvisitegroup.redraw(); + window.totcptmessage.redraw(); + window.totcptblogarticle.redraw(); + window.totcptprojecttask.redraw(); + }); + }); + + function totcptvisite() { + window.totcptvisite = Morris.Area({ + element: 'totcptvisite', + data: [ + {% set before = 0 %} + {% for date, cpt in totcptvisite.value %} + {% set now = cpt - before %} + {% set before = cpt %} + { x: '{{ date }}', a: {{ now }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ['Nombre de visites'] + }); + } + + + function totcptvisitegroup() { + window.totcptvisitegroup = Morris.Area({ + element: 'totcptvisitegroup', + data: [ + {% set before = 0 %} + {% for date, cpt in totcptvisitegroup.value %} + {% set now = cpt - before %} + {% set before = cpt %} + { x: '{{ date }}', a: {{ now }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ['Nombre de visites des groupes'] + }); + } + + function totcptmessage() { + window.totcptmessage = Morris.Area({ + element: 'totcptmessage', + data: [ + {% for date, cpt in totcptmessage.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ['Nombre total de messages tchat'] + }); + } + + function totcptblogarticle() { + window.totcptblogarticle = Morris.Area({ + element: 'totcptblogarticle', + data: [ + {% for date, cpt in totcptblogarticle.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ["Nombre total d'articles de blog"] + }); + } + + function totcptprojecttask() { + window.totcptprojecttask = Morris.Area({ + element: 'totcptprojecttask', + data: [ + {% for date, cpt in totcptprojecttask.value %} + { x: '{{ date }}', a: {{ cpt }} }{% if not loop.last %},{%endif%} + {% endfor %} + ], + xkey: 'x', + ykeys: ['a'], + labels: ["Nombre total de tâches"] + }); + } + + function groupcptvisite() { + window.groupcptvisite = Morris.Donut({ + element: 'groupcptvisite', + data: [ + {% for cpt in groupcptvisite %} + {label: "{{ cpt.name|raw }}", value: {{ cpt.value }}}{% if not loop.last %},{%endif%} + {% endfor %} + ], + resize: true, + redraw: true + }); + } + + function groupcptmessage() { + window.groupcptmessage = Morris.Donut({ + element: 'groupcptmessage', + data: [ + {% for cpt in groupcptmessage %} + {label: "{{ cpt.name|raw }}", value: {{ cpt.value }}}{% if not loop.last %},{%endif%} + {% endfor %} + ], + resize: true, + redraw: true + }); + } + + function groupcptblogarticle() { + window.groupcptblogarticle = Morris.Donut({ + element: 'groupcptblogarticle', + data: [ + {% for cpt in groupcptblogarticle %} + {label: "{{ cpt.name|raw }}", value: {{ cpt.value }}}{% if not loop.last %},{%endif%} + {% endfor %} + ], + resize: true, + redraw: true + }); + } + + function groupcptprojecttask() { + window.groupcptprojecttask = Morris.Donut({ + element: 'groupcptprojecttask', + data: [ + {% for cpt in groupcptprojecttask %} + {label: "{{ cpt.name|raw }}", value: {{ cpt.value }}}{% if not loop.last %},{%endif%} + {% endfor %} + ], + resize: true, + redraw: true + }); + } +{% endblock %} diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronCommand.php b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronCommand.php index b772dbcb..8229b64f 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronCommand.php @@ -50,7 +50,7 @@ class CronCommand extends ContainerAwareCommand $crons = $entityManager->getRepository('CadolesCronBundle:Cron')->toexec(); $i=0; - + if($crons) { $now=new \DateTime(); $this->writelnred(''); diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronexecCommand.php b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronexecCommand.php index cb8c23fb..32e29580 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronexecCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/CronexecCommand.php @@ -26,7 +26,7 @@ class CronexecCommand extends ContainerAwareCommand protected function configure() { $this - ->setName('Cron:Exec') + ->setName('Cron:Run') ->setDescription("Executer les commandes présente dans le bus des commandes à exécuter à la volet") ; } @@ -48,7 +48,7 @@ class CronexecCommand extends ContainerAwareCommand $cronexecs=$this->em->getRepository("CadolesCronBundle:Cronexec")->findAll(); if($cronexecs) { $this->writelnred(''); - $this->writelnred('== Cron:Exec'); + $this->writelnred('== Cron:Run'); $this->writelnred('=========================================================================================================='); foreach($cronexecs as $cron) { diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php index a458524a..d1a74631 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Command/InitDataCommand.php @@ -139,6 +139,25 @@ class InitDataCommand extends ContainerAwareCommand $entity->setNextexecdate($nextdate); $this->entityManager->persist($entity); } + + // Job Statistic + // Toute les 24h à 23h30 + $entity = $this->entityManager->getRepository('CadolesCronBundle:Cron')->find(210); + if(!$entity) { + $entity = new Cron; + $nextdate=$entity->getSubmitdate(); + $nextdate->setTime(23,30); + $entity->setCommand("Core:Statistic"); + $entity->setDescription("Cacul des indicateurs d'usages"); + $entity->setId(210); + $entity->setStatut(2); + $entity->setRepeatcall(0); + $entity->setRepeatexec(0); + $entity->setRepeatinterval(86400); + $entity->setNextexecdate($nextdate); + $this->entityManager->persist($entity); + } + // CRON PORTAIL // Job purge des registrations obsolètes // Toute les 5mn diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Controller/CronController.php b/src/ninegate-1.0/src/Cadoles/CronBundle/Controller/CronController.php index 98e69db3..358e6bd8 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Controller/CronController.php +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Controller/CronController.php @@ -10,6 +10,9 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; + use Cadoles\CronBundle\Entity\Cron; use Cadoles\CronBundle\Form\CronType; @@ -189,18 +192,21 @@ class CronController extends Controller return new Response(json_encode($content), 200); } - public function logAction(Request $request, $id) + public function logAction() { - $kernel = $this->get('kernel'); - $path = $this->get('kernel')->getRootDir() . '/../var/logs/'.$id.'.log'; - $content = file_get_contents($path); - return $this->render('CadolesCronBundle:Cron:logs.html.twig', [ 'useheader' => true, 'usemenu' => false, - 'usesidebar' => true, - "title" => "LOG = ".$id, - "content" => $content + 'usesidebar' => true ]); } + + public function getlogAction(Request $request, $id) + { + $kernel = $this->get('kernel'); + $file = $this->get('kernel')->getRootDir() . '/../var/logs/'.$id.'.log'; + $response = new BinaryFileResponse($file); + $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); + return $response; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml index 923f9672..57264b35 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/config/routing.yml @@ -23,6 +23,9 @@ cadoles_cron_config_cronexecread: defaults: { _controller: CadolesCronBundle:Cron:cronexecread } cadoles_cron_config_log: - path: /config/cron/log/{id} + path: /config/cron/log controller: CadolesCronBundle:Cron:log - defaults: { id: "cron" } \ No newline at end of file + +cadoles_cron_config_getlog: + path: /config/cron/getlog/{id} + controller: CadolesCronBundle:Cron:getlog diff --git a/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/views/Cron/logs.html.twig b/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/views/Cron/logs.html.twig index 8e2100b3..04ac3f05 100644 --- a/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/views/Cron/logs.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CronBundle/Resources/views/Cron/logs.html.twig @@ -1,19 +1,9 @@ {% extends '@CadolesCore/base.html.twig' %} {% block pagewrapper %} -

{{ title }}

+

Télécharger les logs

- Log CRON - Log PROD - Log DEV -

-
-
- Logs -
- -
- {{ content | nl2br }} -
-
+ Log CRON + Log PROD + Log DEV {% endblock %} \ No newline at end of file diff --git a/tmpl/ninegate-init-01.sql b/tmpl/ninegate-init-01.sql index 60d98c98..c54b85c0 100644 --- a/tmpl/ninegate-init-01.sql +++ b/tmpl/ninegate-init-01.sql @@ -40,8 +40,6 @@ INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `f (1240, 1200, 1240, 'Groupes', 'cadoles_core_config_group', 'fa-users', 'ROLE_ADMIN,ROLE_MODO', ''), (1250, 1200, 1250, 'Inscriptions', 'cadoles_core_config_registration', 'fa-pencil-square-o', 'ROLE_ADMIN,ROLE_MODO', ''), (1260, 1200, 1260, 'Utilisateurs', 'cadoles_core_config_user', 'fa-child', 'ROLE_ADMIN,ROLE_MODO', ''), -(1270, 1200, 1270, 'Mailing', 'cadoles_core_config_mailing', 'fa-envelope', 'ROLE_ADMIN,ROLE_MODO', ''), -(1280, 1200, 1280, 'Import Utilisateurs', 'cadoles_core_config_importuser', 'fa-download', 'ROLE_ADMIN,ROLE_MODO', 'importuser_activate'), (1500, NULL, 1500, 'PORTAIL', NULL, 'fa-cubes', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'), (1510, 1500, 1510, 'Modèles de Page', 'cadoles_portal_config_pagetemplate', 'fa-copy', 'ROLE_ADMIN,ROLE_MODO', 'portal_activate'), @@ -78,6 +76,11 @@ INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `f (3160, 3000, 3160, 'Piwik', 'cadoles_portal_config_syncpiwik', 'fa-signal', 'ROLE_ADMIN,ROLE_MODO', 'widpiwik_activate_syncenvole'), (3230, 3000, 3230, 'Wordpress', 'cadoles_portal_config_syncwordpress', 'fa-wordpress', 'ROLE_ADMIN,ROLE_MODO', 'activate_widwordpress'), +(6000, NULL, 6000, 'OUTILS', NULL, 'fa-wrench', 'ROLE_ADMIN,ROLE_MODO', ''), +(6010, 6000, 6010, 'Statistiques', 'cadoles_core_config_statistic', 'fa-bar-chart-o', 'ROLE_ADMIN,ROLE_MODO', ''), +(6020, 6000, 6020, 'Mailing', 'cadoles_core_config_mailing', 'fa-envelope', 'ROLE_ADMIN,ROLE_MODO', ''), +(6030, 6000, 6030, 'Import Utilisateurs', 'cadoles_core_config_importuser', 'fa-download', 'ROLE_ADMIN,ROLE_MODO', 'importuser_activate'), + (7000, NULL, 7000, 'CRON', NULL, 'fa-bolt', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate'), (7010, 7000, 7010, 'Jobs', 'cadoles_cron_config', 'fa-bullseye', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate'), (7020, 7000, 7020, 'Logs', 'cadoles_cron_config_log', 'fa-list-alt', 'ROLE_ADMIN,ROLE_MODO', 'cron_activate'); @@ -131,8 +134,6 @@ INSERT IGNORE permmodo (`route`, `visible`) VALUES ('cadoles_core_config_group',1), ('cadoles_core_config_registration',1), ('cadoles_core_config_user',1), -('cadoles_core_config_mailing',1), -('cadoles_core_config_importuser',0), ('cadoles_portal_config_pagetemplate',1), ('cadoles_portal_config_page',1), ('cadoles_portal_config_item',1), @@ -145,5 +146,8 @@ INSERT IGNORE permmodo (`route`, `visible`) VALUES ('cadoles_portal_config_synclimesurvey',0), ('cadoles_portal_config_syncmoodle',0), ('cadoles_portal_config_syncwordpress',0), +('cadoles_core_config_statistic',1), +('cadoles_core_config_mailing',1), +('cadoles_core_config_importuser',0), ('cadoles_cron_config',0), ('cadoles_cron_config_log',0);
ActionActionIcone Label Ouvert FiltreGroupe de TravailPropriétairePropriétaireCréation Pages Création Calendriers