Commit f8c419e3489f28c51ed3178c0184c4e24e579af8
1 parent
012da777
Exists in
master
and in
1 other branch
força coleta por subrede
Showing
1 changed file
with
43 additions
and
0 deletions
Show diff stats
src/Cacic/CommonBundle/Controller/RedeController.php
| ... | ... | @@ -595,4 +595,47 @@ class RedeController extends Controller |
| 595 | 595 | |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | + | |
| 599 | + public function coletarAction() | |
| 600 | + { | |
| 601 | + $subredesOrig = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->comLocal(); | |
| 602 | + | |
| 603 | + $subredes = array(); | |
| 604 | + | |
| 605 | + foreach ($subredesOrig as $redeItem) { | |
| 606 | + $idRede = $redeItem['idRede']; | |
| 607 | + $subredes["$idRede"]['teIpRede'] = $redeItem['teIpRede']; | |
| 608 | + $subredes["$idRede"]['nmRede'] = $redeItem['nmRede']; | |
| 609 | + $subredes["$idRede"]['nmLocal'] = $redeItem['nmLocal']; | |
| 610 | + } | |
| 611 | + | |
| 612 | + return $this->render( 'CacicCommonBundle:Rede:coletar.html.twig', | |
| 613 | + array( 'subredes' => $subredes )); | |
| 614 | + | |
| 615 | + } | |
| 616 | + | |
| 617 | + public function submitAction(Request $request) | |
| 618 | + { | |
| 619 | + $subredes = $request->get('subrede'); | |
| 620 | + | |
| 621 | + foreach ($subredes as $subrede){ | |
| 622 | + | |
| 623 | + $computadores = $this->getDoctrine()->getRepository('CacicCommonBundle:Computador')->listarPorSubrede($subrede); | |
| 624 | + | |
| 625 | + foreach($computadores as $computador){ | |
| 626 | + | |
| 627 | + $computador->setForcaColeta('S'); | |
| 628 | + $this->getDoctrine()->getManager()->persist( $computador ); | |
| 629 | + | |
| 630 | + } | |
| 631 | + | |
| 632 | + } | |
| 633 | + | |
| 634 | + $this->getDoctrine()->getManager()->flush(); | |
| 635 | + | |
| 636 | + $this->get('session')->getFlashBag()->add('success', 'Dados salvos com sucesso!'); | |
| 637 | + | |
| 638 | + return $this->redirect($this->generateUrl('cacic_rede_coletar') ); | |
| 639 | + | |
| 640 | + } | |
| 598 | 641 | } |
| 599 | 642 | \ No newline at end of file | ... | ... |