/**
  * Create || Update a SeccionEstu entity.
  *
  * @View(serializerEnableMaxDepthChecks=true)
  *
  * @param Request $request
  *
  * @return Response
  *
  */
 public function postAsigAction(Request $request)
 {
     $secc = $request->request->get('secc');
     $notas = $request->request->get('notas');
     $em = $this->getDoctrine()->getManager();
     $entityNota = $em->getRepository('AppBundle:Nota')->findBy(array('secc' => $secc));
     $notaIds = array();
     $notaIdsUpdate = array();
     foreach ($entityNota as $key => $enti) {
         $idEstu = $enti->getPersona()->getId();
         $notaEstu = $enti->getNota();
         $asistEstu = $enti->getAsist();
         if (($keyx = array_search($idEstu, array_column($notas, 'id'))) !== false) {
             if ($notas[$keyx]['nota'] == $notaEstu && $notas[$keyx]['asist'] == $asistEstu) {
                 unset($notas[$keyx]);
                 sort($notas);
             } else {
                 $enti->setNota($notas[$keyx]['nota']);
                 $enti->setAsist($notas[$keyx]['asist']);
                 $notaIdsUpdate[] = $enti;
                 unset($notas[$keyx]);
                 sort($notas);
             }
         } else {
             $notaIds[] = $enti;
         }
     }
     //delete entity
     foreach ($notaIds as $key => $value) {
         $em->remove($value);
     }
     if ($notaIds) {
         $em->flush();
     }
     foreach ($notaIdsUpdate as $key => $value) {
         $em->persist($value);
     }
     if ($notaIdsUpdate) {
         $em->flush();
     }
     //add entity
     $eNota = array();
     foreach ($notas as $key => $value) {
         $entityPersona = $em->getRepository('AppBundle:Persona')->find($value['id']);
         if ($entityPersona) {
             $entitySeccion = $em->getRepository('AppBundle:Seccion')->find($secc);
             $entityNota = new Nota();
             $entityNota->setSecc($entitySeccion);
             $entityNota->setPersona($entityPersona);
             $entityNota->setNota($value['nota']);
             $entityNota->setAsist($value['asist']);
             $em->persist($entityNota);
             array_push($eNota, $entityNota);
         }
     }
     if (count($notas)) {
         $em->flush();
     }
     return $eNota;
 }
