コード例 #1
0
 /**
  * deleteAbonement
  */
 public function deleteAction(Request $request, $id)
 {
     if (false === $this->isZkGranded(array('ROLE_ADDRESSES_DELETE'))) {
         $error = $this->get('translator')->trans('You do not have enough privileges to carry out this action');
         $this->get('session')->getFlashBag()->add('error', $error);
     } else {
         $em = $this->getDoctrine()->getManager();
         $object = $em->getRepository($this->class)->find($id);
         if ($object->hasChildren()) {
             $text = $this->get('translator')->trans('has.children');
             throw new NotFoundHttpException($text);
         }
         if ($object) {
             $log = $this->getTotalUser()->getName() . ' :: ' . $object->getNameUa() . ' ' . $object->getEprasysName() . ' -> delete';
             $em->remove($object);
             $em->flush();
             StaticFunctions::writeLog($this->get('kernel')->getRootDir() . '/logs/deleteStreetAction.log', array($log));
             $this->get('session')->getFlashBag()->add('success', 'Вулицю видалено');
         } else {
             throw new NotFoundHttpException('Вулицю не знайдено!');
         }
     }
     return $this->redirect($this->generateUrl('crm_addresses_street_list'));
 }
コード例 #2
0
 /**
  * deleteAbonement
  */
 public function deleteDepAction(Request $request, $id)
 {
     if (false === $this->isZkGranded(array('ROLE_ADDRESSES_DELETE'))) {
         $error = $this->get('translator')->trans('You do not have enough privileges to carry out this action');
         $this->get('session')->getFlashBag()->add('error', $error);
     } else {
         $em = $this->getDoctrine()->getManager();
         $object = $em->getRepository('Crm\\AddressesBundle\\Entity\\ServiceOrgDep')->find($id);
         if ($object) {
             $service_org_id = $object->getServiceOrg()->getId();
             $log = $this->get('security.context')->getToken()->getUser()->getName() . ' :: ' . $object->getServiceOrg()->getName() . ' ' . $object->getName() . ' -> delete';
             $em->remove($object);
             $em->flush();
             StaticFunctions::writeLog($this->get('kernel')->getRootDir() . '/logs/deleteServiceOrgDepAction.log', array($log));
             $this->get('session')->getFlashBag()->add('success', 'Підрозділ видалено');
         } else {
             throw new NotFoundHttpException('Підрозділ не знайдено!');
         }
     }
     return $this->redirect($this->generateUrl('crm_addresses_service_org_edit', array('id' => $service_org_id)));
 }
コード例 #3
0
 /**
  * deleteBrand
  */
 public function deleteBrandAction(Request $request, $id)
 {
     if (false === $this->isZkGranded(array('ROLE_ADDRESSES_DELETE'))) {
         $error = $this->get('translator')->trans('You do not have enough privileges to carry out this action');
         $this->get('session')->getFlashBag()->add('error', $error);
     } else {
         $em = $this->getDoctrine()->getManager();
         $object = $em->getRepository('Crm\\AddressesBundle\\Entity\\Brand')->find($id);
         $parad_id = $object->getParad()->getId();
         if (!$object) {
             throw new NotFoundHttpException('object не знайдено!');
         }
         if ($object) {
             $log = $this->getTotalUser()->getName() . ' :: ' . $object->getBrandType() . ", Монтажник: " . $object->getWorker() . " Дата установки" . $object->getDateInstall()->format('Y-m-d') . ' -> delete';
             $em->remove($object);
             $em->flush();
             StaticFunctions::writeLog($this->get('kernel')->getRootDir() . '/logs/deleteBrandAction.log', array($log));
             $text = $object->getBrandType() . ' видалено!';
             $this->get('session')->getFlashBag()->add('success', $text);
         }
     }
     return $this->redirect($this->generateUrl('crm_addresses_parad_edit', array('id' => $parad_id)));
 }
コード例 #4
0
 /**
  * deleteAbonement
  */
 public function deleteAction(Request $request, $id)
 {
     if (false === $this->isZkGranded(array('ROLE_ADDRESSES_FLAT_ATTRIBUTE_WRITE'))) {
         $error = $this->get('translator')->trans('You do not have enough privileges to carry out this action');
         $this->get('session')->getFlashBag()->add('error', $error);
     } else {
         $em = $this->getDoctrine()->getManager();
         $object = $em->getRepository($this->class)->find($id);
         if (!$object) {
             throw new NotFoundHttpException('Квартиру не знайдено!');
         }
         if ($object) {
             $log = $this->get('security.context')->getToken()->getUser()->getName() . ' :: ' . $object->getStreetNameUa() . ", " . $object->getHouseName() . " p" . $object->getParadName() . " k" . $object->getName() . ' -> delete';
             $em->remove($object);
             $em->flush();
             StaticFunctions::writeLog($this->get('kernel')->getRootDir() . '/logs/deleteParadAction.log', array($log));
             $this->get('session')->getFlashBag()->add('success', 'Квартиру видалено');
         }
     }
     $referer = $request->headers->get('referer');
     return new RedirectResponse($referer);
 }
コード例 #5
0
 /**
  * deleteRackAbonement
  */
 public function deleteAction(Request $request, $id)
 {
     if (false === $this->isZkGranded(array('ROLE_ADDRESSES_DELETE'))) {
         $error = $this->get('translator')->trans('You do not have enough privileges to carry out this action');
         $this->get('session')->getFlashBag()->add('error', $error);
     } else {
         $em = $this->getDoctrine()->getManager();
         $object = $em->getRepository($this->class)->find($id);
         $rack_id = $object->getRack()->getId();
         if ($object) {
             $log = $this->getTotalUser()->getName() . ' :: ' . $object->getName() . ' -> delete';
             $em->remove($object);
             $em->flush();
             StaticFunctions::writeLog($this->get('kernel')->getRootDir() . '/logs/deleteSwitchDeviceAction.log', array($log));
             $this->get('session')->getFlashBag()->add('success', 'Свіч видалено');
         } else {
             throw new NotFoundHttpException('Свіч не знайдено!');
         }
     }
     return $this->redirect($this->generateUrl('crm_addresses_rack_edit', array('id' => $rack_id)));
 }