Пример #2
0
 public function loadNota(ObjectManager $manager)
 {
     $nota = array(array(1, 12, 1, 16, '80'), array(2, 14, 1, 17, '82'), array(3, 40, 1, 19, '95'), array(4, 41, 1, 19, '95'), array(5, 65, 1, 18, '92'), array(6, 66, 1, 19, '95'), array(7, 67, 1, 19, '95'), array(8, 78, 1, 19, '96'), array(9, 84, 1, 19, '96'), array(10, 87, 1, 17, '90'), array(11, 48, 8, 13, '76'), array(12, 50, 8, 16, '80'), array(13, 55, 8, 12, '75'), array(14, 56, 8, 12, '76'), array(15, 63, 8, 18, '92'), array(16, 69, 8, 19, '96'), array(17, 72, 8, 18, '90'), array(18, 48, 9, 13, '76'), array(19, 50, 9, 17, '82'), array(20, 55, 9, 12, '76'), array(21, 56, 9, 15, '77'), array(22, 63, 9, 19, '96'), array(23, 69, 9, 19, '96'), array(24, 72, 9, 18, '82'), array(25, 48, 10, 15, '78'), array(26, 50, 10, 17, '80'), array(27, 55, 10, 13, '77'), array(28, 56, 10, 16, '79'), array(29, 63, 10, 19, '96'), array(30, 69, 10, 19, '97'), array(31, 72, 10, 18, '88'), array(32, 48, 11, 12, '76'), array(33, 50, 11, 17, '90'), array(34, 55, 11, 13, '77'), array(35, 56, 11, 14, '79'), array(36, 63, 11, 18, '97'), array(37, 69, 11, 19, '97'), array(38, 72, 11, 17, '89'), array(39, 48, 12, 16, '78'), array(40, 50, 12, 17, '80'), array(41, 55, 12, 16, '79'), array(42, 56, 12, 16, '80'), array(43, 63, 12, 18, '93'), array(44, 69, 12, 18, '94'), array(45, 72, 12, 17, '90'), array(46, 65, 2, 20, '99'), array(47, 12, 2, 13, '78'), array(48, 14, 2, 16, '80'), array(49, 40, 2, 18, '93'), array(50, 41, 2, 19, '98'), array(51, 66, 2, 18, '95'), array(52, 67, 2, 17, '96'), array(53, 78, 2, 20, '99'), array(54, 84, 2, 19, '96'), array(55, 87, 2, 16, '92'), array(56, 12, 3, 14, '87'), array(57, 14, 3, 16, '87'), array(58, 40, 3, 19, '98'), array(59, 41, 3, 19, '99'), array(60, 65, 3, 20, '99'), array(61, 66, 3, 18, '95'), array(62, 67, 3, 18, '96'), array(63, 78, 3, 20, '99'), array(64, 84, 3, 19, '97'), array(65, 87, 3, 18, '95'), array(66, 12, 4, 14, '80'), array(67, 14, 4, 17, '87'), array(68, 40, 4, 18, '95'), array(69, 41, 4, 17, '94'), array(70, 65, 4, 19, '98'), array(71, 66, 4, 17, '95'), array(72, 67, 4, 17, '95'), array(73, 78, 4, 19, '97'), array(74, 84, 4, 18, '96'), array(75, 87, 4, 17, '91'), array(76, 12, 5, 16, '87'), array(77, 14, 5, 17, '89'), array(78, 40, 5, 18, '97'), array(79, 41, 5, 18, '97'), array(80, 65, 5, 17, '92'), array(81, 66, 5, 17, '94'), array(82, 67, 5, 17, '95'), array(83, 78, 5, 19, '99'), array(84, 84, 5, 18, '95'), array(85, 87, 5, 16, '89'), array(86, 12, 6, 15, '87'), array(87, 14, 6, 17, '88'), array(88, 40, 6, 19, '98'), array(89, 41, 6, 19, '98'), array(90, 65, 6, 18, '95'), array(91, 66, 6, 18, '96'), array(92, 67, 6, 18, '97'), array(93, 78, 6, 18, '97'), array(94, 84, 6, 18, '96'), array(95, 87, 6, 15, '89'), array(96, 12, 7, 15, '87'), array(97, 14, 7, 18, '89'), array(98, 40, 7, 18, '97'), array(99, 41, 7, 18, '98'), array(100, 65, 7, 19, '96'), array(101, 66, 7, 17, '93'), array(102, 67, 7, 17, '91'), array(103, 78, 7, 18, '97'), array(104, 84, 7, 17, '96'), array(105, 87, 7, 16, '91'), array(106, 64, 8, 17, '89'), array(107, 73, 8, 14, '82'), array(108, 64, 9, 17, '89'), array(109, 73, 9, 16, '88'), array(110, 64, 11, 15, '89'), array(111, 73, 11, 14, '87'), array(112, 64, 10, 16, '91'), array(113, 73, 10, 15, '82'), array(114, 64, 12, 18, '92'), array(115, 73, 12, 17, '89'), array(116, 48, 13, 12, '78'), array(117, 50, 13, 17, '87'), array(118, 55, 13, 12, '79'), array(119, 56, 13, 13, '84'), array(120, 63, 13, 19, '93'), array(121, 64, 13, 17, '92'), array(122, 69, 13, 19, '98'), array(123, 72, 13, 17, '91'), array(124, 73, 13, 16, '89'), array(125, 48, 14, 14, '87'), array(126, 50, 14, 17, '90'), array(127, 55, 14, 12, '89'), array(128, 56, 14, 13, '89'), array(129, 63, 14, 19, '94'), array(130, 64, 14, 17, '94'), array(131, 69, 14, 19, '97'), array(132, 72, 14, 17, '89'), array(133, 73, 14, 16, '89'), array(134, 48, 15, 12, '79'), array(135, 50, 15, 15, '89'), array(136, 55, 15, 12, '77'), array(137, 56, 15, 12, '77'), array(138, 63, 15, 17, '91'), array(139, 64, 15, 17, '89'), array(140, 69, 15, 19, '97'), array(141, 72, 15, 17, '85'), array(142, 73, 15, 14, '86'), array(143, 48, 16, 12, '79'), array(144, 50, 16, 16, '87'), array(145, 55, 16, 13, '77'), array(146, 56, 16, 12, '77'), array(147, 63, 16, 19, '97'), array(148, 64, 16, 17, '87'), array(149, 69, 16, 19, '98'), array(150, 72, 16, 17, '87'), array(151, 73, 16, 16, '87'), array(152, 48, 17, 0, '1'), array(153, 50, 17, 17, '87'), array(154, 55, 17, 13, '79'), array(155, 56, 17, 14, '80'), array(156, 63, 17, 19, '98'), array(157, 64, 17, 18, '91'), array(158, 69, 17, 19, '98'), array(159, 72, 17, 17, '91'), array(160, 73, 17, 17, '90'), array(161, 48, 18, 12, '79'), array(162, 50, 18, 15, '89'), array(163, 55, 18, 12, '79'), array(164, 56, 18, 12, '79'), array(165, 63, 18, 18, '98'), array(166, 64, 18, 15, '89'), array(167, 69, 18, 19, '98'), array(168, 72, 18, 16, '90'), array(169, 73, 18, 14, '90'), array(170, 48, 19, 12, '78'), array(171, 50, 19, 17, '91'), array(172, 55, 19, 16, '90'), array(173, 56, 19, 16, '87'), array(174, 63, 19, 19, '98'), array(175, 64, 19, 18, '92'), array(176, 69, 19, 19, '98'), array(177, 72, 19, 17, '91'), array(178, 73, 19, 17, '90'), array(179, 48, 41, 12, '60'), array(180, 50, 41, 17, '89'), array(181, 55, 41, 13, '87'), array(182, 56, 41, 13, '84'), array(183, 63, 41, 19, '98'), array(184, 64, 41, 17, '90'), array(185, 69, 41, 19, '98'), array(186, 72, 41, 17, '90'), array(187, 73, 41, 17, '92'), array(188, 48, 40, 13, '80'), array(189, 50, 40, 16, '91'), array(190, 55, 40, 13, '91'), array(191, 56, 40, 12, '79'), array(192, 63, 40, 19, '98'), array(193, 64, 40, 17, '92'), array(194, 69, 40, 19, '97'), array(195, 72, 40, 16, '89'), array(196, 73, 40, 17, '92'), array(197, 48, 39, 16, '80'), array(198, 50, 39, 18, '92'), array(199, 55, 39, 16, '86'), array(200, 56, 39, 16, '87'), array(201, 63, 39, 19, '98'), array(202, 64, 39, 18, '92'), array(203, 69, 39, 19, '98'), array(204, 72, 39, 17, '89'), array(205, 73, 39, 17, '90'), array(206, 48, 38, 12, '79'), array(207, 50, 38, 15, '90'), array(208, 55, 38, 12, '79'), array(209, 56, 38, 12, '83'), array(210, 63, 38, 18, '97'), array(211, 64, 38, 15, '90'), array(212, 69, 38, 18, '97'), array(213, 72, 38, 15, '87'), array(214, 73, 38, 14, '91'), array(215, 48, 37, 15, '79'), array(216, 50, 37, 17, '89'), array(217, 55, 37, 13, '79'), array(218, 56, 37, 14, '89'), array(219, 63, 37, 19, '98'), array(220, 64, 37, 18, '90'), array(221, 69, 37, 19, '98'), array(222, 72, 37, 17, '90'), array(223, 73, 37, 18, '92'), array(224, 48, 36, 14, '78'), array(225, 50, 36, 17, '89'), array(226, 55, 36, 14, '87'), array(227, 56, 36, 14, '89'), array(228, 63, 36, 19, '98'), array(229, 64, 36, 18, '91'), array(230, 69, 36, 19, '98'), array(231, 72, 36, 16, '89'), array(232, 73, 36, 17, '90'), array(233, 48, 20, 13, '78'), array(234, 50, 20, 16, '89'), array(235, 55, 20, 13, '80'), array(236, 56, 20, 12, '89'), array(237, 63, 20, 19, '98'), array(238, 64, 20, 17, '91'), array(239, 69, 20, 19, '98'), array(240, 72, 20, 15, '83'), array(241, 73, 20, 17, '92'), array(242, 48, 21, 13, '79'), array(243, 50, 21, 17, '89'), array(244, 55, 21, 15, '79'), array(245, 56, 21, 14, '79'), array(246, 63, 21, 19, '97'), array(247, 64, 21, 18, '92'), array(248, 69, 21, 19, '98'), array(249, 72, 21, 15, '89'), array(250, 73, 21, 18, '91'), array(251, 48, 25, 14, '79'), array(252, 50, 25, 18, '90'), array(253, 55, 25, 13, '87'), array(254, 56, 25, 13, '87'), array(255, 63, 25, 20, '98'), array(256, 64, 25, 18, '91'), array(257, 69, 25, 20, '98'), array(258, 72, 25, 17, '89'), array(259, 73, 25, 17, '89'), array(260, 48, 26, 12, '78'), array(261, 50, 26, 15, '91'), array(262, 55, 26, 12, '78'), array(263, 56, 26, 12, '78'), array(264, 63, 26, 19, '97'), array(265, 64, 26, 16, '91'), array(266, 69, 26, 19, '98'), array(267, 72, 26, 16, '91'), array(268, 73, 26, 17, '91'), array(269, 48, 22, 16, '79'), array(270, 50, 22, 17, '89'), array(271, 55, 22, 14, '89'), array(272, 56, 22, 13, '83'), array(273, 63, 22, 19, '98'), array(274, 64, 22, 18, '92'), array(275, 69, 22, 19, '97'), array(276, 72, 22, 15, '90'), array(277, 73, 22, 17, '91'), array(278, 48, 23, 12, '79'), array(279, 50, 23, 14, '82'), array(280, 55, 23, 12, '79'), array(281, 56, 23, 12, '81'), array(282, 63, 23, 19, '98'), array(283, 64, 23, 16, '81'), array(284, 69, 23, 19, '98'), array(285, 72, 23, 16, '79'), array(286, 73, 23, 15, '79'), array(287, 48, 28, 12, '79'), array(288, 50, 28, 16, '90'), array(289, 55, 28, 12, '89'), array(290, 56, 28, 13, '79'), array(291, 63, 28, 18, '97'), array(292, 64, 28, 15, '90'), array(293, 69, 28, 18, '98'), array(294, 72, 28, 14, '89'), array(295, 73, 28, 15, '90'), array(296, 48, 29, 14, '78'), array(300, 50, 29, 18, '90'), array(301, 55, 29, 14, '87'), array(302, 56, 29, 14, '80'), array(303, 63, 29, 19, '98'), array(304, 64, 29, 17, '90'), array(305, 69, 29, 19, '98'), array(306, 72, 29, 14, '89'), array(307, 73, 29, 16, '89'), array(332, 48, 30, 12, '78'), array(333, 50, 30, 14, '91'), array(334, 55, 30, 12, '87'), array(335, 56, 30, 13, '87'), array(336, 63, 30, 18, '98'), array(337, 64, 30, 15, '89'), array(338, 69, 30, 19, '97'), array(339, 72, 30, 14, '84'), array(340, 73, 30, 15, '89'), array(341, 48, 31, 14, '79'), array(342, 50, 31, 17, '89'), array(343, 55, 31, 14, '87'), array(344, 56, 31, 14, '87'), array(345, 63, 31, 19, '98'), array(346, 64, 31, 17, '89'), array(347, 69, 31, 19, '98'), array(348, 72, 31, 14, '89'), array(349, 73, 31, 17, '90'), array(350, 48, 32, 15, '79'), array(351, 50, 32, 17, '89'), array(352, 55, 32, 14, '82'), array(353, 56, 32, 15, '89'), array(354, 63, 32, 20, '98'), array(355, 64, 32, 18, '91'), array(356, 69, 32, 20, '98'), array(357, 72, 32, 16, '87'), array(358, 73, 32, 18, '92'), array(359, 48, 33, 12, '79'), array(360, 50, 33, 15, '88'), array(361, 55, 33, 12, '84'), array(362, 56, 33, 13, '84'), array(363, 63, 33, 18, '98'), array(364, 64, 33, 16, '92'), array(365, 69, 33, 18, '98'), array(366, 72, 33, 14, '89'), array(367, 73, 33, 15, '91'), array(368, 48, 34, 16, '80'), array(369, 50, 34, 18, '90'), array(370, 55, 34, 16, '89'), array(371, 56, 34, 16, '89'), array(372, 63, 34, 19, '98'), array(373, 64, 34, 18, '93'), array(374, 69, 34, 19, '98'), array(375, 72, 34, 17, '91'), array(376, 73, 34, 17, '92'), array(377, 48, 35, 12, '78'), array(378, 50, 35, 16, '90'), array(379, 55, 35, 13, '87'), array(380, 56, 35, 14, '89'), array(381, 63, 35, 18, '97'), array(382, 64, 35, 16, '91'), array(383, 69, 35, 19, '98'), array(384, 72, 35, 14, '89'), array(385, 73, 35, 16, '90'), array(386, 18, 45, 12, '98'), array(387, 32, 45, 12, '89'), array(388, 39, 45, 15, '96'), array(389, 49, 45, 17, '90'), array(390, 85, 45, 17, '90'), array(391, 68, 46, 17, '90'), array(392, 70, 49, 16, '89'), array(393, 53, 50, 16, '89'), array(394, 24, 51, 16, '87'), array(395, 80, 52, 17, '90'), array(396, 86, 53, 14, '80'));
     $em = $this->container->get('doctrine')->getEntityManager('default');
     foreach ($nota as $data) {
         $entityNota = new Nota();
         /*$entityNota->setNotaId($data[0]);*/
         $entityPersona = $em->getRepository('AppBundle:Persona')->find($data[1]);
         $entityNota->setPersona($entityPersona);
         $entitySeccion = $em->getRepository('AppBundle:Seccion')->find($data[2]);
         $entityNota->setSecc($entitySeccion);
         $entityNota->setNota($data[3]);
         $entityNota->setAsist($data[4]);
         $manager->persist($entityNota);
     }
     $manager->flush();
 }